bs(1) | bs(1) |
possible to know whether a is a number or a string when the format call is coded, coercing a to the type required by f by either adding zero (for e or f format) or concatenating (_) the null string (for s format) should be considered.
index(x, y)
returns the number of the ®rst position in x that any of the characters from y matches. No match yields zero.
trans(s, f, t)
Translates characters of the source s from matching characters in f to a character in the same position in t. Source characters that do not appear in f are copied to the result. If the string f is longer than t, source characters that match in the excess portion of f do not appear in the result.
substr(s, start, width)
returns the
match(string, pattern)
mstring(n) The pattern is a regular expression according to the Basic Regular Expression de®nition (see regexp(5)). mstring returns the
match("a123ab123",
File handling
open(name, file, function) close(name)
name argument must be a bs variable name (passed as a string). For the open, the ®le argument can be:
1.a 0 (zero), 1, or 2 representing standard input, output, or error output, respec- tively;
2.a string representing a ®le name; or
3.a string beginning with an ! representing a command to be executed (via sh
open("get", 0, "r") open("put", 1, "w") open("puterr", 2, "w")
Examples are given in the following section.
access(s, m)
executes access() (see access(2)).
ftype(s) returns a single character ®le type indication: f for regular ®le, p for FIFO (i.e., named pipe), d for directory, b for block special, or c for character special.
Tables
table(name, size)
A table in bs is an associatively accessed,
item(name, i)
key() The item function accesses table elements sequentially (in normal use, there is no orderly progression of key values). Where the item function accesses values, the key function accesses the ``subscript'' of the previous item call. It fails (or in the absence of an
− 5 − | Section 1−53 |
b