[futurebasic] Re: [FB] Reading Data into Containers

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2006 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Sun, 31 Dec 2006 15:21:17 -0700
On Dec 31, 2006, at 1:39 PM, maxclass@... wrote:

> Containers are something I have not used before.
> So, can one use code like the following to READ data into a  
> container. It does not appear to work.
No, that example won't work. Containers are managed handles. In the  
READ FILE statement the second parm (@gC in your example) must  
evaluate to pointer

> But, if I swap out a 255 string in place of "gC" and restrict the  
> bytes to read to 255 this code works fine. Why?
Because the address of the string is the pointer you need. @gC is not  
a pointer.

> Would it be a better solution to read all data into some handle  
> (pointer) instead (my preferred choice).
Yes, reading into a pointer or handle is the most flexible and there  
are published functions to do this. I would recommend the fns found  
in the Spell Check Demo in the Examples/*Donations*/folder. It will  
work for any text size and there are no limits. My own code uses a  
dynamic array of pointers (with each pointer referencing unlimited  
text data). If there is still a need to dump the pointer contents to  
a container (which should be unnecessary except it is any easy way to  
priint a container's contents),  the Pointer to Container example in  
the Examples/Container folder should suffice. The examples are NOT  
using FB edit fields but control-based edit fields (which is where  
code needs to be)

If you want to read a file into a handle there is a example script  
from Ken at the following menu item:  Tools-->Scripts-->Ken's  
Scripts  listed under FILE

I'm sending a small demo backchannel too.

HTH- Brian