Arc Forumnew | comments | leaders | submitlogin
How do I Run a Program?
10 points by tiglionabbit 5890 days ago | 11 comments
I read through the arc tutorial, but didn't see any mention of how to run a program from a file.

My inclination was to search the forum, but there is no search feature! Yet another oversight.

Either of these would be quite valuable to newbies such as myself!



4 points by absz 5890 days ago | link

Another way to run a program from a file is to use arc.sh from the Anarki. This pretty much does what you said (mzscheme -m -f as.scm < myprogram.arc), but is packaged up in a script.

As for searching, the best way is probably to do a Google search for "my query site:arclanguage.org".

-----

2 points by tiglionabbit 5889 days ago | link

>As for searching, the best way is probably to do a Google search for "my query site:arclanguage.org".

True, and I'd figured that out, but neglected to mention it because I still couldn't find what I wanted.

Anyways, search is an important feature these days that every site with some dynamic content should have. You can't expect google's indexer to keep up with all your changes, and a forum with any sort of scale should encourage its users to search for duplicate topics before starting their own lest redundancies abound. I'd like to see an arc solution for searching on these posts.

-----

1 point by almkglor 5889 days ago | link

Posts are stored in flat files in blog.arc (which I think is the basis for this site anyway)

Using my file-table: http://www.arclanguage.com/item?id=3762

You can then do: http://www.arclanguage.com/item?id=3822

Speed is an issue of course ^^. Possibly we could store, say, word counts for each post.

-----

4 points by kens1 5890 days ago | link

To run Arc from a file, I think what you're looking for is the script at http://arclanguage.org/item?id=1424

-----

3 points by eds 5890 days ago | link

On Anarki, arc-exe.scm can be used to execute files containing arc code, much like with conventional scripting languages.

If test.arc contains

  (prn "hello world!")
then on the command line you could type

  > mzc --exe arc arc-exe.scm
to create an standalone arc executable and

  > arc test.arc
  hello world!
to run test.arc through the arc executable you just made.

It might also be nice to have this feature in as.scm.

-----

2 points by shlomif 5888 days ago | link

"It might also be nice to have this feature in as.scm."

I added this feature to as.scm in git-wiki/Anarki about two days ago.

-----

2 points by tiglionabbit 5890 days ago | link

What about on a mac? I was just told that this works: mzscheme -m -f as.scm < myprogram.arc

-----

3 points by sacado 5890 days ago | link

It does work, but don't do that :) At least if you're generating, for example, very big lists : everything evaluated in your program will be displayed. If your code contains something like (= foo (range 1 1000000)), you'll somewhat regret it...

But, in many cases, that will work just fine, despite the noise generated by the repl. You can also do mzscheme -m -f as.scm < myprogram.arc >/dev/null to turn the whole output off (in case you don't need it at all).

-----

2 points by absz 5890 days ago | link

Or wrap your whole program in a (do ... t) block, which is what I do. No change in semantics, and everything works fine.

-----

3 points by eds 5890 days ago | link

I believe the mzc compiler works on mac. (I'm not talking about exe's in the Windows sense here.)

Yes, that works, if you don't mind command-line hacks.

-----

2 points by cronin1024 5889 days ago | link

I haven't been using anything so complicated as any of these other responses - I basically fire up the Arc REPL and load in my program. Just call

arc> (load "foo.arc")

Where foo.arc is your program file and it should work fine.

-----