A recent reply pointed at an entry in the Knowledge Base that
described the in-memory format of the tSTL (string list) resource.

There is a NUL-terminated "prefix string" (which I assume is to be
used to describe the subject of the list) followed by a short int set
to the number of entries in the list, followed by the list entries
themselves, all NUL-terminated.

The following code can be used to walk through each string
in turn:

 file://- test code
 VoidHand hFontChoices;
 Char *pFontChoices;
 int nFontChoices;
 int i;


 hFontChoices = DmGet1Resource('tSTL', FontChoicesStringList);
 pFontChoices = MemHandleLock(hFontChoices);
 pFontChoices += StrLen(pFontChoices)+1;    // scan off the "prefix string"
 nFontChoices = *(short *) pFontChoices;        // get the # of entries
 pFontChoices += sizeof(short);                        // increment over the
short
 for (i=0; i<nFontChoices; i++) {                        // for each entry
...
    // do something w/ string entry #i
pFontChoices += StrLen(pFontChoices)+1;    // point to next entry
}

MemHandleFree(hFontChoices);
 file://- end test code


--
-Richard M. Hartman
[EMAIL PROTECTED]

186,000 mi/sec: not just a good idea, it's the LAW!


Mauricio Tavares wrote in message <33309@palm-dev-forum>...
>
>At 10:40 AM 12/15/00 -0600, you wrote:
>>From: "Mauricio Tavares" <[EMAIL PROTECTED]>
>>
>>> and convert to the list object so it can be shown.  But, what I want is
to
>>> read in the string list and then select one of its entries and then
print
>>> it.  Can't I just get it off the string list or should I convert it to a
>>> list first?
>>
>>Create the string list as a resource (in Constructor), then use
>>SysStringByIndex() to retrieve one of the strings from the list.
>>
> Richard,
>
> I looked at the Palm OS SDK Reference, and saw the format for this
>function is
>
>Char* SysStringByIndex (UInt16 resID, UInt16 index, Char* strP, UInt16
maxLen)
>
>From what I understood, resID is the resource ID for the string list, index
>is the string #, strP is a string that is there just as a placeholder in
>memory so SysStringByIndex has a place to put its return argument.
>
>As a quick and dirty but not very elegant test, I wrote the following
>function:
>
>static void DrawOneListItem(void)
>{
> CharPtr theString;
> Char theStringPtr[255];
>
> theString = SysStringByIndex(stringQuotes, 2, theStringPtr, 255);
> WinDrawChars(theString, sizeof(theStringPtr), 1, 130);
>}
>
>Where my string list looks like this in my .rcp file:
>
>STRINGTABLE stringQuotes
>  "moose bit my sister" "Ministry of silly walks" "nights who say ni"
>
>When I try the above routine, shown above asking for the 3rd string
>(index=2), what I get is "moose", nothing else.  So, that would make me
>think that no matter what I fed to index, theString ends up always being
>the first word in the first string.  Would you have an idea why?  Could I
>be passing the wrong arguments?
>
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to