add a path parameter to the files and folders functions

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

add a path parameter to the files and folders functions

Post by monte » Thu Sep 26, 2013 3:06 am

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
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: add a path parameter to the files and folders functions

Post by Simon » Thu Sep 26, 2013 3:37 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: add a path parameter to the files and folders functions

Post by monte » Thu Sep 26, 2013 3:41 am

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
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: add a path parameter to the files and folders functions

Post by Klaus » Thu Sep 26, 2013 1:41 pm

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! :D

Maybe something like this:
...
put the files of folder "path/to/folder" into tFiles
...

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: add a path parameter to the files and folders functions

Post by monte » Thu Sep 26, 2013 9:54 pm

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")
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: add a path parameter to the files and folders functions

Post by FourthWorld » Thu Sep 26, 2013 10:27 pm

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".
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: add a path parameter to the files and folders functions

Post by monte » Thu Sep 26, 2013 11:30 pm

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.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: add a path parameter to the files and folders functions

Post by mwieder » Tue Oct 01, 2013 8:00 pm

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.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: add a path parameter to the files and folders functions

Post by FourthWorld » Tue Oct 01, 2013 8:14 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: add a path parameter to the files and folders functions

Post by mwieder » Tue Oct 01, 2013 9:34 pm

Cool. That looks pretty clean to me.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: add a path parameter to the files and folders functions

Post by monte » Tue Oct 01, 2013 10:53 pm

What about fileDetails?
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: add a path parameter to the files and folders functions

Post by mwieder » Tue Oct 01, 2013 11:01 pm

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.

Locked

Return to “Engine Contributors”