[futurebasic] Re: [FB] STR#...again (more)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Mon, 17 May 99 01:14:43 -0500
>>What dings me between the ears is why gOffSet&=3 instead of gOffSet&=0 or
>>gOffSet&=2 is needed (although I assume it has to be because the first 2
>>bytes are giving the number of strings).  And why gOffSet& = gOffSet& + 49
>>instead of gOffSet& = gOffSet& + 48 works.  The original suggestion I was
>>given was gOffSet&=0 and then gOffSet& = gOffSet& + 48, but I had to do the
>>above to get the correct use.
>I'm only guessing now, but it appears that when strings are stored in 
>STR# resources, they don't get pad bytes. The simple solution? Add a char 
>to your strings, so they are 49 bytes long. Then when the length byte 
>gets added, they'll be 50 bytes each; then my "one fell swoop" solution 
>should work!
Hi once again,

Here is, IMHO, a clever idea for doing what I suggested above. When you 
create your 49-char strings, do so leaving the length byte as the first 
char (it will be a "0"). Then each string will look like this:

     "0"  ---- your 48 bytes of data ----
49   48   xx   xx   xx   xx ...  xx   xx
len  ch1  ch2  ch3  ch4  ch5... ch48 ch49

When you BLOCKMOVE your data (in one fell swoop) into the DIAGNOSIS$() 
array, skip the first length byte and start with byte . Then each string 
in your array will look like this:

     ---- your 48 bytes of data ----  "1"
48   xx   xx   xx   xx   xx ...  xx   49   
len  ch1  ch2  ch3  ch4  ch5... ch48 ch49

The length bytes will now hold 48's, and the "1" in the 49th byte will be 
ignored. You can use your 48-char strings as is, doing whatever you like 
with them. If you need to copy them back to the STR# resource, just 
offset your copy to ensure that the 49's become the length bytes again. 
Quick & easy!

Have fun.
 =J= a  y