1. GETTING FULL PATHS
- Posted by David Cuny <HW1.DCUNY at HW1.CAHWNET.GOV> Jan 29, 1997
- 1095 views
is there a simple way to convert a string to a full path in Euphoria? for example, the user could type in: "..\foo\bar" i know that you can use dir() to determine (1) that the path is real, and (2) that the path is either a directory or a file. but i need to convert the string to a full path, such as: "c:\stuff\bletch\foo\bar\" i could parse the thing by hand, but it would be easier if there was a function that would expand it automatically. any suggestions? thanks. -- david cuny
2. Re: GETTING FULL PATHS
- Posted by David Gay <moggie at INTERLOG.COM> Jan 29, 1997
- 1100 views
- Last edited Jan 30, 1997
> i know that you can use dir() to determine (1) that the path is real, > and (2) that the path is either a directory or a file. but i need to > convert the string to a full path, such as: > > "c:\stuff\bletch\foo\bar\" > Well, it's really not too hard to do. First, you use the find() command to locate each '\' and turn them into "\\". However, you will have to enlarge the string entered by one every time. I have some source at home that already does this in the first release of "A Beginner's Guide To Euphoria"...if you want it, I will send it to you. Thanks David Gay http://www.interlog.com/~moggie/euphoria.htm
3. Re: GETTING FULL PATHS
- Posted by Jacques Deschenes <desja at QUEBECTEL.COM> Jan 29, 1997
- 1120 views
- Last edited Jan 30, 1997
At 15:47 29-01-97 PST, you wrote: >---------------------- Information from the mail header ----------------------- >Sender: Euphoria Programming for MS-DOS <EUPHORIA at >MIAMIU.ACS.MUOHIO.EDU> >Poster: David Cuny <HW1.DCUNY at HW1.CAHWNET.GOV> >Subject: GETTING FULL PATHS >------------------------------------------------------------------------------- > >is there a simple way to convert a string to a full path in Euphoria? >for example, the user could type in: > > "..\foo\bar" > >i know that you can use dir() to determine (1) that the path is real, >and (2) that the path is either a directory or a file. but i need to >convert the string to a full path, such as: > > "c:\stuff\bletch\foo\bar\" > >i could parse the thing by hand, but it would be easier if there was >a function that would expand it automatically. any suggestions? > >thanks. > >-- david cuny > Hi! David, If I understood your question, this could be an answer. include file.e function FindLastChar(integer char, sequence target) -- search target for a character starting search from end of target integer l, pos sequence inverse inverse="" l = length(target) for i = 0 to l-1 do inverse = inverse & target[l-i] end for pos = find(char,inverse) if not pos then return 0 else return l - pos end if end function --FindLastChar() function ExpandPath(sequence DottedPath) -- expand dotted path to full path -- limitation: only good for one level of dotting.(i.e. parent dir) integer pos sequence Current, Parent pos = match("..",DottedPath) if pos != 1 then return DottedPath end if Current = current_dir() Parent = Current[1..FindLastChar('\\',Current)] return Parent & DottedPath[3..length(DottedPath)] end function --ExpandPath() constant DotDir="..\\foo\\bar" puts(1,ExpandPath(DotDir)) Jacques Deschenes Baie-Comeau, Quebec Canada desja at quebectel.com
4. Re: GETTING FULL PATHS
- Posted by David Cuny <HW1.DCUNY at HW1.CAHWNET.GOV> Jan 30, 1997
- 1109 views
*** Reply to note of 01/29/97 19:42 thanks jacques & david. i was hoping there was a function in Euphoria or a DOS call that i could call, rather than write a parsing routine, but parsing looks like the way i've got to go. it turns out that i have to parse the thing into nodes, in case they type something like "..\...\foo", and i have to use dir() to determine if the last node is a file or a directory node... argh. thanks again. -- david cuny