IBM SC34-5764-01 Server User Manual


 
haystack. By default the search starts at the first character of haystack (that is, the value of start is 1). You
can override this by specifying start (which must be a positive whole number), the point at which the
search starts.
Here are some examples:
POS('day','Saturday') -> 6
POS('x','abc def ghi') -> 0
POS(' ','abc def ghi') -> 4
POS(' ','abc def ghi',5) -> 8
QUEUED
 QUEUED() 
returns the number of lines remaining in the external data queue when the function is called. If no lines are
remaining, a PULL or PARSE PULL reads from the terminal input buffer. If no terminal input is waiting, this
causes a console read.
Here is an example:
QUEUED() -> 5 /* Perhaps */
RANDOM
 RANDOM(
max
min,
, max ,seed
) 
returns a quasi-random nonnegative whole number in the range min to max inclusive. If you specify max
or min or both, max minus min cannot exceed 100000. The min and max default to 0 and 999,
respectively. To start a repeatable sequence of results, use a specific seed as the third argument, as
described in Note 1. This seed must be a positive whole number ranging from 0 to 999999999.
Here are some examples:
RANDOM() -> 305
RANDOM(5,8) -> 7
RANDOM(2) -> 0/*0to2 */
RANDOM(,,1983) -> 123 /* reproducible */
Notes:
1. To obtain a predictable sequence of quasi-random numbers, use RANDOM a number of times, but
specify a seed only the first time. For example, to simulate 40 throws of a 6-sided, unbiased die:
sequence = RANDOM(1,6,12345) /* any number would */
/* do for a seed */
do 39
sequence = sequence RANDOM(1,6)
end
say sequence
The numbers are generated mathematically, using the initial seed, so that as far as possible they
appear to be random. Running the program again produces the same sequence; using a different
initial seed almost certainly produces a different sequence. If you do not supply a seed, the first time
RANDOM is called, the microsecond field of the time-of-day clock is used as the seed; and hence your
program almost always gives different results each time it is run.
2. The random number generator is global for an entire program; the current seed is not saved across
internal routine calls.
Functions
190
CICS TS for VSE/ESA: REXX Guide