LynnS Posted August 19, 2008 Share Posted August 19, 2008 I am importing dialog text from an ini file based on the language detected. Some times the message of the dialog needs additional information based on what language is being displayed (because of the location of the person reading the message). I want to be able to include AutoIt macros like @CRLF and @TAB into the ini variables, something like this: certfailmsg = "text line 1" & @CRLF & "line2" & @Tab & "line2 message" & @CRLF & "line3" & @Tab & "line3 message" & @CRLF & "line4" & @Tab & "line4 message" When I run the script, the iniread() function successfully pulls in the entire line, but when I use msgbox to display it, the macros are interpreted as text instead of the AutoIt macro. Any suggestions? Link to comment Share on other sites More sharing options...
Kerros Posted August 19, 2008 Share Posted August 19, 2008 All you should really need to do is wrap everything inside another quote something like certfailmsg = '"text line 1" & @CRLF & "line2" & @Tab & "line2 message" & @CRLF & "line3" & @Tab & "line3 message" & @CRLF & "line4" & @Tab & "line4 message"' Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
LynnS Posted August 19, 2008 Author Share Posted August 19, 2008 That doesn't work... It still displays things as text. I tried single quotes and double quotes. Link to comment Share on other sites More sharing options...
LarryDalooza Posted August 19, 2008 Share Posted August 19, 2008 $certfailmsg = '"text line 1" & @CRLF & "line2" & @Tab & "line2 message" & @CRLF & "line3" & @Tab & "line3 message" & @CRLF & "line4" & @Tab & "line4 message"' MsgBox(4096,"",$certfailmsg) $certfailmsg = Execute($certfailmsg) MsgBox(4096,"",$certfailmsg) AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
Monamo Posted August 19, 2008 Share Posted August 19, 2008 (edited) That doesn't work... It still displays things as text. I tried single quotes and double quotes.Not overly pretty, but see if this works for you. Created a dummy ini file that contained your example entry:[Section] certfailmsg = "text line 1" & @CRLF & "line2" & @Tab & "line2 message" & @CRLF & "line3" & @Tab & "line3 message" & @CRLF & "line4" & @Tab & "line4 message" And then processed it with: $sIniFile = @ScriptDir & "\temp.ini" $sMsg = IniRead($sIniFile, "Section", "certfailmsg", "") If StringLeft($sMsg, 1) <> Chr(34) Then $sMsg = Chr(34) & $sMsg EndIf If StringRight($sMsg, 1) <> Chr(34) Then $sMsg &= Chr(34) EndIf If StringInStr(StringStripWS($sMsg, 8), "&@") Then $aSplit = StringSplit($sMsg, "&") $sMsg = "" For $i = 1 To $aSplit[0] $aSplit[$i] = StringReplace($aSplit[$i], "@CRLF", @CRLF) $aSplit[$i] = StringReplace($aSplit[$i], "@TAB", @TAB) $sMsg &= $aSplit[$i] Next EndIf MsgBox(64, "Reformatted", $sMsg) Basically, you'd want to update the For...Next loop to reflect all of the specific macros you intend to use in your ini file(s). Hope this can at least get you started. Edited August 19, 2008 by Monamo - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] Link to comment Share on other sites More sharing options...
LynnS Posted August 19, 2008 Author Share Posted August 19, 2008 (edited) I'll have to do some additional testing... I thought the execute() function would work, but I haven't gotten it to yet when reading in the ini file. I'll have to try the other suggestion too. Thanks for the help. Edited August 19, 2008 by LynnS Link to comment Share on other sites More sharing options...
LynnS Posted August 19, 2008 Author Share Posted August 19, 2008 Monamo, that works great. Thanks. Link to comment Share on other sites More sharing options...
LarryDalooza Posted August 20, 2008 Share Posted August 20, 2008 quarkiness of INI funcs... add extra single or double quotes... $certfailmsg = "'text line 1' & @CRLF & 'line2' & @Tab & 'line2 message' & @CRLF & 'line3' & @Tab & 'line3 message' & @CRLF & 'line4' & @Tab & 'line4 message'" IniWrite("test.ini","main","test","'" & $certfailmsg & "'") $certfailmsg = IniRead("test.ini","main","test","") MsgBox(4096,"",$certfailmsg) $certfailmsg = Execute($certfailmsg) MsgBox(4096,"",$certfailmsg) AutoIt has helped make me wealthy 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