Re: [q-lang-users] problem with command line parsing
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2008-01-04 19:00:40
|
Hi David, and welcome to the list! As Tim already pointed out, the interpreter only evaluates expressions, so you need to put the equations into a file and run that with the interpreter. The shebang magic and main function in Tim's example are only needed, however, if you want to run your script as a standalone program. Otherwise, just use your favourite text editor and put the line sqr X = X*X; into a file, say, sqr.q. Now you can run the program from the command line like so: q sqr.q Or, if you already started the interpreter, you can run the script from the interpreter's prompt: ==> run sqr.q In any case, the equations are now ready to be used, so you can now type: ==> sqr 2 I should really put this into the FAQ, this has been asked a couple of times already. :) However, you can find some information about using the interpreter on the corresponding wiki page: http://q-lang.wiki.sourceforge.net/Using+the+Interpreter There you can also read about how to run the interpreter in Emacs, which is maybe the most convenient way to run Q scripts interactively if you know Emacs. I'm afraid that this information is a bit Linux-centric right now, but the described setup should work equally well on OSX and other Unix systems if you have Emacs installed. BTW, in case you didn't know this, thanks to the work of Ryan Schmidt a MacPorts port of Q to OSX exists which greatly reduces the hassle of compiling Q there. You can find more information about this here: http://q-lang.sourceforge.net/download.html#Ports HTH, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |