October 2001
Intermediate to advanced
704 pages
19h 33m
English
STRINGTABLE (tSTL)
STRINGTABLE ID <StringTableResourceId.n> <PrefixString.ss> ... <String.ss>
Using the tSTL resource in a LIST:
[source.rcp]
STRINGTABLE stringTableMetric
"" "Litres" "Meters" "Celsius" "Newtons" "Kilograms"
[source.c]
MemHandle memHandle, memStringList;
MemPtr ptrTable;
UInt16 count;
memHandle = DmGetResource('tSTL', stringTableMetric);
ptrTable = (MemPtr)MemHandleLock(memHandle);
// get the string count <-- "messy"
count =
(*((UInt8 *)(ptrTable + StrLen((Char *)ptrTable) + 1)) << 8) |
*((UInt8 *)(ptrTable + StrLen((Char *)ptrTable) + 2));
// get the handle to an array of strings
memStringList =
SysFormPointerArrayToStrings(ptrTable+StrLen((Char *)ptrTable) + 3, count);
// Note: the "prefix" is ignored here
...
MemHandleUnlock(memHandle);
DmReleaseResource(memHandle);Using the tSTL resource to get a single string:
[source.rcp] STRINGTABLE stringTableTypes "Units are:" "Metric" "Imperial" [source.c] Char string[32]; SysStringByIndex(stringTableTypes, 0, string, 32);
A limitation of 384 strings applies.
STRINGTABLE ID 100 "" "One" "Two" "Three" "Four" STRINGTABLE ID 100 "-" "One" "Two" "Three" "Four"