7

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.

DJPlayer
  • 3,244
  • 2
  • 33
  • 40

1 Answers1

13

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.

Jesper.Reenberg
  • 5,944
  • 23
  • 31
  • say I wanted to change the directory from "C:\\Windows\\system.32" to "C:\\Users\\username\Desktop\" . What would the command be? If I take it line by line.. as OS.FileSys.chDir("..") it works.. but I can only get it to change directory levels by level, line by line. – DJPlayer Mar 18 '11 at 13:25
  • What do you mean by permanent? Please describe what your expected result should be? Perhaps this is best solved by starting a new question – Jesper.Reenberg Oct 08 '14 at 16:14