Jump to content
Sign in to follow this  
JRSmile

Stringbuilder Functionality

Recommended Posts

JRSmile

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:-)

Share this post


Link to post
Share on other sites
poisonkiller

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

Share this post


Link to post
Share on other sites
ConsultingJoe

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
yes it would

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites
JRSmile

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 :)

  • Like 1

$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:-)

Share this post


Link to post
Share on other sites
marcusawerly
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.

Share this post


Link to post
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
Sign in to follow this  

×