[futurebasic] Re: [FB] String <=> Handle

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

From: Jay Reeve <jktr@...>
Date: Sat, 11 Sep 99 01:23:26 -0500
tedd,

>Does anyone have a cool way of going from a string$ to a handle& -- and
>back again? Something like: Given a string, how does one make a handle for
>it? And, given a handle, how does one create a string of its contents?
>
'Will run as is
LOCAL FN str2Hndl(@theStr&,theHndl&)
  LONG IF theHndl&
    size = PEEK(theStr&)
    err = FN SETHANDLESIZE(theHndl&,size)
    BLOCKMOVE theStr&+1,[theHndl&],size
  END IF
END FN

LOCAL FN hndl2Str(theHndl&,@theStr&)
  LONG IF theHndl&
    size = FN GETHANDLESIZE(theHndl&)
    IF size > 255 THEN size = 255
    POKE theStr&, size
    BLOCKMOVE [theHndl&],theStr&+1,size
  END IF
END FN

DIM myStr$,myNewStr$

myStr$ = "  It works. Click to end."
myHndl& = FN NEWHANDLE(0)
LONG IF myHndl&
  FN str2Hndl(myStr$,myHndl&)
  FN hndl2Str(myHndl&,myNewStr$)
  PRINT myNewStr$
END IF

DO
UNTIL FN BUTTON

DEF DISPOSEH(myHndl&)

 0"0
 =J= a  y
  "