aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/doc/tupar.hlp
blob: 3c8d99b3beb30159a57c4ea7b4f1c964a4f9bda6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
.help tupar Jun97 tables
.nj
.ih
NAME
tupar -- Edit table header parameters.
.ih
USAGE
tupar table
.ih
DESCRIPTION
This task is an interactive editor that allows the user to modify table
header parameters.
Prompts are written to STDERR rather than
STDOUT so that STDOUT can be redirected to a file.
If STDERR is redirected, no prompts will appear.
Prompting is also turned off if the input is redirected from a file.

The table to be edited is copied to a temporary table
in the same directory as the original table
(or in tmp$ if the first copy attempt fails),
and the changes are made to that copy.
When you exit 'tupar',
the copy is renamed back to the name of the original table.
If you quit rather than exit,
then the copy is deleted, so the original table will remain unchanged.

The prompt ":" is used by the task when it is waiting for user input.
At this prompt the user can enter any editor command.
The "e" command (or end of file, e.g. Control-Z) will exit the editor.
The following commands are available:  e, q, g, p, d, r, k, t, l.
These commands are interpreted as exit, quit (without saving changes),
get, put, delete, replace, change keyword name, type, and list respectively.
Each of these commands is described in detail below:

The exit command, specified by "e" or end of file,
will close the file--saving all changes,
and open the next file if more than one file was specified
for the 'table' input parameter.

The quit command is similar to exit except that changes that were made
to the header parameters will not take effect,
unless 'inplace = yes'.
If changes were made to the table header
you will be prompted for confirmation
unless the command was given followed by "!";
for example, "q!" or "quit!".

The type command, specified by "t", and the list command,
specified by "l",
both display header parameters---one header per line of output.
The difference between the two commands is that list will show the parameter
number and type will not.
Entering the command "t" or "l" will produce
a listing of all header parameters.
Optionally, an integer may follow
the command indicating that only a particular parameter is to be displayed.
Two integers following the command indicate a range of parameters.
If a number is specified that is beyond the range of valid headers,
an error message will be displayed.
The output consists of the name of the header parameter,
its data type (indicated by a single letter,
"r" for real, "b" for boolean, "i" for integer, or "d" for double),
and its current value.
If the keyword has an associated comment,
the comment will be displayed following the value.
The following are examples of valid syntax for listing header parameters:
.nf
t
l
t 3
l 300 310
.fi

The get command, indicated by "g", will look for a specific keyword and
display its current value.
Optionally, the data type can be specified
using the letter "r" for real, "i" for integer, "d" for double, or
"b" for boolean.
If no data type is specified, then the type is assumed to be text.
If the data type is specified,
the type immediately follows the "g" command;
for example, typing the command "gd X" will get the value 
contained in the header keyword "X" and display it as a double-precision
real value.
If "X" does not exist, no output will be produced.
If the keyword has an associated comment,
the get command displays the comment following the value;
a text string value will be enclosed in quotes
to distinguish the value from the comment.
Examples of valid syntax follow:
.nf
g history
gd coeff0
gi numpts
.fi

The put command, specified by "p", will either replace the value of an
existing parameter,
or it will create a new parameter if the specified parameter is not found.
The "p" command is followed on the command line by a keyword
name and the parameter value.
A comment may optionally follow the value.
The "p" command itself should
be followed by a single letter type specifier, "i" for integer,
"r" for real, "d" for double, or "b" for boolean.
If no type is specified, then the data type is assumed to be text.
In order to specify a comment with a parameter of type text,
the parameter value must be enclosed in quotes
in order to distinguish it from the comment.  (Keyword names
HISTORY and COMMENT are already comments,
and further comments cannot be added to them.)
Examples of valid put command syntax follow:
.nf
p comment Created for testing.
gd coeff0
pd coeff0 3.141592653589793
pi ncoeff 7 number of coefficients
pt fittype chebychev
pt fittype "chebychev" type of fit that these coefficients represent
.fi

The replace command, specified by "r", works much like the put command
described above; however, it will prompt the user for confirmation before
actually changing any values in the table.
A parameter can be specified by name or by number.
The "r" command will not change a keyword name or a data type,
whereas the "p" command can.
After the command is entered,
the current value of the keyword is displayed and
the editor waits for a new value to be entered by the user.
Pressing the return key indicates that no change is to be made.
Pressing the space bar will blank the current value.
You will then be prompted for
confirmation unless the command was issued as "r!" or the input was
redirected from a file.
The default action is given by the 'delete_default' parameter.

A range of contiguous parameters can be replaced at one time by giving
the names or numbers of the first and last parameters to be replaced.
This can involve a lot of prompting for confirmation,
especially if several tables are being edited with 'same=yes'.
In this context, "contiguous" means adjacent in the table header.
Thus, when replacing a range by name,
it is not the parameters that fall alphabetically within the limits
that will be replaced
but rather the parameters that are numerically within the limits.
When editing a list of tables with 'same=yes',
the same replacement string is used for each table.
Thus it is essential that there be the same number of parameters in
the range in all tables being edited.
When no replacement value is given (i.e., just hit the return key),
then the current keyword value is not changed,
either in the first table or in subsequent tables.

Sample replace commands follow:
.nf
r coeff0
r 17
r! 17
r junk dummy
r junk 12
r 5 12
.fi

The delete command, specified by "d", will delete a header parameter by
either name or number.
The editor prompts for confirmation of delete,
unless input is redirected from a file.
The default action is given by the 'delete_default' parameter.
If you do not want to be prompted for confirmation, enter the command as "d!".
If you want to delete a history or comment record other than the first,
you can identify the parameter by number rather than name.

A range of contiguous parameters can be deleted at one time by giving
the names or numbers of the first and last parameters to be deleted.
As with replacing a range of parameters,
a contiguous block of parameters will be deleted.

