[futurebasic] Re: [FB] Long Strings revisited

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

From: tedd <tedd@...>
Date: Tue, 15 Jun 1999 13:59:11 -0400
>Sean,
>
>Congratulations on getting your code to work. As long as it does work,
>you may not want to mess with it any more, but in the interests of clean,
>efficient programming, I invite you to revisit this loop:
>
>>  FOR count = 0 TO (length%-1)
>>    char% = PEEK(pointer&+count)
>>    FN putChar(char%)
>>  NEXT
>>
>You don't include FN putChar in your posted code--is it one of Tedd's?
>Anyway, it should be easy to write a FN putStr(pointer,length) that would
>BLOCKMOVE your string from the edit field handle. IF you're interested,
>and would like some help in doing that, send me a copy of FN putChar and
>I'll see what I can do.
>
> 0"0
> =J= a  y

=J= a  y:

True, the FN putChar(char%) function is one that I wrote. It simply places
a character in a block of memory. The function also checks to see if there
is enough memory available in the current block. If there is, then it adds
the character to the block. If not, then it grabs a larger hunk of memory.
I found that doing it this way was faster than grabbing exact memory as
needed. On the old 68000 machines, it is very slow to do it that way.

To get a long string from it's handle to an edit field I use this:

strH& = FN NEWHANDLE _clear (400)                 '*** creates a new block
BLOCKMOVE [gStringH&],[strH&],stringLength
'--- the first two bytes of a ZTEXT is the length of the TEXT
POKE WORD [strH&], stringLength - 2
'--- set the Handle size to the "real" size
err = FN SETHANDLESIZE(strH&,stringLength)
EDIT$(theFld) = &strH&
teH& = TEHANDLE(theFld)
CALL TEDEACTIVATE(teH&)
DEF DISPOSEH(strH&)                               '*** disposes of the new
block


Where: gStringH& is the handle of the long string.
       strH& is a handle of a temporary string.
       stringLength is the length of the string (what else)

tedd






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