4 Replies Latest reply on Mar 14, 2012 3:25 PM by philmodjunk

# How to replace all "\" with "/" inside a variable through a script

### Title

How to replace all "\" with "/" inside a variable through a script

### Post

Hello,

I'm having a problem with getting the Substitute function to work using it to replace the "\" Backward Slashs with "/" Forward Slashs.

For Example:

C:\Users\hobbies4life\Desktop\Pictures\ASC111.jpg

to this

C:/Users/hobbies4life/Desktop/Pictures/ASC111.jpg

The script function isn't able to find an end quote to accept it as a function inside a calculation screen.

The calculation that i'm using is "imagewin:/" & Substitute( \$file ; "\" ; "/" ) and it gives me the FileMaker error "This text constant does not end with a quotation mark.". How do i go on getting the forward and back Slashs working in this function?

Thanks.

• ###### 1. Re: How to replace all "\" with "/" inside a variable through a script

the back slash is an "escape" character inside text calculations in Filemaker. \" is one way to include a double quote character inside a quoted string. "this \"example\"" would evaluate as this "example".

To use the backslash inside your expression, use two:

"imagewin:/" & Substitute( \$file ; "\\" ; "/" )

• ###### 2. Re: How to replace all "\" with "/" inside a variable through a script

I just tried revising the expresion to "imagewin:/" & Substitute( \$file ; "\\" ; "/" ) and it now sets the script function without an error but when i run it it does not switch all the "\" with "/", they still output with the old "\".

By the way, the \$file is C:\Users\hobbies4life\Desktop\Pictures which is a windows directory format and the filemaker requires the"\" slashs instead of "/" which i can't change for some reason.

Thanks.

• ###### 3. Re: How to replace all "\" with "/" inside a variable through a script

Sorry, it worked, forgot to save the edited script.