Examples of valid delete commands follow:
.nf
d testflag
d 17
d! 17
d junk dummy
d junk 12
d 5 12
.fi

The "k" command changes the name of a keyword
without changing the data type, value, or comment.
Give the current and new keyword names following the "k".
Note that keywords are limited to eight characters.
If the name of a COMMENT or HISTORY keyword is changed,
only the first occurrence of that keyword will be changed.

Examples of valid change keyword commands follow:
.nf
k history comment
k dummy test
.fi
.ih
PARAMETERS
.ls table [file name template]
A table name or list of table names whose header parameters are to be edited.
Unless 'inplace = yes',
each table will be copied (one at a time) to a temporary table,
and changes are made to the copy until you exit.
This can cause problems if there is not enough disk space for the copy;
however, the 'inplace' parameter can
be set to "yes" so that the tables are opened in-place.
.le
.ls (same = no) [boolean]
Apply the same set of instructions to all tables?  

This is only relevant when more than one table is being edited.
If 'same = no', instructions are processed separately for each table,
with the "e" command used to end processing of a table and open
the next table.

If 'same = yes', the same instruction set is applied to all tables.
These instructions will be read from STDIN (which may be redirected)
and saved in a local buffer while the first table in the list is open.
For each subsequent table the instructions will be read from the local buffer.
Caution is advised when deleting or replacing parameters, especially by
number; remember that prompting for confirmation is turned off if the
input is redirected or if the instruction is given as "d!" or "r!".

If 'same = yes' and you quit (rather than exit) from editing the first table,
the behavior of the task depends on whether changes were made before quitting.
If changes were made then the task aborts immediately
without opening the other tables in the input list.
If no change was made then the other tables are processed.
The idea is to allow "g", "t", and "l" commands
and still be able to quit rather than exit,
since nothing was modified.
If changes were made but you quit,
that's interpreted as trying to recover from an error,
so we don't change the first table and we don't continue.
.le
.ls (verbose = yes) [boolean]
Display the name of each table when it is opened?  

If STDOUT is redirected
then these file names will be written to STDERR as well as to STDOUT.
.le
.ls (readonly = no) [boolean]
Prevent changes from being made to the file?  

If 'readonly = yes', then the
table is opened with read only access.  This is useful for viewing the
contents of the table while at the same time preventing changes from
being made to it.  (Only the "g", "t", and "l" commands are useful in
read only mode).
.le
.ls (inplace = no) [boolean]
Edit the original table in-place?

By default a copy of the original table is made,
either in the same directory or in tmp$.
This makes it possible to quit without saving changes.
If the table is large, however,
it may be undesirable to make a copy,
so the 'inplace' parameter gives you the option
of editing the original table.
In this case, however, it will not be possible to quit without saving changes.
.le
.ls (quit_default = no) [boolean]
The value of this parameter is the default response to the prompt
for confirmation if you give the quit command.
.le
.ls (delete_default = yes) [boolean]
The value of this parameter is the default response to the prompt
for confirmation for the delete and replace commands.
.le
.ls go_ahead [boolean]
The user does not set this explicitly.
It is the parameter which is actually gotten in response to a prompt.
.le
.ih
EXAMPLES
1. This example reads all history records from all tables in the default
directory and writes them to 'history.lis'.
.nf

tt> tupar *.tab same=yes verbose=no readonly=yes >history.lis
        (The task writes a ":" prompt and waits for input.)
:g history
:q
tt>
.fi

2. This example illustrates the use of each of the commands when editing
parameters in one table.  This kind of interactive use of the task
would not be appropriate when operating on a list of tables unless
the 'same' parameter is set to "no".
.nf

tt> tupar junk
        (The task writes the table name and a ":" prompt and waits for input.)
junk.lis
:g garvage
        (The keyword was not found, so nothing was displayed.)
:g garbage
GARBAGE = 3.1416926535
:pd garbage 3.1415926535
:p comment yet another comment
:t
GARBAGE  d 3.1415926535
COMMENT  t This is the first comment.
PI       t 3.1415926535  not an accurate value
COMMENT  t yet another comment
:l 3 999
 3 PI       t '3.1415926535'  not an accurate value
 4 COMMENT  t yet another comment
:g pi
PI = '3.1415926535'  not an accurate value
:gd pi
PI = 3.1415926535  not an accurate value
:pd pi 3.14159265358979323846 a more accurate value
:l
 1 GARBAGE  d 3.1415926535
 2 COMMENT  t This is the first comment.
 3 PI       d 3.141592653589793  a more accurate value
 4 COMMENT  t yet another comment
:d garbage
The following parameter is to be deleted:
GARBAGE  d 3.1415926535
   ...   OK to delete ? (yes):			(user hits return)
:d comment
The following parameter is to be deleted:
COMMENT  t This is the first comment.
   ...   OK to delete ? (yes): n		(user types n)
:l 4
parameter out of range; max is 3
:d 3
The following parameter is to be deleted:
COMMENT  t yet another comment
   ...   OK to delete ? (yes):			(user hits return)
:t
COMMENT  t This is the first comment.
PI       d 3.141592653589793  a more accurate value
:r 1
keyword COMMENT, type t; give replacement value:
This is the first comment.			(TUPAR writes this & waits)
this is a comment				(this line entered by user)
Current parameter and its replacement are:
COMMENT  t This is the first comment.
COMMENT  t this is a comment
   ...   OK to replace ? (yes): n		(user types n)
no action taken
:q
tt>
.fi
.ih
BUGS
.ih
REFERENCES
This task was written by Phil Hodge.
.ih
SEE ALSO
tprint, tdump, tedit

Type "help tables opt=sys" for a higher-level description of the 'tables' 
package.
.endhelp