Imbuter2000 Posted June 21, 2011 Share Posted June 21, 2011 I need to display a no halting msgbox with a variable for body. I'm using this code, that works most of the times: Run (@AutoItExe & ' /AutoItExecuteLine "MsgBox(0,''titletext'',''' & $bodyvariable & ''')"') The problems happen when $bodyvariable contains for example the characters " or ' (not sure what of the two, maybe both), for reasons that you can logically understand. The question is: how can I modify the code to overcome this problem? Link to comment Share on other sites More sharing options...
Tvern Posted June 21, 2011 Share Posted June 21, 2011 You can use StringReplace to change all quotes in escaped quotes like this: $bodyvariable = """This"" is a 'Test'" ConsoleWrite($bodyvariable & @CRLF) ;Text to be displayed $bodyvariable = StringReplace($bodyvariable,"'","''") ;escaple single quotes (prevents an error ) $bodyvariable = StringReplace($bodyvariable,'"','""') ;escape double quotes (prevents the quotes dissappearing) Run (@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''titletext'', ''' & $bodyvariable & ''')"') There might be a nicer way to do it though. Link to comment Share on other sites More sharing options...
Imbuter2000 Posted June 21, 2011 Author Share Posted June 21, 2011 You can use StringReplace to change all quotes in escaped quotes like this: $bodyvariable = """This"" is a 'Test'" ConsoleWrite($bodyvariable & @CRLF) ;Text to be displayed $bodyvariable = StringReplace($bodyvariable,"'","''") ;escaple single quotes (prevents an error ) $bodyvariable = StringReplace($bodyvariable,'"','""') ;escape double quotes (prevents the quotes dissappearing) Run (@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''titletext'', ''' & $bodyvariable & ''')"') There might be a nicer way to do it though. Right, good idea! Thanks! I will try it tomorrow in office... Link to comment Share on other sites More sharing options...
Imbuter2000 Posted June 23, 2011 Author Share Posted June 23, 2011 Tried and it works like a charm! thank you again! 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