meokey Posted April 3, 2009 Share Posted April 3, 2009 (edited) Is it possible to make the following work? Thanks. ; test $inifile="test.ini" IniWrite($inifile, "English", "string1", '"There is a(an) " & $var & " in the box."') dim $aaa $var="apple" Assign("aaa",IniRead($inifile,"English","string1", "")) MsgBox(0, "", $aaa) Edited April 3, 2009 by meokey Link to comment Share on other sites More sharing options...
Authenticity Posted April 3, 2009 Share Posted April 3, 2009 (edited) $var = "apple" has to be declared or assigned before using it. ; test Dim $aaa, $var="apple", $inifile="test.ini" IniWrite($inifile, "English", "string1", "There is a " & $var & " in the box.") ;Assign("aaa",IniRead($inifile,"English","string1", "")) $aaa = IniRead($inifile,"English","string1", "") MsgBox(0, "", $aaa) Edited April 3, 2009 by Authenticity Link to comment Share on other sites More sharing options...
meokey Posted April 3, 2009 Author Share Posted April 3, 2009 (edited) Thanks for replying, but sorry I didn't make myself clear.I want to put $var into the string, and assign it LATER when I know what's $var. OK, I modify the code a little:; test $inifile="test.ini" IniWrite($inifile, "English", "string1", '"There is a(an) " & $var & " in the box."') dim $aaa $var="apple" Assign("aaa",IniRead($inifile,"English","string1", "")) MsgBox(0, "", $aaa) $var="pear" Assign("aaa",IniRead($inifile,"English","string1", "")) MsgBox(0, "", $aaa) Edited April 3, 2009 by meokey Link to comment Share on other sites More sharing options...
Developers Jos Posted April 3, 2009 Developers Share Posted April 3, 2009 How about: ; test $inifile="test.ini" IniWrite($inifile, "English", "string1", '"There is a(an) $var in the box."') dim $aaa $var="apple" $aaa = StringReplace(IniRead($inifile,"English","string1", ""),"$var",$var) MsgBox(0, "", $aaa) $var="pear" $aaa = StringReplace(IniRead($inifile,"English","string1", ""),"$var",$var) MsgBox(0, "", $aaa) 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. Link to comment Share on other sites More sharing options...
martin Posted April 3, 2009 Share Posted April 3, 2009 Thanks for replying, but sorry I didn't make myself clear. I want to put $var into the string, and assign it LATER when I know what's $var. OK, I modify the code a little: ; test $inifile="test.ini" IniWrite($inifile, "English", "string1", '"There is a(an) " & $var & " in the box."') dim $aaa $var="apple" Assign("aaa",IniRead($inifile,"English","string1", "")) MsgBox(0, "", $aaa) $var="pear" Assign("aaa",IniRead($inifile,"English","string1", "")) MsgBox(0, "", $aaa) ; test OPt("ExpandVarStrings",1);<--see the help for explanation $inifile="test.ini" $variablename = "var" IniWrite($inifile, "English", "string1", "There is a(an) $" & $variablename & "$ in the box.") dim $aaa $var="apple" Assign("aaa",IniRead($inifile,"English","string1", "")) MsgBox(0, "", $aaa) $var="pear" Assign("aaa",IniRead($inifile,"English","string1", "")) MsgBox(0, "", $aaa) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
meokey Posted April 3, 2009 Author Share Posted April 3, 2009 (edited) Thanks Martin and Jos. This is exactly what I want. ; test OPt("ExpandVarStrings",1);<--see the help for explanation $inifile="test.ini" $variablename = "var" IniWrite($inifile, "English", "string1", "There is a(an) $" & $variablename & "$ in the box.") dim $aaa $var="apple" Assign("aaa",IniRead($inifile,"English","string1", "")) MsgBox(0, "", $aaa) $var="pear" Assign("aaa",IniRead($inifile,"English","string1", "")) MsgBox(0, "", $aaa) Edited April 3, 2009 by meokey Link to comment Share on other sites More sharing options...
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