On Fri, Nov 05, 2004 at 08:12:01PM -0000, Gary wrote:
> How do I access the members of a string list?  I've got my list 
> 
>     <STRING_LIST_RESOURCE RESOURCE_ID="1300">
>       <STRING_PREFIX> "Item_List" </STRING_PREFIX>
>       <STRINGS>
>               <TEXT> "Item 1" </TEXT>
>               <TEXT> "Item 2" </TEXT>
>       </STRINGS>
>     </STRING_LIST_RESOURCE>
> 
> and I'm able to get a handle to it
> 
>     hndList = DmGetResource (strListRscType, 1300);
> 
> but is this a list of pointers to char arrays? as in 
> 
>     char** myList;
>     myList = (char**) MemHandleLock (hndList);                        

Not quite. The first sequence of bytes is the prefix
(NUL-terminated). The next two bytes is the count of strings in the
list, and the rest of the bytes are the actual strings, separated with
the NUL character. So the following (untested) code would access the
list:

 Char* prefix = MemHandleLock(rsrc);
 UInt16 count;
 MemMove(&count, prefix + StrLen(prefix) + 1, sizeof(UInt16));
 Char** strings = new Char*[count];
 Char* tmp = prefix + StrLen(prefix) + 1 + sizeof(UInt16);
 for (Int16 i = 0; i < count; ++i) {
    strings[i] = tmp;
    tmp += StrLen(tmp) + 1;
 }

-- 
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL

Dave is currently listening to Tom Robinson Band - Sorry Mr. Harris (TRB Two)

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

Reply via email to