b
bs(1) | bs(1) |
interrogate operator, returns null) if there was no valid subscript for the previous item call. The name argument should not be quoted. Since exact table sizes are not de®ned, the interrogation operator should be used to detect
table("t", 100)
...
#If word contains "party", the following expression adds one
#to the count of that word:
++t[word]
...
# To print out the the key/value pairs:
for i = 0, ?(s = item(t, i)), ++i if key() put = key()_":"_s
If the interrogation operator is not used, the result of item is null if there are no further elements in the table. Null is, however, a legal ``subscript''.
iskey(name, word)
iskey tests whether the key word exists in the table name and returns one for true, zero for false.
Odds and ends
eval(s) The string argument is evaluated as a bs expression. The function is handy for converting numeric strings to numeric internal form. eval can also be used as a crude form of indirection, as in:
name = "xyz" eval("++"_ name)
which increments the variable xyz. In addition, eval preceded by the interrogation operator permits the user to control bs error conditions. For example:
?eval("open(\"X\", \"XXX\", \"r\")")
returns the value zero if there is no ®le named XXX (instead of halting the user's program). The following executes a goto to the label L (if it exists):
label="L"
if !(?eval("goto "_ label)) puterr = "no label"
plot(request, args)
If the tplot command is available, the plot function produces output on devices recognized by tplot. The requests are as follows:
| Call | Function |
| plot(0, term) | causes further plot output to be piped into tplot |
|
| with an argument of |
|
| 40 characters in length. |
| plot(1) | ``erases'' the plotter. |
| plot(2, string) | labels the current point with string. |
| plot(3, x1, y1, x2, y2) | draws the line between (x1,y1) and (x2,y2). |
| plot(4, x, y, r) | draws a circle with center (x,y) and radius r. |
| plot(5, x1, y1, x2, y2, x3, y3) | draws an arc (counterclockwise) with center |
|
| (x1,y1) and endpoints (x2,y2) and (x3,y3). |
| plot(6) | is not implemented. |
| plot(7, x, y) | makes the current point (x,y). |
| plot(8, x, y) | draws a line from the current point to (x,y). |
| plot(9, x, y) | draws a point at (x,y). |
| plot(10, string) | sets the line mode to string. |
| plot(11, x1, y1, x2, y2) | makes (x1,y1) the lower left corner of the plot- |
|
| ting area and (x2,y2) the upper right corner of |
|
| the plotting area. |
Section 1−54 | − 6 − |