20. Tech Note: The LISTRUN and IMPORT Commands                April 8, 1996
-----------------------------------------------------------------------

The LISTRUN and IMPORT commands provide a mechanism for distributing NS 
BASIC
programs for users of NS BASIC 2.5 and earlier. These commands were 
replaced
in Rev 3.0 by the MAKEPACKAGE command, and the pages dropped from the
Handbook. This Tech Note contains the information from those pages.


Saving and Loading RunTime Programs

You can create programs that other people can run, even though they do not 
own
NS BASIC. You can also write programs than other NS BASIC owners can run, 
but
not examine. These programs are called .i.RunTime programs;. Once created,
these programs cannot be viewed by anyone. You can create a RunTime 
version of
a SAVEed program using the LISTRUN command. We'll create a small program, 
save
it, and then use the LISTRUN Command to create the RunTime version:

0010 REM LISTRUN Example
0020 PRINT "Hidden Program"
0030 END
* SAVE listRunExample
listRunExample saved.
* LISTRUN
//START,listRunExample,9/23/94 1:33 pm,Version 1.02'
0+02*((=ZNWkXV75628sYSwJNKEjorsrmvwvy_.V$5P"a$XY_3Xp*-5=9*"MNXYZR$'_95.
//END

Notice the output of the LISTRUN Command. This text represents the small
program in a way that does not reveal the NS BASIC program text. 
When you use a serial terminal with NS BASIC, you can copy a RunTime 
program
out of the communications software you use with your desktop computer and 
save
it to a file.

You can use a text version of a RunTime program with any version of NS 
BASIC.
To load a RunTime program into NS BASIC, you must connect the Newton to a
desktop computer. See the Using NS BASIC With a Computer or Terminal 
section
of this Handbook for more information.

Once the Newton and desktop computer are connected, you use the IMPORT 
command
to load the RunTime program. The IMPORT Command will display a prompt when 
it
is ready to begin loading a RunTime program. At this time, you can use copy
and paste to enter the text of the RunTime program into your communications
software. NS BASIC will process the file, and save an executable but
unLISTable version onto the Newton. This is an example session showing the
IMPORT Command:

* NEW
* IMPORT
Initializing Import
Paste RunTime Program to serial port now!
* //START,listRunExample,9/23/94 1:33 pm,Version 1.02'
0+02*((=ZNWkXV75628sYSwJNKEjorsrmvwvy_.V$5P"a$XY_3Xp*-5=9*"MNXYZR$'_95.
//END
Saving as listRunExample.BAS:NSBASIC
Write out .txt file...
0
* 1
* 2
* Compiling...
Saving listRunExample.BAS:NSBASIC...
Import complete.
* DIR
listRunExample           BASIC program
* LOAD listRunExample
* LIST
* RUN
Hidden Program
* 


-----------------------------------------------------------------------
LISTRUN	Command

description

LISTRUN produces a specially encoded version of a program called a RunTime
program. It outputs the program in a printable but unreadable form.

This output can be sent to another Newton using a serial connection.

The IMPORT Command is used at the other end to SAVE the RunTime as a NS 
BASIC
program which can be executed but not LISTed.

To create a RunTime file that may be used by others, LOAD your program and
type LISTRUN while connected via a serial terminal. You will see a text
version of your program displayed. Copy this text via cut and paste and 
save
it. 

Other people may LOAD and RUN this special text version using the IMPORT
Command.

Lines in Runtime files that start with // are comments and annotations. 
They
do not turn into code. You may add additional // lines to provide some
documentation with your RunTime program.

The //START line is used by NS BASIC during IMPORT processing. It includes 
the
program name, the date and time the Runtime was created, and the version 
of NS
BASIC that was used to create it.

If the word "overwrite" appears anywhere on the //START line, the incoming
program will overwrite a program of the same name that exists on the 
Newton.
If you omit the overwrite word and a program of the same name exists on the
Newton the IMPORT will be rejected and the following message is displayed:

programName already exists.
Delete and Import again.

Each line contains a checksum to guard against data corruption.
example: creating runtime program
10 REM LISTRUN Example
20 PRINT "Hidden Program"
30 end
output
* save listRunExample
listRunExample saved.
* listrun
//START,listRunExample,9/23/94 1:33 pm,Version 1.02'
0+02*((=ZNWkXV75628sYSwJNKEjorsrmvwvy_.V$5P"a$XY_3Xp*-5=9*"MNXYZR$'_95.
//END

-----------------------------------------------------------------------
IMPORT	Command

description

The IMPORT Command is used to LOAD a RunTime file as a NS BASIC program 
which
can be executed but not LISTed.

You must connect the Newton to a desktop computer with a serial cable in 
order
to use the IMPORT Command.

Lines in RunTime files that start with // are comments and annotations. 
They
do not turn into code. You may add additional // lines to provide some
documentation with your RunTime program.

The //START line is used by NS BASIC during IMPORT processing. It includes 
the
program name, the date and time the RunTime was created, and the version 
of NS
BASIC that was used to create it.

If the word "overwrite" appears anywhere on the //START line, the incoming
program will overwrite a program of the same name that exists on the 
Newton.
If you omit the overwrite word and a program of the same name exists on the
Newton the IMPORT will be rejected and the following message is displayed:

programName already exists.
Delete and Import again.

Each line contains a checksum to guard against data corruption.

example: loading a runtime program
* new
* import
Initializing Import
Paste RunTime Program to serial port now!
* //START,listRunExample,9/23/94 1:33 pm,Version 1.02'
0+02*((=ZNWkXV75628sYSwJNKEjorsrmvwvy_.V$5P"a$XY_3Xp*-5=9*"MNXYZR$'_95.
//END
Saving as listRunExample.BAS:NSBASIC
Write out .txt file...
0
* 1
* 2
* Compiling...
Saving listRunExample.BAS:NSBASIC...
Import complete.
* dir
listRunExample           BASIC program
* load listRunExample
* list
* run
Hidden Program
*