[futurebasic] Re: [FB] Modernization of File Open code

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2009 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Sat, 4 Jul 2009 23:12:48 -0700
Several things to upgrade:

(1) FBtoC/FB5 does not support _fSave and _fOpen in Files$. Only  
FSSpecs, FSRefs and CFURLRefs are supported. Examples using the latter  
can be found ( like usual ) in FB5 examples

(2) The OPEN statements would need to be changed to correspond to  
whatever method is used in FIles$. Again, see examples.

(3) While FBtoC supports Get Field / Read Field, its implementation  
uses handles and CF and not textEdit as in the past. Edit Field ID, &h  
is not supported AFAIK ( Edit fields have limited support as posted  
earlier this week ).

These FNs would mostly need to be scrapped and rewritten and I would  
use something different if all you want to do is write/read text data.  
Most programs don't prompt users to write edit fields. How much data  
is being transferred ( i.e. always Str255 or less or unlimited )?  If  
less than Str255, just read into a pascal string and use Def  
SetButtonTextString( _yourEditField, yourString ) to set the EUTC  
( see my demo posted earlier this week ) and fn ButtonTextString$ 
( yourEditField ) to read data from the EUTC.

My own methods for data >  255 chars is to read the data into  
pointers  ( mallloc or NewPtr ) and manage it that way. Containers  
might work and you should read about them to learn more.

Brian S.






On Jul 4, 2009, at 9:22 PM, Brian Heibert wrote:

> I was trying to use this to open a text file and place the contents  
> in my appearance button edit field
> But I think this must be old code because it didn’t work
> Are there any modern examples out there?
>
> Brian
>
> Local Fn WriteEditField (EditID As Int)
> '---> Variables
> Dim @EditH   As Handle
> Dim FileName As Str63
> Dim @Vol     As Int
> '---> Write Edit Field
> FileName = Files$(_fSave,"Save Edit Field As…","Untitled",Vol)
> Long If Len(FileName)
> Def Open "EFFD"
> Open "O",1,FileName,,Vol
> Get Field EditH, EditID
> Write Field #1, EditH
> Close #1
> Kill Field EditH
> End If
> End Fn
>
> Local Fn ReadEditField (EditID As Int)
> '---> Variables
> Dim @EditH   As Handle
> Dim FileName As Str63
> Dim @Vol     As Int
> '---> Read Edit Field
> FileName = Files$(_fOpen,"EFFD",,Vol)
> Long If Len(FileName)
> Open "I",1,FileName,,Vol
> Read Field #EditID, EditH
> Edit Field EditID, &EditH
> Close #1
> Kill Field EditH
> End If
> End Fn
>
>
>
> =
> --
> To unsubscribe, send ANY message to: futurebasic- 
> unsubscribe@associate=
> .com
>
> =