CyberSlug Posted October 17, 2004 Posted October 17, 2004 I get a message box saying The value of foo is and nothing else... Shouldn't it also print 42 ???Opt("ExpandVarStrings", 1) $foo = 42 $example = "The value of foo is $foo" Msgbox(4096,"", $example) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Valik Posted October 17, 2004 Posted October 17, 2004 Not only does this not display the data contained in $foo, also, if you add some text to the end of the string like this:$example = "The value of foo is $foo blah blah blah"All you will get is:The value of foo isWhich obviously has everything after the variable truncated.
SlimShady Posted October 17, 2004 Posted October 17, 2004 Just like environment variables, you have to add the special char also at the end. If you want to use the variable $foo, use it like this $foo$. I adjusted your example: Opt("ExpandVarStrings", 1) $foo = 42 $example = "The value of foo is $foo$" Msgbox(4096,"", $example)
Developers Jos Posted October 17, 2004 Developers Posted October 17, 2004 Just like environment variables, you have to add the special char also at the end.If you want to use the variable $foo, use it like this $foo$.I adjusted your example:Opt("ExpandVarStrings", 1) $foo = 42 $example = "The value of foo is $foo$" Msgbox(4096,"", $example)<{POST_SNAPBACK}>Correct, but shouldn't this also work ?Opt ("ExpandVarStrings", 1) $foo = 42 $example = "The value of $foo is $foo$" MsgBox(4096, "", $example) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Valik Posted October 17, 2004 Posted October 17, 2004 The help file does not describe the usage like that."The value of var1 is $var1".In my opinion, requiring a trailing $ removes most of the usefulness of this feature since it still requires manual editing of the variable to get the syntax correct. If you have to manually edit the variable, then why not just add the concatenation operator and be done with it?JdeB is right. If it does require both leading/trailing $, then it should not be necessary to use $$ to escape $'s since the word needs to have both before it is a variable. That means "The value of $foo is $foo$" should print correctly.However, in the end, I don't really care how it works, I guess; I don't intend to use this feature as it makes code slightly more vague to read.
MHz Posted October 17, 2004 Posted October 17, 2004 Opt("ExpandVarStrings", 1) $foo = 42 $example = 'The value of $$foo is $foo$' Msgbox(4096,"", $example) This outputs 'The value of $foo is 42' Just got to have lots of $$$$ ?
CyberSlug Posted October 17, 2004 Author Posted October 17, 2004 (edited) In the end it doesn't work yet EDIT: Okay, MHz's method works, but the documentation is wrong then. And the truncation thing that Valik pointed out is a bug.I really would like to use this feature in AutoBuilder when doing code generation:'GuiCreate("MyGUI", ' & $w & ", " & $h & ",(@DesktopWidth-" & $w & ")/2, (@DesktopHeight-" & $h & ")/2 , 0x04CF0000)"versus'GuiCreate("MyGUI", $w , $h ,(@DesktopWidth - $w )/2, (@DesktopHeight - $h )/2 , 0x04CF0000)' Edited October 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Developers Jos Posted October 17, 2004 Developers Posted October 17, 2004 In the end it doesn't work yet I really would like to use this feature in AutoBuilder when doing code generation:'GuiCreate("MyGUI", ' & $w & ", " & $h & ",(@DesktopWidth-" & $w & ")/2, (@DesktopHeight-" & $h & ")/2 , 0x04CF0000)"versus'GuiCreate("MyGUI", $w , $h ,(@DesktopWidth - $w )/2, (@DesktopHeight - $h )/2 , 0x04CF0000)'<{POST_SNAPBACK}>CyberSlug,I think it should be:'GuiCreate("MyGUI", $w$ , $h$ ,(@DesktopWidth - $w$ )/2, (@DesktopHeight - $h$ )/2 , 0x04CF0000)' SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
CyberSlug Posted October 17, 2004 Author Posted October 17, 2004 (edited) Actually, here's what I want--I need the double @ symbol: Opt("ExpandVarStrings", 1) Dim $w = 300, $h = 200 $output = 'GuiCreate("MyGUI", $w$, $h$, (@@DesktopWidth-$w$)/2, (@@DesktopHeight-$h$)/2, 0x04CF0000)' MsgBox(4096,"Result", $output) Edited October 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
CyberSlug Posted October 17, 2004 Author Posted October 17, 2004 Another question, is there any way to get arrays to work? $x[5]$ $x$[5] seem to fail Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Administrators Jon Posted October 17, 2004 Administrators Posted October 17, 2004 Yeah it needs a leading and trailing $ - otherwise you wouldn't be able to do $foo = "there" msgbox(0, "", "hello$foo$hello")
CyberSlug Posted October 17, 2004 Author Posted October 17, 2004 Workaround for arrays is to use Assign: Opt("ExpandVarStrings", 1) Dim $x = StringSplit("ABCD","");creates array $x[0], ..., $x[4] For $i = 0 To 4 Assign("x" & $i, $x[$i]);create vars x0, ..., x4 Next MsgBox(4096, "Example", "One $x1$ Two $x2$ Three $x3$ Four $x4$") Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now