User guide

46 CHAPTER 3. THE LIBRARY
ch := capitalch(ch) CIN:y, POS:y, NAT:y
This function converts l owercase letters to uppercase, leaving other characters un-
changed.
res := changeco(val, cptr) CIN:y, POS:y, NAT:y
This function is only used in the functions that implement the coroutine mechanism,
namely: createco, callco, resumeco and cowait. It causes the current coroutine to
become suspended and gives control to the coroutine specified by cptr. Strangely,
execution continues just after the call of changeco but with the P pointer pointing to
the stack frame of the function that cause d the target coroutine to become suspended.
The calls of changeco in callco, cowait and resumeco are immediately followed by
RETURN sttatements which cause the cor re sponding functi on to return wi t h result val.
Its only other use in createco and this is more subtle but can be understood by l ooking
at the description of createco on page 47.
res := changepri(taskid, pri) CIN:n, POS:y, NAT:n
This Cintpos function attempts to change the priority of the sp e c i fied task to pri.
It moves the specified task control block to its new position in the priority chain. If the
specied task is runnable and of higher priority than the current task, it is given control
leaving the curr e nt task suspended in RUN state. The result is non zero if successful,
otherwise it is zero wit h result2 set to 101 if taskid is invalid or to 102 if the change
would cause two tasks to have the same priority.
res := clihook(arg) CIN:y, POS:y, NAT:y
This function simply calls start(arg) and ret ur ns its result. Its purpose is to
assist debugging by providing a place to set a breakp oi nt in the command language
interpreter (CLI) just before a command in entered. O cc ass i onal l y, a user may find it
useful to override the standard definition of clihook with a private version.
codewrch(code) CIN:y, POS:y, NAT:y
This routine uses wrch to write the Uni c ode character code as a sequence of bytes
in either UTF8 or GB2312 format. If the encoding field of the current output stre am
is UTF8, the output is in UTF8 form at as described in the following table.
Code range Binary value UTF8 bytes
0-7F zzzzzzz 0zzzzzzz
80-7FF yyyyyzzzzzz 110yyyyy 10zzzzzz
800-FFFF xxxxyyyyyyzzzzzz 1110xxxx 10yyyyyy 10zzzzzz
1000-1FFFFF wwwxxxxxxyyyyyyzzzzzz 11110www 10xxxxxx 10yyyyyy 10zzzzzz
etc etc etc
If the encoding field of the current output stream i s GB2312, the output is in GB2312
format as described in the following table.