application.writeFile() path_question

Questions, tips and tricks and techniques for scripting in Servoy

application.writeFile() path_question

Postby Ron » Sun Feb 08, 2004 1:11 pm

I have been fighting with this command and found out that if I don't use a double backward slash in my path my picture icon does'nt show up (on c:\).
Funny thing is that if I use a single slash it seems somehow to be there, because it can be used by Marcel's great splash tool.
I realize that this is Windows_CMD stuff but am just curious..


var fileName = 'c:\\out.png'
application.writeFile(fileName,picture_1);
Ron
 
Posts: 315
Joined: Fri May 23, 2003 12:30 am
Location: Netherlands

Postby jcompagner » Sun Feb 08, 2004 1:50 pm

always use / instead of \ or \\
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby pbakker » Sun Feb 08, 2004 2:38 pm

The \ is part of the Java Regular Expression "Language" (see Servoy Advanced Programming Guide).

So, a \ in a string will be interpreted as a sort of command for example \n gives you a "return" in a string and \t a tab.

Got me baffled for a couple of hours as well... :oops:
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby IT2Be » Sun Feb 08, 2004 3:19 pm

Just to be a little more precise (not too much since this is not really my peace of cake)...

Not only is it part of the java regex but it is part of regexes in general...

The "\" is a special character that is used to start a match. '\w' matches all word character, '\d' matches all integers etc...

If you would use '\n' in this respect the regex function won't find a match because there is no such thing as '\n'. But if you want to search for '\n' you would do that like '\\n'.

Outside a regex the '\' is also used to start a special character in this case '\n' will find a match and let's say '\newdirectory' also but it wil be <linefeed>ewdirectory. You then again would have to use '\\newdirectory' to get the requested output...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany


Return to Methods

Who is online

Users browsing this forum: No registered users and 32 guests

cron