Page 1 of 1

escaping backslash for javascript

Posted: Wed Jun 15, 2011 3:54 pm
by smeyn
I need to create a javascript file with the value of $TARGETDIR$ included. Unfortunately in Javascript I need to double the backslashes present in the path of $TARGETDIR$.
e.g. $TARGETDIR$ = C:\Program Files\Test has to become in the Javascript C:\\Program Files\\Test

Is there a way of doing this easily?

Many thanks

Re: escaping backslash for javascript

Posted: Wed Jun 15, 2011 3:59 pm
by giaviv
There definitely is - assign the value of $TARGETDIR$ to a temporary variable and use the Replace command on that variable to replace \ with \\ like so:

Set Variable TMP to $TARGETDIR$
Replace \ with \\ in variable TMP

Or paste this in InstallAware:

~InstallAware Clipboard Data~
~Replace String~
~{B63AD60B-788E-43D3-9557-F4364EAFB07C}~
~TMP~
~\~
~\\~
~TRUE~
~TRUE~
~Set Variable~
~{37BEDFD8-27D0-4177-9741-7F12AA0C3E0B}~
~TMP$MYAH$MYAH$FALSE~
~$TARGETDIR$~


Enjoy!

Re: escaping backslash for javascript

Posted: Wed Jun 15, 2011 7:06 pm
by smeyn
Thanks

that worked great.

Re: escaping backslash for javascript

Posted: Wed Jun 15, 2011 7:34 pm
by giaviv
:)