source: NEWT0/trunk/documents/en.01_howto.txt @ 133

Revision 133, 5.8 KB checked in by matthiasm, 3 years ago (diff)

Converted documentation from Japanese into what Google claims to be English. Manually improved a few lines of the translation, but I am not sure if I got it right.

  • Property svn:executable set to *
Line 
1  NEWT/0, the basics
2----------------------
3
4   This document assumes that the reader has a basic knowledge of Unix shell
5   commands and is familiar with setting the required path variables.
6
7
8   Basic use:
9
10     As with most shell commands, the -h option briefly describe all command
11     line options:
12
13       % newt -h
14
15       Usage: newt [switches] [-] [programfile]
16         -t               enable trace mode
17         -l               dump lex info, dispaly the lexical analysis stage of
18                          compilation
19         -s               dump syntax tree
20         -b               dump byte code
21         -C directory     change working directory
22         -e 'command'     compile and run one line of script
23         -i [symbols]     print function info: see a description of the built-in
24                          function name 'symbol' or of all functions
25         -v               print version number
26         -h               print this help message
27         --newton, --nos2 generate Newton OS 2.0 compatible code
28         --copyright      print copyright information
29         --version        print version number (same as -v)
30
31     How to compile and run scripts:
32
33       % newt name        run the script file name.
34       % newt             read a script from standard input
35       % script           run the script if the first line of the script file
36                          is "#! newt" *1
37
38       * 1) NewtonScript comments are delimited with /* */ and // only, The
39           Unix "#!" notation is treated as a comment in the first line of
40           the file only.
41
42   ○ built-in functions
43
44       List all built-in function using the command line option -i
45
46   % newt -i
47
48         HasVariable (frame, name)
49         HasVar (name)
50         DefGlobalFn (name, fn)
51         DefGlobalVar (name, value)
52         Mod (n1, n2)
53         (...)
54         StrCat (str1, str2) ... concatenate two strings (side effects) (*2)
55         P (obj) ... print the object
56         Print (obj) ... print the object (*2)
57         LoadLib (file) ... load external libraries (*2)
58         Load (file) ... load and run a script file (*2)
59         Require (str) ... load a require library  (*2)
60         GetEnv (str) ... obtain environment variables (*2)
61         FileExists (path) ... confirm the existence of a file (*2)
62         DirName (path) ... extract the path to the directory name (*2)
63         BaseName (path) ... extract the path to the file name (*2)
64         JoinPath (dir, fname) ... join a directory and a path name (*2)
65         ExpandPath (path) ... convert a relative to the absolute path (*2)
66         Split (str, sep) ... split in a string at the delimiter to generate
67                              an array (*2)
68         DumpFn (fn) ... dump a function (*3). If the argument is nil, the
69                         currently running function is dumped
70         DumpBC (instructions) ... dump an instruction as byte code (*3)
71         DumpStacks () ... VM stack dump (*3)
72         Gets () ... obtain a line from standard input
73         Getc () ... Gets character from standard input
74         Getch () ... Gets a character directly from the keyboard
75
76         And (n1, n2) ... (*4)
77         Or (n1, n2) ... (*4)
78         ShiftLeft (n1, n2) ... (*4)
79         ShiftRight (n1, n2) ... (*4)
80         ObjectEqual (obj1, obj2) ... (*4)
81         DefMagicPointer (mp, value) ... (*4)
82         MakeRegex (pattern, opt) ... (*4)
83
84         Clone (obj) ... (*5)
85         ClassOf (obj) ... (*5)
86         Length (obj) ... (*5)
87
88       *2) extended function
89       *3) debugging function
90       *4) syntax (operators, etc.) automatically extracted from the function
91       *5) function will be inlined into byte code
92
93       In addition to the above functions the usual mathematical operators
94       are supported.
95
96       Only the most important functions are implemented at the moment. Regular
97       use of newt/0 will show which functions of the NewtonScript manual must
98      still be written.
99
100   ○ external libraries
101
102     External libraries written in "C" can be used by calling
103
104       LoadLib ( "samplelib.dylib");
105
106       * libraries can be loaded using a full path name as well
107
108     External libraries in the sample is loaded in the following two additional functions
109     .
110
111        GetGlobalFn (name) ... global function, the function returns an object
112        info (obj) ... functions specified by the object or symbol
113                                         See the description of global functions
114
115   ○ Require request for the library by
116
117     Require outside the library (extension. Dylib,. So) or
118     Source code (the extension. Newt) only once can be loaded.
119     Rhodes was once the library is not loaded. Library search path
120     Look for the library to load.
121
122        Require ( "protoFILE");
123
124
125   ○ library search path
126
127     NEWTLIB environment variable to the library search path was set by
128     Will be searched. NEWTLIB has not been set for the current path
129     And running a file from a directory will be searched.
130
131
132   ○ for the library initialization
133
134     Library of egg.newt exists in the search path, newt starts
135     Automatically when the motion was pounded into reading.
136
137
138   ○ global variables
139
140         A directory of executable files _EXEDIR_ ...
141         _ARGV_ ... When you start the command of the arguments (not a command name)
142         _ENV_ ... Environment variables (NEWTLIB currently only) may be stored
143         About _VERSION_ ...
144         _STDOUT_ ... Standard output (usually the NIL, if the string is the string will be added to the output)
145         _STDERR_ ... Standard error output (usually the NIL, if the string is the string will be added to the output)
146         The library requires ... Require information
147
148   ※ changes the future may be
Note: See TracBrowser for help on using the repository browser.