[futurebasic] Re: [FB] Edit Fields, Strings

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

From: tedd <tedd@...>
Date: Sun, 30 May 1999 13:12:47 -0400
>>Now, back to the original question -- using POKE is one way to get to the
>>memory  you want. It makes no sense to create a block of memory that you
>>can't use -- in other words, store and retrieve stuff.
>>
>>So, next question: How do you store the string "This is text!" into a block
>>of memory? Please give an example.
>>
>>tedd
>
>
>handle& = FN NEWHANDLE _clear (fileSize&)
>pointer& = [handle&] 'Right?
>PTRSTR$(pointer&) = "This is text!"
>
>
>or
>
>string$ = "This is text!"
>handle& = FN NEWHANDLE _clear (fileSize&)
>length = len(string$)
>
>for count = 1 to length
>  temp$ = right$( left$(string$,count), 1)
>  ascii = asc(temp$)
>  poke handle&, ascii
>next


Well... kind of. Look at the following code and see how it works.

'--- will run "as is" ---

COMPILE  0,_dimmedVarsOnly

DIM RECORD mThing
  DIM recString$
DIM END RECORD .mThingSize

DIM gTheH&
DIM gMyString&

END GLOBALS

'--------------------------

LOCAL FN buildWind
  WINDOW 1,"test",(0,0)-(300,200),_doczoom
END FN

'--------------------------

LOCAL FN doRecordThing
  DIM handle&
  DIM pointer&
  DIM fileSize&
  DIM a$

  fileSize& = 400
  gTheH& = FN NEWHANDLE _clear (fileSize&)
  gMyString& = [gTheH&]
  gMyString&.recString$ = "This is text!"

END FN

'--------------------------

LOCAL FN doPokeThing
  DIM myString$
  DIM handle&
  DIM length
  DIM count
  DIM ascii
  DIM fileSize&
  DIM temp$

  fileSize& = 400
  myString$ = "This is text!"
  gTheH& = FN NEWHANDLE _clear (fileSize&)
  length = LEN(myString$)

  FOR count = 1 TO length
    temp$ = RIGHT$( LEFT$(myString$,count), 1)
    ascii = ASC(temp$)
    POKE [gTheH&] + count, ascii
  NEXT

END FN

'--------------------------
LOCAL FN showStuff
  DIM myPointer&
  DIM i
  DIM ascii

  FN doRecordThing
  PRINT gMyString&.recString$
  DEF DISPOSEH(gTheH&)
  PRINT

  FN doPokeThing
  FOR i = 1 TO 15
    ascii = PEEK([gTheH&]+i)
    PRINT CHR$(ascii);
  NEXT
  DEF DISPOSEH(gTheH&)
  PRINT

END FN

'--------------------------

"MAIN"
DIM a$

FN buildWind
FN showStuff
PRINT

INPUT"Enter anything to end";a$

END



___________________________________________________________________
<mailto:tedd@...>	               http://sperling.com/