Use SysStringByIndex() function. The Maximum length of the string that
can be stored is 255 characters. If you want to store more than that
break it into multiple strings, fetch the strings from the resource
using above function and concatenate programmatically.

No, the maximum length of any one string in the string list resource is 32767 or 65535 bytes (not characters), depending on whether all of the routines that SysStringByIndex correctly handle UInt16 string lengths. Though you'd also hit the limit of 64K bytes minus a bit for the maximum size of a resource.


But in double-checking the code, I noticed there's a separate issue, where the number of strings in a string list resource (modulo 256) must be less than 128 for the routine to work properly. Otherwise the code in SysStringByIndex that calculates the string count won't generate the correct result, due to sign extending the low-order byte.

Though this bug will only cause the routine to fail with more than 127 strings if (a) you pass an out-of-bounds index, in which case you'll get back a garbage result versus an empty string, or (b) if you've got more than 255 strings, then the calculated count would wrap around, and you can get an empty string returned even with a valid string index.

But having more than 127 strings in a resource is not a great idea anyway.

-- Ken
--
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-470-9200

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

Reply via email to