[PD] abstraction's knowledge of parent's path

David Sabine dave at davesabine.com
Fri Nov 8 04:26:39 CET 2002


hello all,

Wow, this opens a big can of worms in my mind.

For instance, I'm currently working on a PD patch that writes numerous sound
files to the hard drive (each file name is created via a counter: i.e.
1.wav, 2.wav, 3.wav etc.)

When I close and reopen the patch, I'd sure like to be able to look on the
hard drive for the most recent file, then begin where I left off.  Example,
if "159.wav" was the last file written to the drive, then this new session
would start at "160.wav".

As it is now, I've considered logging the filenames in a text file via
[textfile] or [qlist], then open the log each time PD opens.  If I could
bypass this step, then my life would be a "little" simpler.

Hello all,


See, I've been thinking for some time that it would be VERY handy if PD had
an object available that would allow PD to respond with information about
the file system.  MAX has some objects for this purpose, like;

[absolutepath]
[filedate]
[filein]
[filepath]
[relativepath]

I'm not certain that those objects would suffice, but I think they're
definately a move in the right direction.


I'm very comfortable with the VBScript objects for manipulating files and
I've cppied the various methods of the "FileSystemObject" below.
(cut-n-pasted from www.devguru.com below).  The basic gyst of it is this
simple.  There is a file system object which will return collections (as
arrays) of drives, folders, files.  Each collection has certain properties,
such as "count" and "size" and "name"...then each element in the collections
has more properties: such as "date", "size", "type", "name", etc.


Drives Property
Returns a Drives collection consisting of all the Drive objects on a
computer.

Syntax: [drvcollection = ] object.Drives

METHODS

BuildPath Method
This method is used to append a name onto an existing path.

[newfullpath = ]object.BuildPath(path, name)

CopyFile Method
This method allows us to copy one or more files from one location (the
source) to another (destination).

Syntax: object.CopyFile source, destination [, overwrite]

CopyFolder Method
Copies one or more folders and all contents, including files and subfolders,
from one location to another.

Syntax: object.CopyFolder source, destination, [, overwrite]

CreateFolder Method
This method allows us to create a folder.

Syntax: object.CreateFolderfoldername

CreateTextFile Method
Creates a text file and returns a TextStreamObject that can then be used to
write to and read from the file.

Syntax: object.CreateTextFile filename [, overwrite[, unicode]]

DeleteFile Method
This method deletes a specified file or files (using wilcards).

Syntax: object.DeleteFile file [, force]

DeleteFolder Method
This method deletes a specified folder, including all files and subfolders.

Syntax: object.DeleteFolder folder [, force]

DriveExists Method
This method lets us check if a specified drive exists. It returns True if
the drive does exist and False if it doesn't.

Syntax: object.DriveExists(drive)

FileExists Method
Lets us check whether a specified file exists. Returns True if the file does
exist and False otherwise.

Syntax: object.FileExists(file)

FolderExists Method
Allows us to check if a specified folder exists. Returns True if the folder
does exist and False if it doesn't.

Syntax: object.FolderExists(folder)

GetAbsolutePathName Method
This method gets the complete path from the root of the drive for the
specified path string.

Syntax: object.GetAbsolutePathName(path)

GetBaseName Method
This method gets the base name of the file or folder in a specified path.

Syntax: object.GetBaseName(path)

GetDrive Method
This method returns a Drive object corresponding to the drive in a supplied
path.

Syntax: object.GetDrive(drive)

GetDriveName Method
This method gets a string containing the name of the drive in a supplied
path.

Syntax: object.GetDriveName(path)

GetExtensionName Method
Used to return a string containing the extension name of the last component
in a supplied path.

Syntax: object.GetExtensionName(path)

GetFile Method
Returns the File object for the specified file name.

Syntax: object.GetFile(filename)

GetFileName Method
This method is used to return the name of the last file or folder of the
supplied path.

Syntax: object.GetFileName(path)

GetFileVersion Method
This method is used to return the version of the file in the specified path.

Syntax: object.GetFileVersion(path)

GetFolder Method
This method returns a Folder object fo the folder specified in the folder
parameter.

Syntax: object.GetFolder(folder)

GetParentFolderName Method
Returns a string containing the name of the parent folder of the last file
or folder in a specified path.

Syntax: object.GetParentFolderName(path)

GetSpecialFolder Method
Returns the path to one of the special folders - \Windows, \System or \TMP.

Syntax: object.GetSpecialFolder(folder)

GetTempName Method
This method is used to generate a random filename for a temporary file..

Syntax: object.GetTempName

MoveFile Method
Moves one or more files from one location to another.

Syntax: object.MoveFile source, destination

MoveFolder Method
Moves one or more folders from one location to another.

Syntax: object.MoveFolder source, destination

OpenTextFile Method
Opens the file specified in the filename parameter and returns an instance
of the TextStreamObject for that file.


regards,
Dave Sabine




----- Original Message -----
From: "David McCallum" <8dngm at qlink.queensu.ca>
To: <pd-list at iem.kug.ac.at>
Sent: Thursday, November 07, 2002 7:05 PM
Subject: [PD] abstraction's knowledge of parent's path


>
>          Is there any way for an abstraction to know the path of its
> parent? Like if the abstraction wanted to save a file in its parent's
path?
>
> David
>
>
> .
> . David McCallum
> .  Music wants to be free
> . http://mentalfloss.ca/sintheta/
> .
>
>
> _______________________________________________
> PD-list mailing list
> PD-list at iem.kug.ac.at
> http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
>






More information about the Pd-list mailing list