NewtonScript:      NTK   ·   «Einstein Toolkit»   ·   Tutorial

A NewtonScript IDE built into Einstein


Einstein Toolkit

Einstein now comes with a built-in developer environment (IDE) to compile and run scripts, and build and analyse packages. To launch this feature, named Toolkit, press Shift-Apple-T / Shift-Ctrl-T.


Toolkit opens an editor window with a little NewtonScript example. You can test the Toolkit by slecting [Project - Run] from the pulldown menu, or simply by pressing Apple-R / Ctrl-R.


Within seconds, the script should compile, and a package is created and uploaded to Einstein. If everything works, Toolkit will launch your new app for testing.

To make sure that Toolkit did actually create a new app from scratch, go back into the editor, and change the text "Say Hello" into something else: "Aloha!". Press Apple-R / Ctrl-R, and Toolkit will compile, install, and run your new version of the sample app.


NewtonScript and Einstein Toolkit

Toolkit uses newt/64 to compile the user code into a preset environment to achieve quick first results. It also allows complex code by describing every detail of the Package file.

Toolkit is currently limited to a single script file.


Line by Line

  • kAppName must be set to a text string that uniquely identifies the package
  • kAppSymbol identifies the NewtonScript part of the package. The symbol is composed of vertical bars, starting with a name of the app, followed by ':', followed by the developer identifier. This allows multiple packages by the same name to exist on a device.
  • kAppLabel is the text that appears under the app icon in the Extras drawer
  • helloButton is an optional element that makes our little sample code interactive
  • newt.theForm must describe a NewtonOS View. _proto: protoFloatNGo is one of the simpler top level windows that implements almost everything needed to get something on the screen.


Internals

Toolkit generates a Package description (add p(newt.app); to the bottom of the script to see what the predefined package description does. You can provide your own Package description by writing your own (newt.app := {...};).

Toolkt generates its own local path to store a copy of the compiled packes. You can define a custom path by adding newt.pkgPath := "/some/path/hello.ns"; to the top of the script.


Decompiling an existing Package

The EInstein Toolkit can analyse and partially decompile existing .pkg files. Choose [Project - Decompile Package...] from the pulldown menu, choose a Package fiel on your file system, and Toolkit will present the data structure of the Package, ready to recompile into a new package.

Toolkit currently functions into bytecode. It will eventually recreate NewtonScript for functions.


Tutorial

Check out the introductory tutorial to NewtonScript here.