Re: Doubling \\ in file names

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- 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!  smile  smile  smile
>
> 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!
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu