[futurebasic] Re: [FB] FSSpec: Folder in a Folder

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

From: Robert Covington <artlythere@...>
Date: Thu, 23 Sep 2004 12:57:30 -0400
On Thursday, September 23, 2004, at 12:42  AM, Darron Forehand wrote:

> Hi all.  I'm trying to make the switch to FSSpec from the old 
> volRefNum% in FB^3, and I'm just not getting it all after a number of 
> days of looking at/for samples and trial and error (mostly error).  
> This includes studying the FutureBasic Reference eDoc and the book 
> Switching to FutureBasic.  I know it must be easy and I'm ashamed to 
> say that it's just not clicking.
>
> More specifically, I've made a FSSpec from scratch (as opposed to 
> having the user make it--this is the way it needs to be done in this 
> case).  It creates a folder (inside the App's folder) and then saves a 
> file in that folder.  The problem I'm having is trying to create 
> another folder inside the first, and saving another file in it.  
> Hierarchically, it should look something like this:
>
> App Folder
> .....1st Folder
> ..........File 1
> .....2nd Folder
> ..........File 2
> .....3rd Folder
> ..........File 3
>
> etc.
>
> What I'm getting is this:
>
> App Folder
> .....1st Folder
> ..........File 1
> ..........File 2
> ..........File 3
> .....2nd Folder
>
> If anyone could help out, I would consider naming my thirdborn after 
> you. ;)  Thank you in advance.
>
> Darron Forehand


You need to go the cheesey easy route and use FOLDER, then follow that 
up with Fn FBMakeFSSpec, which takes workingDirectory reference number 
and does you right in Carbon.

Then you need to create a phony filespec and go with it.
This works here, is one way to approach it.

If it's a girl, call her Bobbie.

Robert




dim folderRef1,folderRef2,folderRef3
dim as FSSpec folderSpec1,folderSpec2,folderSpec3
dim as FSSpec fileSpec1,fileSpec2,fileSpec3
dim folderName1$, foldername2$,folderName3$
dim fileName1$,fileName2$,fileName3$
dim err

folderName1$ = "My Folder 1"
folderName2$ = "My Folder 2"
folderName3$ = "My Folder 3"

fileName1$  = "My File 1"
fileName2$  = "My File 2"
fileName3$  = "My File 3"


//You need to go the cheesey easy route and use FOLDER.

folderRef1 = Folder(FolderName1$,system(_aplvol))

//Folder 1 will be created if not found, otherwise you have it's vRef 
now.

folderRef2 = Folder(FolderName2$,folderRef1)

//Folder 2 will be created if not found, otherwise you have it's vRef 
now.

folderRef3 = Folder(FolderName3$,folderRef2)

//Folder 3 will be created if not found, otherwise you have it's vRef 
now.

//Now, you know the Folder and the names....

Err = Fn FBMakeFSSpec(folderRef1,0,folderName1$, folderSpec1) // Folder 
1 for example...

//For a file inside that , it should work to do this afterward:

Err = Fn FSMakeFSSpec(folderSpec1.vRefnum%, folderSpec1.parID&, 
fileName1$,fileSpec1)

Open "O",1,@fileSpec1
close #1

Err = Fn FBMakeFSSpec(folderRef2,0,folderName2$, folderSpec2)
Err = Fn FSMakeFSSpec(folderSpec2.vRefnum%, folderSpec2.parID&, 
fileName2$,fileSpec2)

Open "O",1,@fileSpec2
close #1

Err = Fn FBMakeFSSpec(folderRef3,0,folderName3$, folderSpec3)
Err = Fn FSMakeFSSpec(folderSpec3.vRefnum%, folderSpec3.parID&, 
fileName3$,fileSpec3)

Open "O",1,@fileSpec3
close #1

// rc