Skip to content

Instantly share code, notes, and snippets.

@rocketnia
Last active September 23, 2015 15:37
Show Gist options
  • Save rocketnia/576688 to your computer and use it in GitHub Desktop.
Save rocketnia/576688 to your computer and use it in GitHub Desktop.
@echo off
rem 2010, 2013 Ross Angle. Released under the CC0 license.
rem Lines beginning with "rem", like this one, are comments.
rem The "@echo off" line above stops the following commands,
rem including these comments, from being displayed to the terminal
rem window. For a more transparent view of what this batch file is
rem doing, you can take out that line.
rem The @ at the beginning of "@echo off" causes that command to be
rem invisible too.
rem Now we'll keep track of ".", which is the current working
rem directory, and return to that directory later on using "popd".
rem This is mostly useful if we're running this batch file as part of
rem a longer terminal session, so that when we exit Arc and return to
rem the command prompt we're in the same directory we left.
pushd .
rem Now we change the working directory to the Arc directory, so that
rem when we're using Arc, our (load "...") statements will find files
rem from that directory. More importantly, Arc itself also uses some
rem (load "...") statements internally, which won't work if the
rem working directory is wrong.
rem This is the path to the Arc directory on my system. You'll
rem probably need to change this. If your path has any spaces in it
rem (like "C:\Documents and Settings\Your Name\Desktop\arc3.1"),
rem you'll need to put quotes around the path.
rem If the directory you're trying to refer to here is the same as
rem the directory this .bat file lives in, you can use this command
rem instead:
rem cd "%~dp0"
cd C:\proj\tools\languages\arc\arc3.1
rem Now for the command you've been waiting for. :-p This runs Racket
rem from a specific place on my system--in fact, the place Racket
rem installs itself by default on Windows. The "Racket" utility is
rem the same as what previous versions of Racket (PLT Scheme) called
rem "MzScheme", so keep that in mind if you need to change this path
rem to accommodate your installation.
rem Since we're running Racket from a specific file path, it doesn't
rem matter whether it's actually possible to say "Racket -f as.scm".
rem That's basically just a shortcut syntax that searches the
rem directories listed in the PATH environment variable for any
rem executable named "Racket". As for changing that variable... well,
rem I'll just assume you don't care for now, 'cause that saves me the
rem effort of explaining how not to mess up the PATH. :-p
rem The -f option here means that we're loading a file. I'm using
rem Racket 5.0.1, and if I were to add the -m ("main") option, as
rem seen on http://www.arclanguage.org/install, it would cause an
rem error because Arc doesn't actually define a "main" function.
"C:\Program Files\Racket\Racket" -f as.scm
rem Here's the command for an MzScheme 352 setup I have on my system.
rem I'm using the -m option here, as recommended, because a "Welcome
rem to MzScheme" message is displayed if I leave it out.
rem "C:\proj\tools\languages\racket\plt-352\MzScheme" -m -f as.scm
rem The "pause" command displays a "press any key" message. If Racket
rem exits with an error, this command keeps the batch script running
rem long enough for you to read the error message. (Double-clicking a
rem batch file opens a window that closes once the script is
rem complete.)
pause
rem Finally, as planned, we restore the working directory we started
rem with.
popd
@rocketnia
Copy link
Author

Thanks! I've made a note of that in the code.

Personally, I don't put these .bat files in my Arc directories, but the use of %~dp0 could easily come in handy for someone else, and I'll keep it in mind the next time I make files like these.

I've also mentioned the CC0 license so it's easier to include this file in other projects like you have. I consider it silly to assign attribution to this code since it's so simple and common, but the comments are substantial, so I figure I should license this explicitly after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment