NS BASIC FAQ





NS BASIC FAQ: Dec 19, 1996
NS BASIC Corporation
Phone: 416 264-5999  Fax: 416 264-5888
Internet: info© nsbasic.com
WWW: http://www.nsbasic.com

1. What is Basic?
2. What kind of Basic is this?
3. What do I need to program in NS BASIC?
4. What data types are supported?
5. Can I create files?
6. Can I accept handwritten input and drawings?
7. Is it a substitute for NTK?
8. Which Newtons does it run on?
9. How much memory does it use?
10. Can I program windows and buttons?
11. Can I access the serial port?
12. Can I access other applications with NS BASIC?
13. Does it come with a manual?
14. Where can I get the book?
15. Can I make normal Newton packages in the Extras drawer with it?
16. Can I distribute applications I write to other users?
17. Can I program it using a regular keyboard?
18. How fast is it?
19. Can I control my VCR with it?
20. What about support?
21. Will there be future releases?
22. I just bought NS BASIC. How do I know I have the latest rev?
23. What about NS BASIC and the Internet?

1. What is Basic?
Basic is probably the world's most widely used computer programming langauge. Versions of it exist for virtually every make and model of computer. Simple programming constructs such as FOR...NEXT and GOSUB provide an easy, quickly-learned syntax. Basic is usually implemented an interactive language, allowing programmers to test their work as they go, and to easily modify and debug their code. It has resisted all attempts at standardization: there are numerous dialects in existence. It is widely used for business, educational and scientific applications.

2. What kind of Basic is this?
NS BASIC is implemented as a fully interactive implementation of Basic. As well as providing the full instruction set, it has extensions to take advantage of the Newton environment. If you don't find the specific version of a function or statement you may have used in another Basic, there is almost certainly an equivalent in NS BASIC. In addition, functions can be programmed in NewtonScript and called by NS BASIC programs.

3. What do I need to program in NS BASIC?
NSB can be programmed directly on the Newton without requiring a host system. Popup menus provide quick access to many commands and statements; other code can be input using the on screen keyboard or via handwritten input. Programs can also be downloaded via a serial port, or edited from a PC or Mac using a terminal emulator tied in through the serial port. The Newton keyboard is also supported.

4. What data types are supported?
Integers, reals, booleans, floating point, strings, arrays and frames. A frame is a list of field names, each with a value that can be any of the data types (including another frame). Veru handy and powerful!

5. Can I create files?
Yes. For example, the statement CREATE CH,"MYFILE",NAME will create a file named MYFILE, indexed by NAME and open on channel CH.

6. Can I accept handwritten input and drawings?
Yes. The statement HWINPUT X will put up an edit box. The text the user enters will be returned in X. Options on this statement include putting up a prompt, a popup list of potential input values and a toggle to set recognition to prefer letters or numbers. There are various other window objects that make inputting of text and drawings easy.

7. Is it a substitute for NTK?
Not for everyone. The NTK (Newton Tool Kit) is still the development environment of choice for serious commercial application development. The licence fee is for NTK is $299 and it requires a powerful Macintosh to run. Even an experienced and skilled programmer will need a few months to become fully productive with NTK. NS BASIC is well suited for the casual programmer who needs to develop less complex applications. 

Time spend programming NS BASIC is not wasted if you are planning perhaps to use NTK later. It provides a gentle introduction to some of the advanced concepts contained in the Newton. A number of serious NTK developers even use NS BASIC to test out their ideas before getting to work on NTK.

NS BASIC can also act a useful prototyping tool. Applications can be quickly put together and shown to users for feedback. Once the design is finalized, NTK can be used.

Finally, NS BASIC can aid NTK users as a research/hacking tool. Since it is interactive and Newton-based, it is easy to use as a tool to peek into locations within the Newton and to test new functions.

