1. Doubling \\ in file names
- Posted by Ray Tomes <rtomes at ihug.co.nz> Jun 18, 2003
- 387 views
Hi All I think that I am having trouble because of needing to double back slashes in a file name for various GUI commands such as extractIcon. If I have a file name with single back slashes then is there some function that will make them all double or am I doing something daft? What is the rule on what things treat "\" in text in this way (i.e. as a special escape character)? Is it always the case in all text strings, or do some just have normal single "\" in file names? I am using create( PictureButton, ... and want to put an extractIcon(f) command directly in as a parameter for the picture icon and it seems the reason for failure is that f has single back slashes. I am going to have a working program soon! Ray
2. Re: Doubling \\ in file names
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 18, 2003
- 377 views
On Wed, 18 Jun 2003 17:58:09 +1200 (06/18/03 15:58:09) , Ray Tomes <rtomes at ihug.co.nz> wrote: > > > Hi All > > I think that I am having trouble because of needing to double back > slashes in a file name for various GUI commands such as extractIcon. If I > have a file name with single back slashes then is there some function > that will make them all double or am I doing something daft? > > What is the rule on what things treat "\" in text in this way (i.e. as a > special escape character)? Is it always the case in all text strings, or > do some just have normal single "\" in file names? > > I am using create( PictureButton, ... and want to put an extractIcon(f) > command directly in as a parameter for the picture icon and it seems the > reason for failure is that f has single back slashes. > Hi Ray, this has nothing to do with file names, that's just a red-herring. Inside string literals, the backslash character '\' has a special meaning. Certain two-character combinations are used to represent special characters. They are (from memory)... \t The TAB character \n The new-line character \\ The backslash character This means that if you need to specify a backslash in a string you need to write it as a double \\. Thus "C:\\Program Files\\My Application\\abc.dat" is converted by Euphoria to C:\Program Files\My Application\abc.dat The other combinations are useful for embedding new-lines and TABs inside strings. Hope this helps. -- cheers, Derek Parnell
3. Re: Doubling \\ in file names
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Jun 18, 2003
- 393 views
----- Original Message ----- From: "Ray Tomes" <rtomes at ihug.co.nz> To: "EUforum" <EUforum at topica.com> Subject: Doubling \\ in file names > > > Hi All > > I think that I am having trouble because of needing to double back > slashes in a file name for various GUI commands such as extractIcon. If > I have a file name with single back slashes then is there some function > that will make them all double or am I doing something daft? Try the function below, it's simple, no tests for if you happened to already have doubled backslashes. > > What is the rule on what things treat "\" in text in this way (i.e. as a > special escape character)? Is it always the case in all text strings, > or do some just have normal single "\" in file names? I think it's the same in all sequences, although it *may* be possible (I'm not sure) that if you get a filename from some function like current_dir, and then use that in some other function where a filename is expected, you might not have to worry about double slashes? I forget. Dan Moyer > > I am using create( PictureButton, ... and want to put an extractIcon(f) > command directly in as a parameter for the picture icon and it seems the > reason for failure is that f has single back slashes. > > I am going to have a working program soon! > > Ray > > -- function to make double backslashes out of singles: function DblUpBkSlshs (sequence in) sequence temp temp = {} for n = 1 to length(in) do temp &= in[n] if equal(in[n], '\\') then temp &= "\\" end if end for return temp end function -------------------------- -- test it: include file.e sequence a a = current_dir() puts(1, a & "\n") a = DblUpBkSlshs(a) puts(1, a & "\n") a = "abc\\def\\ghijk\\" puts(1, a & "\n") a = DblUpBkSlshs(a) puts(1, a) > > > TOPICA - Start your own email discussion group. FREE! > >
4. Re: Doubling \\ in file names
- Posted by aku saya <akusaya at gmx.net> Jun 18, 2003
- 390 views
You need to type double backslashes ONLY in source files (*.ex, *.exw), not in anything outside it. For example if you make code like this puts(1, "Enter a file name: ") filename = gets(0) -- prompt a file name -- then user types: c:\abc\def.ext fn = open(filename, "r") You don't need to convert the contents of variable "filename" to double backslashes for the open() function. YOu need double backslashes ONLY in source files. Not the others. I think the extractIcon() is not compatible with picturebutton, not because of the backslash thing. ______________________________________________ R> Hi All R> I think that I am having trouble because of needing to double back R> slashes in a file name for various GUI commands such as extractIcon. If R> I have a file name with single back slashes then is there some function R> that will make them all double or am I doing something daft? R> What is the rule on what things treat "\" in text in this way (i.e. as a R> special escape character)? Is it always the case in all text strings, R> or do some just have normal single "\" in file names? R> I am using create( PictureButton, ... and want to put an extractIcon(f) R> command directly in as a parameter for the picture icon and it seems the R> reason for failure is that f has single back slashes. R> I am going to have a working program soon! R> Ray
5. Re: Doubling \\ in file names
- Posted by Ray Tomes <rtomes at ihug.co.nz> Jun 18, 2003
- 394 views
aku saya wrote: > You need to type double backslashes ONLY in source files (*.ex, *.exw), > not in anything outside it. Hi Aku and others (hides red face) Yes, I worked this out but couldn't get back here quick enough to pull the string on my message back! Must have been programming too many hours lately! Ray
6. Re: Doubling \\ in file names
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Jun 18, 2003
- 380 views
Al, That's a *very* clear & succinct explanation! Dan Moyer ----- Original Message ----- From: "Al Getz" <Xaxo at aol.com> To: "EUforum" <EUforum at topica.com> Subject: RE: Doubling \\ in file names > > > Hello again, > > The only time you dont use double backslashes is when > you type an 'include' statement that includes a path > directory name or whatever (in a source file). > > Ex: > > include c:\mydir\files\file.e > > Whenever they are inclosed in double quotes you have to: > > atom fn > fn=open("C:\\dir\\file.txt","r") > > Take care for now, > Al > > > > TOPICA - Start your own email discussion group. FREE! >
7. Re: Doubling \\ in file names
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jun 19, 2003
- 412 views
I just always remember there are six. Straight from the Eu docs: Special characters may be entered using a back-slash:=20 \n newline \r carriage return \t tab \\ backslash \" double quote \' single quote Pete (Struggling to get through some 100+ posts (possibly not all from this list) at the mo!)