HP-UX Reference (11i v2 04/09) - 1 User Commands A-M (vol 1)

b
bs(1) bs(1)
previous item call. The name argument should not be quoted. Since exact table sizes
are not defined, the interrogation operator should be used to detect end-of-table; for
example:
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:
fori=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 convert-
ing 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 file named XXX (instead of halting the user’s pro-
gram). 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 -Tterm. term can
be up to 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
plotting area and (x2,y2) the upper right
corner of the plotting area.
HP-UX 11i Version 2: September 2004 − 6 − Hewlett-Packard Company Section 1−−59