I have never used SML on a Windows machine (have before on a unix machine w/ emacs).
for the life of me I cannot find the current directory when in the sml environment. If I attempt to: use "filename.sml" it raising an exception.. I cannot find out where to place my file..
btw file is written in notepad++ and merely named w/ a .sml extension.
The current working directory would be from where you start your SML interpreter. If you have a shortcut on your desktop, then I would gues you can set the CWD in the properties of the shortcut (I'm not a windows user), I would gues that it, by default, is the directory where you have SML/NJ installed.
If you start the sml interpreter from the commandline, then the CWD is the directory you were in, when you started the interpreter.
You can get the interpreter to output its CWD with the following command
OS.FileSys.getDir()
And you can also change the CWD to another working directory with OS.FileSys.chDir.
It is however easyer to just use absolute paths when trying to "load" sml files with use
Update.
Quite easy: You can do the following
- OS.FileSys.chDir("/tmp"); (* Go to the tmp directory *)
val it = () : unit
- OS.FileSys.getDir(); (* Verify that we did go to the tmp directory *)
val it = "/tmp" : string
- OS.FileSys.chDir("/home/jesper"); (* Go to my home directory *)
val it = () : unit
- OS.FileSys.getDir(); (* Verify where we did go. *)
val it = "/home/jesper" : string
On a windows file system you obviously have to escape the backspaces. The below code ought to work, but I can't test it as I don't have windows.
OS.FileSys.chDir("C:\\Users\\username\\Desktop");
In the comment you wrote, you had forgot to escape the two last backspaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With