Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by Rich!

Is There An Sequence To Escape / When Using In A String For Path Vars?

example


This is ok
$BasePath = "G:"

but this gives error

$BasePath = "G:/"

it is because of the / , im asuming is being used as an escape char in Ez-Script.

is there a way to escape this?


ARC Pro

Upgrade to ARC Pro

Synthiam ARC Pro is a cool new tool that will help unleash your creativity with programming robots in just seconds!

#1  
I don't get an error when I run a script with your example in it ... $BasePath = "G:/"
.... Do you have the full script to post?
United Kingdom
#2  
Two things;

1) Shouldn't it be "G:\"?
2) "G:\" does give an error. However "G:\EZ-Builder" is OK.

What is this for? It may be that there is a better/different way of doing it.
#3  
yes sorry it is the \" that give the error

I can code around it. Being familiar with many languages but not so familiar with EZ-Script , most languages have and escape code around this for instand \!" would work in some languages or \\\" to produce single back slash
United Kingdom
#4  
If you add a trailing space it will save the variable however that will lead to problems with any commands that use the variable.

Again, what's it for? That may help find a solution. I assume some kind of file interaction but would need to know more.

If the intention is to have a path and multiple different $file variables you can always use $basepath as "G:" and have the $file variables (or text) begin with the \

i.e.

Code:

$basepath = "G:"
$filename = "\log.txt"
FileWrite($basepath+$filename, "Here is some data")
#5  
That is the work around i am currently using Rich. I was just wanting to avoid putting the \ in front of all the file names when i could have had it once in the base path decoration.


This is they script and its use.


Print("Setting up Variables")
$BasePath = "G:"
$OutputDir = $BasePath + "\DataOut"
$InputDir = $BasePath + "\DataIn"
$Weatherinput = $InputDir + "\wather.rss"
$X10SystemInput = $InputDir + "\HomeX10.rss"
$TaskListInput = $inputDir + "\Tasklist.rss"
Print("Var Setup Completed")
United Kingdom
#6  
Unless you had each file start with a preceding name or letter

Code:

$basepath = "G:\Robot-"
$filename1 = "log.txt"
$filename2 = "data.txt"


The filenames would actually be Robot-log.txt and Robot-data.txt

Not ideal but unless I've missed it a variable cannot end with a \
#7  
Good catch Rich... my script ran because it had no context... no other commands associated with it....
#8  
you could try to use \\ instead. I am not at a machine running ARC or i would test it for you.
$BasePath = "G:\\"

\ is an escape code in C#. \\ should give you \
#9  
This

$BasePath = "G:\\"

Also resulted in error.
United Kingdom
#11  
No problem. I guess the outcome is that this is a limitation in EZ-Script and an alternative method is needed.

P.S. Thanks for the credit, you're number 250:D
#12  
maybe it is messing up because you misspelled weather in wather.rss
#14  
ya the wather weather was not relevant.
The out come was just the EZ Script does not allow the \ character at the end of a string.
Trinidad/Tobago
#15  

Code:


$path="C:\Users\ "
$len=Length($path)
$path[$len]=""


this can work to remove the extra space left at the end if you really wanted the \ at the end of the first variable

have any of you guys figured out how to print a forward bracket? i.e. "(" the backslash in front works for printing "\"" but not the (