ask file - user selected type

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Weasel73
Posts: 15
Joined: Wed Jan 31, 2007 2:57 am

ask file - user selected type

Post by Weasel73 » Sun Mar 11, 2007 6:58 pm

Is there a way to determine the user selected format of the types provided to the ask file command?

I'm trying to make a "save as" option for exporting data tables. I know I can work around the issue if there is not a way of getting the selection from the ask file dialog, but it would be simpler for my users to use the ask file dialog types.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Mar 11, 2007 7:08 pm

Dear Weasel,

IIRC, the result contains the data type selected by the user.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Weasel73
Posts: 15
Joined: Wed Jan 31, 2007 2:57 am

Post by Weasel73 » Sun Mar 11, 2007 7:45 pm

That is what I thought at first, but I'm unable to get this information from the result. Do you have an example?

Here is what I'm testing with:

ask file "Please name the file:" with type "CSV File|csv|CSV" or type "TAB File|tab|TAB" as sheet

if it is empty then
answer "it is empty"
else
answer it
end if

"it" only contains the path and file name specified by the user. Selecting either format type doesn't appear to change anything. Is the selected format type stored somewhere else? Thanks.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Mar 11, 2007 7:50 pm

Dear Weasel73,

ask file "Please name the file:" with type "CSV File|csv|CSV " or type "TAB File|tab|TEXT" or type "TEXT File|txt|TEXT" as sheet
put the result into rslt
if it is not empty then
answer rslt & cr & it
else
answer "it is empty
end if

Kindest regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Weasel73
Posts: 15
Joined: Wed Jan 31, 2007 2:57 am

Post by Weasel73 » Sun Mar 11, 2007 7:55 pm

Mark, Thank you so much.

marielle
Livecode Opensource Backer
Livecode Opensource Backer

Post by marielle » Sun Mar 11, 2007 8:24 pm

Note that to check up information about file types, a posteriori, on Macs, you can always use detailed files or long files

From the docs:
The detailed files form returns a list of files, one file per line. Each line contains the following attributes, separated by commas:
* The file's name, URL-encoded
* The file's size in bytes (on Mac OS and OS X systems, the size of the file's data fork)
* The resource fork size in bytes (Mac OS and OS X systems only)
* The file's creation date in seconds (Mac OS, OS X, and Windows systems only)
* The file's modification date in seconds
* The file's last-accessed date in seconds (Unix and Windows systems only)
* The file's last-backup date in seconds (Mac OS and OS X systems only)
* The file's owner (Unix systems only)
* The file's group owner (Unix systems only)
* The file's access permissions
* The file's creator and file type (Mac OS and OS X only)
Any attribute that is not supported on the current system is reported as "0" (zero).

Post Reply

Return to “Talking LiveCode”