86
Fixed-Length String Storage Layout
Offset
Length
Description
0
1
The string length, in bytes.
1
1
A marker identifying the string characteristics:
&Hff fixed allocation, fixed length
2
N
The characters of the string where N is the fixed string length.
3.26.3 String Address and String Type
Generally, you neednt be concerned about the technical details regarding strings described in the
preceding section. For certain special situations, however, it may be useful directly access a string
variables inner data components. The StrAddress() function works with all of the string types
described above and will return the address of the first character of the string storage. Note, however,
that for dynamically allocated strings if the strings length is zero the returned address will be of no use (it
will generally be zero). Moreover, the returned address may be an address in RAM, in Program Memory
or in Persistent Memory. Depending on where the strings characters are stored you must use different
System Library Functions to retrieve the strings characters. You can use the System Library function
StrType() to determine the nature of the strings storage. It will return the second byte of the string
variables storage space. See the tables above for the values and their meaning.
BasicX Compatibility Note
In BasicX compatibility mode, neither StrAddress() nor StrType() is available.
3.27 Task Management
The ZBasic System Library has several routines that are helpful for managing tasks including LockTask(),
UnlockTask(), StatusTask(), ResumeTask(), RunTask() and ExitTask(). The latter four routines permit
some advanced task management for special situations. One use of these routines is to implement a
timeout on a task that is awaiting the completion of an event, e.g. an external interrupt or an input
capture. Normally, when a task is set to wait for an event like these it will wait indefinitely.
3.27.1 Task Control Block
Each task has an associated Task Control Block (TCB) - a data area that occupies the first few bytes of
the task stack in VM mode (the last few bytes of the task stack in native mode). In most cases, a program
will not need to access the contents of a TCB. The information is included here for those rare
circumstances when is needed. Use of this information is recommended for advanced programmers only.
When a task is activated its task control block is initialized and then inserted into a circular linked list
immediately following the task control block of the then-current task. The table below gives some
information on the structure of the task control block. It is important to note that this information is
considered implementation detail subject to change as necessary.
Task Control Block Elements (VM Mode Devices)
Offset
Length
Description
0
1
Task status. See StatusTask() for details.
1
2
Remaining time to sleep (in RTC ticks).
3
2
Address of next task control block.
5
6
Task context: IP, BP, SP (valid only when not the current task).
11
1
Task control flags (used internally).
12
2
Address of the byte following the end of the tasks stack.