[futurebasic] Re: [FB] Long Strings revisited

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

From: Sean -G3- <mclaughlin@...>
Date: Mon, 14 Jun 99 22:27:08 -0400
Sorry about that, I just fixed it. I spent hours on it, but didn't fix it 
until right after I posted a message to an entire newsgroup...

With the "Why isn't array(0) working with 'Arrays without element zero' 
option on?", that makes two bogus posts. Oh well, I'll make some good out 
of it. Heres the revised source which works, for anyone interested in 
edit field text manipulation:
I'm not sure why, but I didn't have to lock down the handle for FN 
saveDay.

LOCAL FN saveDay
  DIM editFieldHandle&, pointer&
  DIM char%, length%, saveState%, osErr%, count
  
  'Set the long string ID in order to write to it
  gLongStringID = gDate
  
  'Get the edit field handle, and some info from it
  editFieldHandle& = TEHANDLE(2)
  length%  = editFieldHandle&..teLength%
  pointer& = PEEK LONG(editFieldHandle&..teTextH&)
  
  FOR count = 0 TO (length%-1)
    char% = PEEK(pointer&+count)
    FN putChar(char%)
  NEXT
  
END FN

CLEAR LOCAL
LOCAL FN readDay
  DIM theHoriz, theVert
  DIM longStringSize, saveState%, osErr%, pointer&
  DIM char%, temp$

<snip>

  gLongStringID = gDate
  
  'Save the handle state, then lock it
  saveState% = FN HGETSTATE(gStringH&(gLongStringID))
  osErr% = FN HLOCK(gStringH&(gLongStringID))
  
  'Get a pointer to the locked-down handle
  pointer& = PEEK LONG( gStringH&(gLongStringID) )
  
  'Get the long string size
  longStringSize = PEEK WORD (pointer&)
  INC(longStringSize)
  
  'Read the long string into the edit field
  EDIT$(2) = ""
  FN appendWithHandle(pointer&+2,longStringSize,2)
  'EDIT$(2) = STR$(longStringSize)
  
  'Return the state of the handle
  osErr% = FN HSETSTATE(gStringH&(gLongStringID),saveState%)

END FN

>I'm now trying to do some stuff with a calender. There are 31 dates, each 
>of which have their own pointer to a block of long string data. When the 
>user clicks a date, the program simply displays the string.
>
>I have a function to read edit field data into a long string, and to 
>insert a long string into an edit field. I took Tedd's Long Strings and 
>added a (gLongStringID) to all global variables. I made a test program to 
>ensure that this works, and it did. I simply set the gLongStringID 
>variable before I call a long string function.
>
>This program gives me a Type 1 Error when I run it. The error goes away 
>when I REM out this line:
>current& = [textHandle&] + count + 2
>
>Any help is appreciated.