8. Which Newtons does it run on?
NS BASIC runs on all Newton devices produced to date, including the original and upgraded MessagePad, the MP 100, the MP 110, MP 120, MP 130, MP 2000 and eMate 300. (both 1.x and 2.x operating systems. It will also run on the Sharp Expertpad and the Motorola Macro. NS BASIC Rev 2.52 can be used on all Newtons; Rev 3.x will only run with Newton 2.0 units. Both versions of NS BASIC are supplied on the NS BASIC release diskette.

9. How much memory does it use?
NS BASIC itself uses about 128k of memory. A memory card is recommended for uses with the original Newton Message pad, the upgraded Message Pad or the Message Pad 100. Programs do not take up any additional internal memory while running, other than space used for user variables. The code itself remains resident on the card (except for the current code block) and does not significantly impact internal memory. Programs can therefore be of almost any size, subject to space available on the card. The CHAIN statement can be used to segment programs.

NS BASIC programs themselves are very compact: a hundred line program uses only about 10K of storage.

Can I access system information?
Yes. For example, the following statement outputs the user's name from the internal settings.
PRINT getglobals().userconfiguration.name
Furthermore, it is possible to access the system information, such as the Notepad. Here's a short program that creates a note:

10 notes:=getroot().paperroll
20 u.notes:makeTextNote("This note was created by NS BASIC",true)


10. Can I program windows and buttons?
Yes. Windows are passive boxes that hold text. You can define the bounds, the boundary, the pattern for the boundary, the fill pattern and the text font, style and size. Multiple windows can be displayed simultaneously.
Buttons are implemented as windows that execute a GOTO LineNumber when they are tapped. With this, event driven programs can be created. 

What kind of window objects (widgets) are available for programming?
Most of the types of objects you see in other Newton applications are available, plus some custom ones only found in NS BASIC. You get: app, azTabs, azVertTabs, checkbox, closeBox, datePicker, digitalClock, draw, floatNGo, glance, gauge, labelInput,labelPicker, LargeCloseBox, month, newSetClock, numberPicker, paragraph, pictureButton, picker, rCheckbox, scroller, setClock, slider, status, text, textButton, textList, title

11. Can I access the serial port?
Yes, you can control the serial port with PRINT/INPUT statements. You've got control over the baud rate, data bits, stop bit and parity. You can also change the prompt character and the unpend character, or unpend after a certain number of bytes.

12. Can I access other applications?
Yes. It is even possible to pass information to some other applications as well. For example, to pass an array of numbers to Pelican Software's QChart to product a graph, use the following code:
0010 LET a=[1,2,5,4,3,1,2,3,4,5]
0020 LET getroot().|qf_qchart:donv|.ddxdata=a
0021 LET getroot().|qf_qchart:donv|.rows=5
0022 LET getroot().|qf_qchart:donv|.cols=2
0030 LET getroot().|qf_qchart:donv|.ddxfrom='|basic:nsbasic|
0040 LET x:=getroot().|qf_Qchart:donv|:open()

The Qchart application will automatically open and produce the graph.

You can also call NS BASIC code from within other applications, such as spreadsheets, forms apps, and launcher utilities such as GestureLaunch.

13. Does it come with a manual?
Yes. An approximately 260 page handbook, (spiral bound so it lies flat) provides a complete description of the various commands, statements and functions, together with examples for each one. The manual is about the same size as the Newton, so it's easy to carry along with you. It's a reference style manual, which will be easy to work with for people who have already programmed BASIC on other platforms.

In addition, AP Professional, a division of Addison Wesley, have published the book "Programming for the Newton", by Schettino and O'Hara. ISBN# 0-12-623955-X. It is available through your local bookstore or from our WWW order form. This book is especially good for people who are just starting to program or who are a bit rusty. It also includes excellent sections on building larger, event driven applications in NS BASIC.

14. Where can I get the book?
Ask for it at your local bookseller. You can also order it from the NS BASIC WWW site. 

Does the demo with BASIC for the Newton work on a Newton 2.0 unit?

If you have a Newton 2.0 unit, the demo on the original printing will not work. AP Professional will supply you with an updated diskette at no charge by sending email to  jpepper© harcourtbrace.com, or calling Jeff Pepper at 617 232-0500 x 103.

15. Can I make normal Newton packages in the Extras drawer with it?
Yes. You will need ate least NS BASIC 3.0 and a Newton 2.0 unit. When you've got your program working using the normal development environment, type MAKEPACKAGE. NS BASIC will then turn your program into a standard Newton package.

To move it to other Newtons, you'll need a Package Uploader or Package Extractor program. There's a Tech Note that give details of available packages to do this.

16. Can I distribute applications I write to other users?
Yes. You may distribute packages produced with NS BASIC to other users royalty free. Of course, NS BASIC itself is licenced and may not be distributed.

17. Can I program it using a regular keyboard?
Yes, either from a Macintosh, DOS or Windows PC or Unix system. All character input and output is redirected through your host PC, so it is easy to work directly using your PC's keyboard and screen. Of course, you can also develop directly on the Newton; a number of pop up boxes and other tools are provided to make it easy. The Newton keyboard is also supported.

18. How fast is it?
All interpretation of NS BASIC code is done as statements are entered, not at run time. However, NewtonScript itself is interpreted. This results in code that is much more compact, important on a machine with a small memory footprint. NS BASIC Statements take varying amounts of time to execute: a simple FOR...NEXT loop executes at the rate of up to 83 statements per second on an MessagePad 130. On an MP 20000, we've seen 706 statements per second. Advantages of interpreters include the ability to examine and change code in the middle of execution and rapid development. NS BASIC programs are also very compact: a hundred line program uses only about 10K of storage.

19. Can I control my VCR with it?
Yes. Documentation on where to find the codes for most types of consumer electronics and how to program them is contained in one of the Tech Notes provided with NS BASIC.

20. What about support?
Send question/problems to our Support Line by one of the following:
fax: (416) 264-5888
Internet: support© nsbasic.com
There is also an on line BBS on the web site where you can post questions.
Have a look at the Tech Notes as well: they cover many topics on how to use NS BASIC.

21. Will there be future releases?
Yes. We intend to continually enhance NS BASIC. Send your suggestions to the Support Line: we'd love to hear from you about them. Be sure and register!

22. I just bought NS BASIC. How do I know I have the latest rev?
Register. We will send you the latest version as of your date of purchase, if an update exists.

23. What about NS BASIC and the Internet?
NS BASIC makes a very handy tool for accessing the internet. With it, you can create custom mail, news and web applications. By loading the BASIC iNet Tool (BIT) onto your system, you add a set of easy to use functions to NS BASIC that let you cruise the net from your Newt.
See the Tech Note for complete details.



Specifications and policies subject to change.


Last update: January 10, 1997