escaping backslash for javascript

Got a problem you cannot solve? Try here.
Post Reply
smeyn
Posts: 12
Joined: Wed Jun 15, 2011 3:41 pm

escaping backslash for javascript

Post 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
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: escaping backslash for javascript

Post 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!
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
smeyn
Posts: 12
Joined: Wed Jun 15, 2011 3:41 pm

Re: escaping backslash for javascript

Post by smeyn »

Thanks

that worked great.
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: escaping backslash for javascript

Post by giaviv »

:)
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Post Reply