[futurebasic] Re: [FB] file paths

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

From: Robert Covington <artlythere@...>
Date: Thu, 17 Jan 2008 17:00:29 -0500
If you are using the  Files$ dialog to get the user's choice, it  
should ask if you wish to replace it when they choose the same one?

For knowing otherwise, if you have a known, FSSpec,  or Path, or the  
various components of non-fspec'ness (deprecated working directory  
numbert/etc) you can use:

exists =  USR FSFileExists(fspec) or
exists =  USR FileExists(blah blah blah)

If you wish to append to the end of a file, add to it, and not  
overwrite it, you can use the Open "A" method. Open "O" will  
overwrite things.

FB's file methods are behind the times for filtering and such via the  
typelist these days, you usually need to use a nav services callback  
to get best results, but here's the general methods.

// User has chosen File Menu Open or Save
dim fname$
dim mySpec as FSSpec

// Open (Text files in this case, for everything... use "" )
fName$ = Files$(_FSSpecOpenPreview,"TEXT", "Choose a file...",mySpec)

// Save
Def Open "TEXTCRTR" // Text file type, your app's creator code (can  
get via Apple)
fName$ = Files$(_FSSpecSave,"Choose a filename to  

Open "O",1,@mySpec
Print #1,"Here we are"
Close #1


Open "A",1,@mySpec
Print #1,"Here we are again (and again if we reopen)"
Close #1


On Jan 17, 2008, at 4:32 PM, Robert wrote:

> Hi group
> I am getting great success with many things but I am seriously hung  
> up on two issues.
> I have written a program that creates a file and opens it and then  
> I print some text and numbers to the file and then it closes. Works  
> great but if the file exists it is overwritten. Is there a method  
> of checking for the existence of the file you are about to open so  
> that the user can be asked if the overwrite is ok or to bail out?
> I can open file menus but all I can get out of these  is a file  
> name, or directory name but not a complete path name so my output  
> files are created only in the directory from which the program is run.
> Aw gee, guys please don't tell me it takes a long program segment  
> to do this lol.
> And big thanks for putting up with my many questions, I am spending  
> a lot of effort to figure out things by myself, honest.
> Robert
> --
> To unsubscribe, send ANY message to: futurebasic- 
> unsubscribe@...