[futurebasic] Re: [FB] Re: convert pascal string to container

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2001 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Wed, 15 Aug 01 14:05:47 -0500
>Jay Reeve wrote:
>> 
>>
>> Did anyone else find problems in the code I posted? (Jonathan, you talked
>> about "debugging" it--??) I confess I omitted an important error check
>> after resizing the handle, but otherwise it seems to work perfectly here.
>> 
>
>Your code ran fine here, but I have not checked if it is OK with the
>Release 4 (Larry has not received yet the Release 5), I suppose it
>should work as is though. Maybe, his emailer has eaten an ampersand 
>somewhere.
>Although, your code would run faster, I can propose simpler FNs:

<snip>
Ah, so. I forgot about PtrAndHand. You're right, it is a bit simpler, 
although I think the version you sent will copy length bytes and miss the 
last char of the strings. Shouldn't it be this?
  long if fn PtrAndHand(S1+1,C.0&,S1.0``) = _noErr
    long if fn PtrAndHand(S2+1,C.0&,S2.0``) = _noErr
      long if fn PtrAndHand(S3+1,C.0&,S3.0``) = _noErr
        long if fn PtrAndHand(S4+1,C.0&,S4.0``) = _noErr

I suspect you're right about mine being faster, too, but only because in 
yours the handle has to be resized for each string added.

If we had a sure way to identify whether the incoming var was a string or 
a container, we could easily accomplish what Michael is looking for. Does 
anyone know whether it is reliable to pass an address to fn 
gethandlesize() and see if there is an error? I'll have to try it.

 0"0
 =J= a  y
  "