[futurebasic] Re: [FB] Working With Files

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2010 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Wed, 20 Jan 2010 16:50:38 -0700
On Jan 20, 2010, at 4:20 PM, Brian Stevens wrote:

>
> On Jan 20, 2010, at 3:22 PM, Max Taylor wrote:
>
>>
>> dim as pointer dataBufferPtr
>> ...
>> dataBufferPtr = fn NewPtrClear( 32767 ) //i.e. for instance
>> ...
>> read file # 1, @dataBufferPtr, lof( 1, 1 )
>>
>> If I can get the above lines to actually read the data into the  
>> buffer what would be the best way to show the file in a window?
>
> There are a few ways to tackle this Max. If your window has an  
> EditUnicodeTextControl ( EUTC ), it can be populated as shown below:
>
> xx = fn SetControlData( c, _kControlEditTextPart,  
> _kControlEditTextTextTag, fn GetPtrSize( dataBufferPtr ),  
> #dataBufferPtr )
>
> Where 'c' is the ControlRef/HIViewRef to the EUTC
>
> This is just one method for one type of control. There are many  
> other possibilities. My own shareware uses dynamic arrays of records  
> with an allocated pointer in each record for the data.
>
> It looks something like( Max knows this already but thought it might  
> give newcomes ideas ) :
> xx = fn SetControlData( c, _kControlEditTextPart,  
> _kControlEditTextTextTag, fn GetPtrSize( myRec.p( idx ),  
> #myRec.p( idx ) )
>
> where 'idx' is the element of the array of records and myRec.p is  
> the pointer and one of several fields within a record.

Just an example of options, the data could be in a CFString and  
HIViewSetText (HIViewRef inView, CFStringRef inText ) used to set the  
text in an EUTC. ( also see BW's recently posted 'CFAdditions' ( which  
will be in examples in the revision ) ). It takes only one call to  
move the data from the pointer to a CFString.


Brian S