[futurebasic] Re: [FB] Re: Writing to a text file

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

From: Bernie Wylde <bernie.w@...>
Date: Thu, 17 Jul 2003 09:48:36 +0100
On Thursday, Jul 17, 2003, at 08:32 Europe/London, Joe Lewis Wilkins 
wrote:
>
> When you click on the Open Text File Button and then Cancel the 
> subsequent Open Dialog, an inappropriate action follows, so I've 
> modified the following: (I ADDED TWO LINES IN THE FIRST FN AND 3 LINES 
> IN THE NEXT ONE.)
> .....
>

On the other hand, if you don't like the idea of setting and re-setting 
the global gFBQuit you could return a 'file opened' flag from:

// Open file, load text into container
local mode
local fn OpenTextFileToContainer( @CPtr as ptr )
dim as FSSpec  f
dim as long    size
dim as boolean flag     //ADDED LINE

flag = _false     //ADDED LINE
long if len( files$( _FSSpecOpen, "TEXT", "Open file to parse", f ))
flag = _zTrue     //ADDED LINE
if CPtr.nil& then DisposeHandle( CPtr.nil& ) : CPtr.nil& = _nil
on error end
open "I", #1, @f
size = lof( 1, 1 )
long if error = _noErr and syserror = _noErr and size > 0
CPtr.nil& = Fn NewHandle( size )
long if fn MemError = _noErr and CPtr.nil& != _nil
HLock( CPtr.nil& )
read file #1, [CPtr.nil&], size
HUnlock( CPtr.nil& )
long if error != _noErr or syserror != _noErr
DisposeHandle( CPtr.nil& ) : CPtr.nil& = _nil
end if
xelse
long if CPtr.nil&
DisposeHandle( CPtr.nil& ) : CPtr.nil& = _nil
end if
end if
end if
close 1
error = _noErr : syserror = _noErr
on error return
end if

end fn = flag     //AMENDED LINE


and check it:

local fn LaunchProgram
kill dynamic splitArray
kill dynamic arrayB
appearance button 3,,0
edit$(1) = ""
edit$(2) = ""
long if fn OpenTextFileToContainer( gC )     //AMENDED LINE
fn CaseAndPunctuation( 4, 5)
fn SplitAndSortArray
end if     //ADDED LINE
appearance button 3,,0
end fn


Thanks for a great utility, Ken

Bernie