Arc Forumnew | comments | leaders | submitlogin
Running arc scripts directly? (Windows)
4 points by tokipin 5434 days ago | 2 comments
Is there a straightforward way to run an arbitrary Arc script directly on Windows? Something like:

  mzscheme -f "ac.scm" -<some letter> "myscript.arc"

?


2 points by shader 5433 days ago | link

Here's what I would do:

Modify as.scm, or make a new scheme file that contains this code, slightly modified from Anarki's as.scm:

  ;load arc files
  (require mzscheme)
  (require "ac.scm")
  (require "brackets.scm")
  (use-bracket-readtable)

  ;compile arc.arc
  (if (and (file-exists? "arc.arc.scm") (< (file-or-directory-modify-seconds "arc.arc")
                                           (file-or-directory-modify-seconds "arc.arc.scm")))
      (load "arc.arc.scm")
      (begin
        (display "Compiling arc.arc...\n")
        (flush-output (current-output-port))
        (acompile "arc.arc")))
  (aload "libs.arc")
  
  ;either load a file or run the prompt
  (if (> (vector-length argv) 0)
      (begin
        (call-with-input-file
  	  (vector-ref argv 0)
  	aload1)
        (exit))
      (tl))
Then, if you're using powershell, you can create a function to save you some typing:

  function arc { mzscheme -fmv as.scm $args }
You may want to put this in you powershell profile:

  notepad $profile
Otherwise the function will only last as long as your powershell session.

When you're ready to use it, type either "arc" to just get the repl, or "arc file.arc" to execute the file. It's that easy!

-----

2 points by pg 5434 days ago | link

Create a Scheme file foo.scm that contains

    (load "as.scm") ; or whatever
    (aload "bar.arc")
and in bar.arc put whatever additional Arc code you want to define, then a call to it:

    (def myscript () ... )

    (myscript)
Warning: some Arc operators in the standard distribution don't work on Windows.

-----