[futurebasic] Re: [FB] File Open & Save again

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2004 : Group Archive : Group : All Groups

From: George Beckman <gbeckman@...>
Date: Mon, 4 Oct 2004 21:00:25 -0700
I will try to debug this, although I am not getting the errors you get 
as I don't have the whole thing.

----
Best Wishes,

George
http://www.pggp.com
On Oct 4, 2004, at 8:29 PM, Brian Heibert wrote:

> In the .main file:

If this is where you are getting the error, I don't understand.   This 
is a good line.   It must be the placement of this line.   FB requires 
you to declare before you use something.   Unless your main occurs 
before (in order) the incl file it won't work.

You may need it at the top of the INCL.   I make a separate globals 
file above the INCL

> Dim gFileSpec as FSSpec

this line is a good one.   I have about 5 of these in my big project.

>
> In the .incl file:
> '~File Management
>

This line is bad
> DIM gFileSpec
gFileSpec has already been declared and cannot be declared more than 
once.   If you do it because the compiler tells you you need to declare 
it, it is because it is not above this piece of code...(in the order of 
things)


> LOCAL FN loadSTR$(ID)
> txt$ = ""
> rHndl& = FN GETRESOURCE(_"STR ",ID)
> LONG IF rHndl&
> txt$ = PSTR$([rHndl&])
> END IF
> END FN=txt$
>
> LOCAL FN SaveDoc
> savprompt$ = FN loadSTR$(135)
> filnm$ = FN loadSTR$(136)

I would use

filename$=Files$(_fsspecSave,"tbd~",,gFileSpec)

> // File Type: tbd~
> fileName$ = FILES$(_fSave,savprompt$,filnm$,vRefNum%)
> LONG IF LEN(filename$)

This next line is too late.   It only has effect on the FILE$ statement 
above
> gFBUseNavServices = _zTrue

The next line can not happen because if fileName is "" you won't get 
past the Long if LEN line above.
> if filename$ = "" then filename$ = filnm$

This is also too late.   This was taken care of inthe FILES$ line.
> DEF OPEN "tbd~"

THis one is where you are mixing the methods
> //OPEN "O",1,filename$,,vRefNum%
I would use

> OPEN "O",1, @gFileSpec

> GET FIELD efHandle&, efID%
> WRITE FIELD #8001, efHandle&
> CLOSE #1
> KILL FIELD efHandle&
> END IF
> END FN
>
> LOCAL FN OpenDoc

Good
> filename$=Files$(_fsspecOpen,"tbd~",,gFileSpec)

If you want the folder to open in a certain place you would need this 
line before FILES$
> gFBUseNavServices = _zTrue
But that alone won't do it.   We can work on this later.

> DEF OPEN "tbd~"
> LONG IF LEN(filename$)
Both of the following are remmed out...but I figure you will remove the 
// from one.
> //OPEN "I",1, @gFileSpec
> //Open "I",1,@gFileSpec
>
> READ FIELD #8001, efHandle&
> EDIT FIELD #8001, &efHandle&
> CLOSE #1
> KILL FIELD efHandle&
>
> XELSE
> BEEP
> END IF
> END FN