[futurebasic] Re: Emulating VB 64K Strings

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 1997 : Group Archive : Group : All Groups

From: Deepesh Letap <DLetap@...>
Date: Mon, 17 Nov 1997 08:43:57 +0000
>I have been a lurker for some time but have been faithfully
>reading a learning. I am spoiled by Visual Basic 64K length
>strings and am feeling limited with FB 256 byte ones.
>I am porting some Visual Basic stuff to Mac for a chemistry
>product and wonder if anyone has some code to handle blocks
>of memory as if they were large string variables.
>I'd like to allocate a 32K block and have a functions to
>append data, read it out a byte, block, or line at a time
>and one to return the length. Anyone got these?

The routines do exist and somebondy on the list had made them. Assuming
you cannot find that excellent compendium, and assuming yours are plain text
strings which are not styled text, the use of handles makes this quite simple.

To make a new string, of StringLength& characters, use:

String1Hndl&=FN NEWHANDLE(StringLength&)
osErr%=FN HLOCK(String1Hndl&)
String1Ptr&=PEEK LONG(String1Hndl&)
DEF BLOCKMOVE TheSourcePtr&,String1Ptr&, StringLength&
osErr%=FN HUNLOCK(String1Hndl&)

To read it out byte by byte, use:

TextSize&=FN GETHANDLESIZE(String1Hndl&)
osErr%=FN HLOCK(String1Hndl&)
FOR Loop&=0 TO TextSize&
REM Perform you action on ReadByte%
NEXT Loop&
osErr%=FN HUNLOCK(String1Hndl&)

To append String2 onto String1, use:

osErr%=FN HANDANDHAND(String1Hndl&, String2Hndl&)

To check the size of your string, use:

TextSize&=FN GETHANDLESIZE(String1Hndl&)

When a string is no longer required, remember to dispose of it:

osErr%=FN DISPOSEHANDLE(String1Hndl&)

These are from the top of my head so please excuse any obvious typing errors.

Hope they help,