RE: Current Directory
- Posted by Al Getz <Xaxo at aol.com> Feb 14, 2003
- 507 views
Derek Parnell wrote: > On Fri, 14 Feb 2003 10:07:39 +1300, Brendon Sly > <bwsly at infoscience.otago.ac.nz> wrote: > > > > >> -----Original Message----- > >> From: Derek Parnell [mailto:ddparnell at bigpond.com] > >> Sent: Thursday, 13 February 2003 10:45 p.m. > >> To: EUforum > >> Subject: Re: Current Directory > >> > > > > Hi Derek, > > > > <enormous snip> > >> > >> So how can I find out, using basic Euphoria, what is the current > >> directory > >> for ANY drive in the system? > >> > >> I know I can use DOS INT21 command and WinAPI call, but I'd rather avoid > >> that if possible. > > > > I've no idea how you'd do a generic solution that'd work on anything, > > but.. > > > > I had to do something like this a while back but since my app was being > > called from a batch file, I could 'cheat' and make use of the 'chdir' > > command. If you type 'chdir X:' (where X is the drive you're interested > > in) > > at a DOS prompt, it'll return the current directory for that drive, > > according to that DOS session. > > > > Thank you Brendon. I didn't know the CHDIR trick. Here is the code that > I > tried it out with. > ---------- > object x > integer fh > sequence dirs > -- Create a file to collect data in. > fh = open("d.d", "w") > close(fh) -- Collect the current directory for > > each drive. > for i = 'c' to 'z' do > system("chdir " & i & ": >>d.d",0) > end for > > -- Now read the directories into a sequence. > dirs = {} > fh = open("d.d", "r") > x = gets(fh) > while sequence(x) do > -- strip of the LF > x = x[1..length(x)-1] > dirs = append(dirs, x) > x = gets(fh) > end while > close(fh) > > -- Proof: Display the directories from the sequence. > for i = 1 to length(dirs) do > printf(1, "%d ==> %s\n", {i,dirs[i]}) > end for > > -------------- > This works. However when running it under EXW.EXE it looks terrible. All > > those flashing windows! I'll live with it for now though. Thanks again > for > this tip. > > -- > > cheers, > Derek Parnell > > Hello again, Pretty neat trick, if you were living back in 1998 In WinXP you get something like 24 dos windows that STAY open. In some versions you might just get flashing windows like you (Derek) had mentioned. This is another reason to avoid using the 'system' command for long term goals. It's an old way of doing things. Also, from a clean boot all i get is the following: C drive: the directory from which the program had started, change the startup dir and this changes. All other drives: No additional directory info except the drive letter like this: D:\, E:\, F:\, etc for all the drives in the system. So a natural question then is HOW do you intend to syncronize your users 'current directories' (of which there could be a possible twenty six!) to YOUR program? Since you said you DONT have to switch directories... Good luck with it, Al