Page 1 of 1
add a path parameter to the files and folders functions
Posted: Thu Sep 26, 2013 3:06 am
by monte
Hi
Do others think it would be useful to add a relative/absolute path parameter to the files and the folders functions? Personally I think it would be nice not to need to mess with the folder all the time.
Cheers
Monte
Re: add a path parameter to the files and folders functions
Posted: Thu Sep 26, 2013 3:37 am
by Simon
Hi Monte,
Does this mean get rid of (or not having to use) "put the effective filename of this stack..."
If yes, then I'm all for it!
Simon
Re: add a path parameter to the files and folders functions
Posted: Thu Sep 26, 2013 3:41 am
by monte
It means not having to:
Code: Select all
put the folder into tCurrentFolder
set the folder to tSomeOtherFolder
-- do something with the files or folders
set the folder to tCurrentFolder
Re: add a path parameter to the files and folders functions
Posted: Thu Sep 26, 2013 1:41 pm
by Klaus
monte wrote:It means not having to:
Code: Select all
put the folder into tCurrentFolder
set the folder to tSomeOtherFolder
-- do something with the files or folders
set the folder to tCurrentFolder
YES, I want that!
Maybe something like this:
...
put the files of folder "path/to/folder" into tFiles
...
Re: add a path parameter to the files and folders functions
Posted: Thu Sep 26, 2013 9:54 pm
by monte
I think functions can only have one parameter in the "the... of..." form. So it would just be:
Code: Select all
put the files of "path/to/folder"
or
put files("path/to/folder")
Re: add a path parameter to the files and folders functions
Posted: Thu Sep 26, 2013 10:27 pm
by FourthWorld
monte wrote:I think functions can only have one parameter in the "the... of..." form...
...until we arrive in a saner world where using "sometimes" rules allowing function calls with property syntax is disallowed (sorry, HyperCard team, you screwed up there. <g>).
More seriously, as long as we're exploring ways to avoid having to change the directory to file operations, perhaps we could have some means of obtaining the "detailed files" info for a single file in one line?
e.g.:
get fileInfo(tSomeFilePath)
...would return an array with the elements currently included in the items of "the detailed files".
Re: add a path parameter to the files and folders functions
Posted: Thu Sep 26, 2013 11:30 pm
by monte
Well arguably the files of a folder is a property of the folder so it works sometimes...
I like your idea of a function for details. Returning an array also means there's no need to urlEncode the name.
Re: add a path parameter to the files and folders functions
Posted: Tue Oct 01, 2013 8:00 pm
by mwieder
I think you may have the add the companion functions:
Code: Select all
put the [detailed] files of <pathToFolder>
put the [detailed] folders of <pathToFolder>
put the fileInfo of <pathToFile>
put the folderInfo of <pathToFolder>
and I have mixed feelings about returning detailed info in an array. What would the structure look like (assuming a hash rather than a numeric array)? This gets messy cross-platform.
Re: add a path parameter to the files and folders functions
Posted: Tue Oct 01, 2013 8:14 pm
by FourthWorld
mwieder wrote:and I have mixed feelings about returning detailed info in an array. What would the structure look like (assuming a hash rather than a numeric array)? This gets messy cross-platform.
IIRC there are 11 items in each line returned from "the detailed files", all but the last of which (Mac creator and type code) are currently provided for all platforms.
The keys could be:
name
size
resourceSize (Mac only; 0 for all others, as it is now)
created
modified
accessed
backedup
permissions
owner
group
creatortype
The only value I would change from its form in "the detailed files" would be the name - in "the detailed files" it's URL encoded only to prevent commas from mucking with parsing, and it would simplify things if the file name were provided as-is.
Re: add a path parameter to the files and folders functions
Posted: Tue Oct 01, 2013 9:34 pm
by mwieder
Cool. That looks pretty clean to me.
Re: add a path parameter to the files and folders functions
Posted: Tue Oct 01, 2013 10:53 pm
by monte
What about fileDetails?
Re: add a path parameter to the files and folders functions
Posted: Tue Oct 01, 2013 11:01 pm
by mwieder
fileDetails is good by me. I also like the fact that returning an array allows for flexibility in terms of adding more details in the future as appropriate without breaking the way the function works.