Works for me, eeg in the form of
Code:
SaveDir=curdir()
CD ..
*
CD (SaveDir)
also variants instead of CD .. like CD \Windows and others work. I was unable to make this fail.
Make sure the "some code" section does neither change the SaveDir variable value nor changes to a different drive, eg via calling some class, method, function which itself uses some other code and that changes drive.
That's the disadvantage of the curdir() result, not having the drive letter in it. Instead of curdir() using fullpath(curdir()) or Sys(5)+Sys(2003) would also work independent of a drive change.
For analysis check out Sys(5)+Sys(2003) and the SaveDir value before doing CD (SaveDir), check if DIRECTORY(Sys(5)+SaveDir) exists.
I always am an evangelist for absolute paths for such scenarios, not absolute in the sense of being hardcoded, unchangable, unconfigurable, but the absolute path determined at runtime from a current or relative path. Fullpath() is a function to remember for that matter to merge an absolute and relative path to the resulting fullpath, determined that at runtime, SYS(2014) is another function to keep in mind. A relative path expanded to a full path at runtime will undoubtedly work, unless "some code" deletes a folder, but regardless to where other code changes the current dir. The drive letter is an info missing from curdir(), and that's therefore insufficient, no matter how often, long or loud you swear no other code changes drive.
Also I see a tendency here, that is really making me sad. Both users and developers argue with "this will never happen". You always have to expect the unexpected. In development you normally are not alone, even as a single freelance developer you make use of libraries written by other developers, you work in a multiprocessing operating system etc. The argument of "this has worked in system X for N years, never failed" also is a very moot point.
Changing OS and something stops working, I can understand you first suspect an OS bug or behavior change, but that's not the case here. Double check the circumstances of an error. SAVE TO some.mem ALL LIKE * will make your error handler save all variables, if you also store sys(5)+Sys(2003) you can see why CD (SaveDir) errors. And undoubtedly, if that error comes up, either SaveDir has changed, the current drive has change, the folder was deleted or renamed or the folder is hidden or granted privileges have changed. There are very many reasons and they all don't only depend on your code, other programs can do things in parallel, for example. Get real.
Bye, Olaf.