[futurebasic] RE: [FB] STR# question

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

From: Chris.Young@...
Date: Fri, 14 May 1999 12:02:54 -0500

On Friday, May 14, 1999 9:36 AM, JoeAtTIME [SMTP:JoeAtTIME@...] 
wrote:
> 
> In a message dated 5/14/99 7:38:15 AM, you wrote:
> 
<BIG SNIP>
> itemnumber=FN countStr(_diagnosislistSTR)
> LONG IF itemnumber>0
>     StrHndl& = FN GETRESOURCE(_"STR#",_diagnosislistSTR)
>     OSErr  = FN HNOPURGE(StrHndl&):gOffSet&=0
>     FOR Myloop=1 TO itemnumber
>       POKE @DIAGNOSIS$(Myloop),48           'Set length byte
>       BLOCKMOVE [StrHndl&]+gOffSet&,@DIAGNOSIS$(Myloop)+1,48'move 
string
>       gOffSet& = gOffSet& + 48              'get offset of next string
>     NEXT
>     OSErr  = FN HPURGE(StrHndl&)
> END IF
> 
> Corrections?
> 
> Thanks, Terrald
> >>
> 
>  I think this line:     gOffSet& = gOffSet& + 48              'get 
offset of 
> next string
> 
>  should be:     gOffSet& = gOffSet& + 50              'get offset of 
next 
> string
> 
> Strings contain a length byte and also need to be padded to an even 
number of
> 
> bytes. So you have the string = 48 bytes + 1 length byte + 1 unused 
byte = 50
> 
> bytes total.
> -Joe Lertola
> 
> --
Also, doesn't a STR# resource begin with the string count (word or 
integer length)? You would need to start your gOffset& at 2 (if it is 
an integer) or 4 if it is a long to account for this.

Chris Young