Jump to content

Stringbuilder Functionality


JRSmile
 Share

Recommended Posts

I have missed the stringbuilder functionality from VB.NET inautoit so i added a little UDF to easily add strings together.

every call of _adstr() adds the given variable to the string. If _adstr() is called without arguments the string will be returned and deleted.

#region examples
_adstr("1")
_adstr("1")
_adstr("1")
ConsoleWrite(_adstr())
_adstr("2")
_adstr("3")
_adstr("4")
ConsoleWrite(_adstr())
_adstr("5")
_adstr(@CRLF & @ComputerName & @CRLF)
_adstr("6")
ConsoleWrite(_adstr())
#endregion

Func _adstr($text = "")
    if $text = "" Then
        $tmp = Eval("adstr_var")
        Assign("adstr_var","")
        Return $tmp
    EndIf
    Assign("adstr_var",Eval("adstr_var") & $text,2)
    Return Eval("adstr_var")
EndFunc
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

Nice script! But wouldn't it be less code this way:

#region examples
$str = "1"
$str &= "1"
$str &= "1"
ConsoleWrite($str)
$str = "2"
$str &= "3"
$str &= "4"
ConsoleWrite($str)
$str = "5"
$str &= @CRLF & @ComputerName & @CRLF
$str &= "6"
ConsoleWrite($str)
#endregion
Link to comment
Share on other sites

yes it would

yes but you can alter the function to add for example @CRLFs to it and you have an easy formatting solution :) for mass output of strings.

i just wanted to demonstrate that you don't need to have to register a variable for every kind of stuff :)

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

  • 11 years later...
On 6/9/2007 at 8:43 AM, poisonkiller said:

Nice script! But wouldn't it be less code this way:

 

#region examples
$str = "1"
$str &= "1"
$str &= "1"
ConsoleWrite($str)
$str = "2"
$str &= "3"
$str &= "4"
ConsoleWrite($str)
$str = "5"
$str &= @CRLF & @ComputerName & @CRLF
$str &= "6"
ConsoleWrite($str)
#endregion

Thanks for this.  I know it is super duper old, but it was helpful even today.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...