Command Line Arguments in NewtonScript and NEWT/0 ¬


Still being a daily Newton user as well as a developer, I’ve always wanted to learn NewtonScript. I’ve got a PowerMac 9500 that’s been configured for Newton OS development for quite some time and I’ve got a couple projects in mind, but I just never seem to get around it.

I’ve also had NEWT/0, an open source, cross-platform NewtonScript interpreter, installed for a while. Since it can run NewtonScript scripts from the command line like any other interpreter, I decided I’d like to know if it was possible to get the command line arguments from NewtonScript so I could eventually write some local scripts to get myself familiar with the syntax & functions (therefore less of a learning curve when I finally get around to writing some actual Newton packages). After a point in the right direction from Matthias Melcher and a lot of digging through the NEWT/0 source code, I finally figured out how to do so.

Here’s a quick NewtonScript script that can be run through NEWT/0 to print out the command line arguments you pass to it:

#!/usr/bin/env newt

Print("'_ARGV_ exists? ");
if GlobalVarExists('_ARGV_) then Print("Yes.\n") else Print("No.\n");

foreach slot, value in GetGlobalVar('_ARGV_) do Print(slot && ":"
&& value && "\n");

I doubt there are many, if any, out there that are interested in doing this, but—who knows?—maybe somebody else will start scripting in NewtonScript too. (Expect to see some more NewtonScript-related news around here in the future.)

  Textile help