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

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

From: tedd <tedd@...>
Date: Thu, 27 May 1999 08:59:42 -0400
tedd said:

>>Next question: How does one grab a hunk of memory that's capable of
>>holding, let' say, 400 charcters?
>
>Back to the original question:
>handle& = FN NEWHANDLE _clear (fileSize&)
>should do it.

Correct-a-mundo, again! -- With three considerations:

1. Where filesize& = 400

2. Considering that 400 is far less than the range for the variable
"filesize&", I would have simply used an integer variable, namely
"filesize%";

3. Last, but most important, you have asked for a Handle. You could have
asked for a pointer NEWPTR which would have answered the question more
simply.

>However, I'm not sure what the _clear part is; thats not in
>the help file.

The _clear part, as I understand it, will change every byte in your
allocation to zero. If you don't do the _clear thing; and you have
reclaimed some memory that had something in it before; then that portion of
memory will still have data remaining. (See page 377 of the Handles and
Pointers section of the FB Handbook.)

Now, back to the lesson.

After obtaining a chunk of memory, through NEWHANDLE or NEWPTR, you now
have that chunk of memory for you do use as you want. That means that
nothing in the operating system of anything else will use that memory for
anything. That block of memory is yours.

However, the only way for you to find your new memory block is via its
pointer. If you have allocated the memory via a FN NEWPTR, then you have
the pointer. If you allocated that memory via FN NEWHANDLE, then you still
have the pointer, but you have an additional step to get at it
(dereference). In FB you use brackets "[xxx]".

Now, with that said, the next question:

How do you put stuff in that memory block? Please give examples of using
both a pointer and a handle.

tedd

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