View Full Version : "hello", said the registry
dev_web
06-06-2005, 11:46 PM
My software is using an if statement to see if a certain registry key equals a certain value. It stores the registry's key value in a variable called Def_web. it checks to see if the variable "Def_web" = "E:\Program Files\Internet Explorer\iexplore.exe -nohome" including the quotation marks. But if I enter it as: if (Def_web == ""E:\Program Files\Internet Explorer\iexplore.exe" -nohome" ) it has an error because of the quotation marks.
What can I do? :huh
Please Help
I have been working on this for days to no end... :eek:
and all help is greatly appreciated :)
Dermot
06-07-2005, 12:37 AM
Hi
You need to escape the two quotation marks so that the scripting engine knows that they are part of the string.
if (Def_web == "\"E:\Program Files\Internet Explorer\iexplore.exe\" -nohome" )
Dermot
dev_web
06-07-2005, 01:12 AM
Thanks So Much!!!! :)
backslases are also requred for literal backslashes
dev_web
06-07-2005, 11:30 AM
It still is not working...even with the back slashes
Try this:
if (Def_web == "\"E:\\Program Files\\Internet Explorer\\iexplore.exe\" -nohome" ) then
Dermot
06-07-2005, 11:45 AM
What error are you getting? Maybe if you post the complete code we can help. Have you checked the Def_web variable to see what it contains?
Dialog.Message("Variable Contents", Def_web)
Dermot
Dermot
06-07-2005, 11:48 AM
Try this:
if (Def_web == "\"E:\\Program Files\\Internet Explorer\\iexplore.exe\" -nohome" ) then
I had thought of this Mark but had assumed that if the value of Def_web was read from the registry it would not have the escape backslashes. Maybe I am wrong.
Dermot
dev_web
06-07-2005, 01:39 PM
IT WORKED! :p IT'S WORKING! REJOICE! thank you so so so so so much everbody! :)
Dermot
06-07-2005, 02:21 PM
So what was the problem? How did you get it to work?
Dermot
I had thought of this Mark but had assumed that if the value of Def_web was read from the registry it would not have the escape backslashes. Maybe I am wrong.
Well you are partly right, the value read from the registry won't have the escaped backslashes, but the value you compare it against must have the backslashes escaped.
From the Help file:
The backslash and quote (\") is known as an escape sequence. An escape sequence is a special sequence of characters that gets converted or “translated” into something else by the script engine. Escape sequences allow you to include things that can’t be typed directly into a string.
So when the script engine looks at the string it doesn't see the "\\" it just sees "\". If you just pass it one "\" the script engine won't see it, it will read it as an escape sequence.
Dermot
06-07-2005, 06:09 PM
Of course, that makes sense. Don't know what I was thinking of.
Dermot
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.