These articles are excerpted from various 1996 issues of PDA Developers magazine. Copyright (C) 1996 by Creative Digital, Inc. All Rights Reserved.

For a sample copy of PDA Developers, contact Creative Digital at info© cdpubs.com or visit their web site at http://www.cdpubs.com.

NS BASIC CORNER - RELEASE 2.0
John Schettino
GTE Laboratories, Inc.
js12© gte.com



Copyright(C) 1996 by Creative Digital Publishing Inc. All rights reserved.

NS BASIC has been undergoing a steady transformation from a hobby language to a true Newton development environment. It was never intended to replace the Newton Tool Kit (NTK), but rather to offer an alternative for those not interested in investing the time to learn yet another language. For the weekend programmer, or the Newton owner who wants to make his or her Newton do just one custom thing, NS BASIC provides a simple environment. With the release of Newton 2.0, a whole new world of possibilities has opened up. Not surprisingly, NS BASIC has a new release just for Newton 2.0. This column is devoted to describing these new features. Some of this is new territory, since I haven't talked about Widgets and other advanced features before.

IT'S ALWAYS FASTER
Every release of NS BASIC has provided some speed improvement. While it is still not nearly as fast as a NewtonScript application, version 3.0 does provide a major speed boost. Some of that boost is provided by Newton 2.0, which is generally faster in all operations. The rest is provided by a major internal overhaul of NS BASIC. That overhaul was needed anyway, as you'll see later.

Some other interesting things happened:

Let's take a look at each of these changes.

NEW WIDGETS
A widget is just NS BASIC's way of saying NewtonScript proto, for those of you familiar with the NTK. For the rest of us, a widget is a special window that you create in your program that displays one of the Newton user interface elements. Examples are pickers, buttons, pop-ups, clocks, calendars, gauges, and text-entry areas that you see in the NotePad, Dates, and elsewhere in the Newton.

You can create NS BASIC programs that use these same elements. The best part is that the widgets do most of the work for you. Buttons call (by using either GOTO or GOSUB) a line number when they are tapped. For text-entry widgets, you can extract the text; for pick lists, you can retrieve the user's selection. You can set and clear check boxes, and find out if they are checked. All this is possible from within an NS BASIC program. For those you just getting started, I'll be writing a number of columns this year on widget programming.

In NS BASIC version 2.x, you were limited to those interface elements found in the Newton prior to Newton 2.0. NS BASIC 3.0 adds several following widgets.

Application
The application widget forms the basic backdrop for a program.

Date Picker
This is used to select a date.

Digital Clock
This is used to enter a time value using tapping, and to display a time.

Number Picker
This is used to enter a numeric value using tapping.

Picture button
This is used for iconic buttons. There are also additional functions for manipulating the bit maps used by picture buttons.

Folder Tabs
These are used to select alphabetic values. Two orientations are provided.

Newton 2.0-Compatible Clock
This is for entering time and displaying time.

FUNCTIONS AS STATEMENTS
The rules for a statement line have been adjusted so you can now call a function, without assigning its value to a variable. In other words, you can now use functions like SETVALUE() and ADDARRAYSLOT() by themselves as statements. This is a minor change, but it can improve the speed of programs that use a lot of widgets.

STAND-ALONE PACKAGES
A new command has been added that lets you create stand-alone packages. The MAKEPACKAGE command reads a saved program and creates a package in the Extras drawer with that package's name. You can then run that program simply by tapping its icon in the Extras drawer. You can turn any kind of program into an application, but it makes most sense to create packages from programs that use widgets.

You can use the SETICON statement to set the icon for a package created by NS BASIC. The statement can be included in the program itself, so the icon can also change when it is run.

You can use the NOTIFY() function to provide Newton-style notification messages within your programs:

ENVIRONMENTAL UPDATES
Improvements have been made to the programming environment as well. You can now edit a line using the EDIT command if you know the line number to edit. The edit slip for program statements is much better at recognizing handwritten NS BASIC code too.

Cut and paste is supported now in NS BASIC. You can cut portions of a program to the Newton's clipboard and paste them into the NotePad. You can bring program text into NS BASIC the same way.

NEXT TIME
In my next column I use some of these new features in the first version of a Newton-like NS BASIC program. I talk about using the WINDOW command to create windows and widgets, and how to do event-based programming in NS BASIC. Since you can now create packages from NS BASIC programs, I also discuss some of the issues this raises.


Return to the NS Basic Corner
Return to the product information main page