Tech Note January 27, 1997
03. Accessing Built In Data
-----------------------------------------------------------------
The GETROOT() Function returns the root frame of your Newton. Every
application currently installed on your Newton is accessible via this
frame. Because of their large size, you should always use the special :=
assignment operator to point to this frame.
The first example program will display all of the items stored in the
root frame. The output of this list is quite large, and will not be
reproduced in this technote. This program is completely safe. You can
enter and run it on your Newton with no risk of data loss.
10 REM getroot() Example
20 rootFrame := getroot()
30 rootElements := elements(rootFrame)
40 numElements = length(rootElements)-1
50 FOR i = 0 TO numElements
60 PRINT rootElements[i]
70 NEXT i
The next example will open the Names application, and is also completely
safe:
10 getroot().cardFile:open()
The :open() in the above program tells the Names application to open as
if you had tapped Names. The built-in applications respond to :open() and
:close(). The names of the built-in applications are paperRoll (Note
Pad), calendar (Dates), cardFile (Names), extrasDrawer (Extras), and
assistant (Assist).
The last example program will display all of the fields in your user
configuration frame. The output of this list is quite large, and will not
be reproduced in this technote. This program is completely safe. You can
enter and run it on your Newton with no risk of data loss.
10 REM GETROOT().userConfiguration Example
20 rootFrame := GETGLOBALS().userConfiguration
30 rootElements := ELEMENTS(rootFrame)
40 numElements = LENGTH(rootElements)-1
50 FOR i = 0 TO numElements
60 PRINT rootElements[i]
70 NEXT i
Figuring out the index to a file
--------------------------------
One of the first things you need to do in accessing someone else's files
is figure out what the name of the index variable is for your OPEN and
GET statements.
Here's a short NS BASIC program that displays all the file names and what
their indexes are. It uses some functions that are not listed in the NS
BASIC manual.
* list
0010 rem list indexes of all files
0011 print "Enter 0 for internal, 1 for card:";
0012 input store
0020 LET x:=getstores()[store]:getsoupnames()
0030 for i=0 to length(x)-1
0040 print x[i]
0060 LET indexes:=getstores()[store]:getsoup(x[i]):getindexes()
0065 if length(indexes)=0 then goto 100
0070 for j=0 to length(indexes)-1
0080 print "",indexes[j].path
0090 next j
0100 next i
* run
Enter 0 for internal, 1 for card:
? 1
Calendar
mtgStartDate
mtgAlarm
Calendar Notes
mtgStartDate
mtgAlarm
indexes.BAS:NSBASIC
LineNo
Names
sortOn
Notes
timeStamp
Repeat Meetings
mtgStopDate
mtgAlarm
Repeat Notes
mtgStopDate
mtgAlarm
SCRATCH.BAS:NSBASIC
LineNo
System
tag
To do
mtgStartDate
mtgAlarm