Using substituteString to use a path as string

Using substituteString to use a path as string

alexandre_bisewski
Enthusiast Enthusiast
615 Views
2 Replies
Message 1 of 3

Using substituteString to use a path as string

alexandre_bisewski
Enthusiast
Enthusiast

Hello!

 

I have a string called _str that I am using with:  execute _str.

 

In this string I have a print command where I need to print one folder path:

_str  = "\tprint \"the path is"+_mypath +"\"\n"

execute _str

 

Ok, I need to use that scapes \t and \n but not in path...So ok, we I am using(substituteString _path "\\" "\\\\") to replace in path all the "\" to "\\".

 

Works fine but to use this path again to open a file for example I need to revert the process and back to "\" using (substituteString _path "\\\\" "\\") 

 

This is working for me but sounds to strange to do it. Are there a better way to do it?

 

Thank you!

0 Likes
Accepted solutions (1)
616 Views
2 Replies
Replies (2)
Message 2 of 3

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

turn all backslashes into forward slashes in the path:

my_path = @"c:\temp\test.txt"
substitutestring my_path "\\" "/"

 

Message 3 of 3

alexandre_bisewski
Enthusiast
Enthusiast

Works perfectly...Is to easy for Denis. I need to be more hard...

0 Likes