Page 1 of 2
Solved!!! How to custom an open stack file???
Posted: Sun Apr 08, 2018 7:08 pm
by Fasasoftware
Dear friends,
I need to open a stack as my custom file....in other words i want only open a type of file...like .pippo
how i can do?? thanks a lot....
example code like this.....
Code: Select all
on mouseUp
answer file "A text file" with type ("text files|txt|tTXT" & return & "all files|*|*")
if it <> "" then
put it into theFilePath
put URL ("file:" & theFilePath) into field "text"
else
--no file was selected, or cancel was pressed
beep
end if
end mouseUp
here my bad script....
Code: Select all
on mouseUp
answer file "A custom file" with type (".pippo" & return & "all files|*|*")
if it <> "" then
put it into theFilePath
-----put URL ("file:" & theFilePath) into field "text"
Open thefilepath
else
--no file was selected, or cancel was pressed
beep
end if
end mouseUp
Thank a lot to everybody!!!
best regards,
Lestroso

Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 7:27 pm
by Klaus
Buonasera Lestroso,
not sure, but maybe you mean something like:
Code: Select all
...
if it <> "" then
put it into theFilePath
try
go stack thefilepath
if the result <> EMPTY then
answer "Looks like this is not a stack!"
end if
end try
end if
...
Best
Klaus
Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 7:35 pm
by Fasasoftware
Vielen Danke Klaus!!!
my idea for the script is a little different....i want with ask command see only a .pippo file...ok, stack...
but in the file when i choose the file i want see only .pippo .....because i want customize my main stack...
Thanks again....
Best regards,
Lestroso

Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 7:37 pm
by Klaus
Sorry, I have no idea what exactly you want to do?
Do you only want to allow .pippo files in the open dialog?
Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 7:57 pm
by bogs
IF Klaus is correct, and you *only* want to show pippo files, what you would shoot for is more like this -
Code: Select all
answer file "A custom file" with type ("Pippo files|pippo")
if it <> "" then
put it into theFilePath
Open thefilepath
else
--no file was selected, or cancel was pressed
beep
end if
Which would give you this:

- Selection_003.png (18.4 KiB) Viewed 8352 times
Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 8:15 pm
by sphere
Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 8:43 pm
by bogs
Good one sphere

Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 8:47 pm
by Klaus
Pipo <> pippo
The latter is a common italian (first) name, you jokers!

Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 8:51 pm
by Fasasoftware
Dear bogs,
i have tryed your script...but here nothing works....do you have an other ideas to try ????
in truth i want to make "catalog" as extension to open with livecode...
in other words i want only open a livecode stack file with my custom extension...
thanks a a lot..to everybody,
Lestroso

Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 8:56 pm
by Klaus
I just saved a stack with the suffix "*.pippo" and bogs' script worked as advertised!?
At least here on my Mac.
Re: How to custom an open stack file???
Posted: Sun Apr 08, 2018 10:17 pm
by bogs
Well, I tested it here on linux, mac and windows, and it worked, which leads me to suspect typographical error in naming your file, assuming of course that you copied the script I put up there and didn't type it in manually.
Fasasoftware wrote: ↑Sun Apr 08, 2018 8:51 pm
in truth i want to make "catalog" as extension to open with livecode...
in other words i want only open a livecode stack file with my custom extension...
The extension doesn't really matter, you could put anything. The part that filters out that particular extension is the part after the pipe symbol, which is what determines what file extensions will be shown.
So for example, if you put -
Code: Select all
answer file "A custom file" with type ("My marvelous custom files!!|mcf")
then you would only see files with an extension of ".mcf". If your extension is going to be uppercase, make sure you make it that after the piping symbol, or you won't see them. *.MCF is not *.mcf.
Same thing for the "pippo", if your file was ".Pippo" the script won't work until the extension is corrected.
Hope that was of some help.
Re: How to custom an open stack file???
Posted: Mon Apr 09, 2018 4:35 pm
by Fasasoftware
Dear friends,
nothing works here....i'm using livecode community 8.1.9 on my imac...but the code you gave me don't work!!
can you help me please??
i put here some type i have tryed...
Code: Select all
on mouseDown
-- answer file "A custom file" with type ("My marvelous custom files!!|pippo") --> Don't work!
--answer file "Give me a file with catalog extension..." with type ("catalog | catalog") --->Don't work!
--answer file "Give me a file with catalog extension..." with type ("catalog | CATALOG") --->Don't work!
-- answer file "prompt" with type "my catalog file |.catalog" --->Don't work!
--answer files "Select the images you wish to view:" with type "JPEG Images|jpg|JPEG"--> THis Work Fine!!
answer file "A custom file" with type ("Pippo files |pippo") ---> Don't work
if it <> "" then
put it into theFilePath
Open thefilepath
else
--no file was selected, or cancel was pressed
beep
end if
end mouseDown
best regards,
Lestroso

Re: How to custom an open stack file???
Posted: Mon Apr 09, 2018 4:56 pm
by Klaus
Just tested this snippet on LC 8.1.9 on my Mac:
...
answer file "A custom file" with type ("Pippo files |pippo")
put it into theFilePath
Open thefilepath
...
and it worked, sorry, no idea what is going wrong on your side...
Re: How to custom an open stack file???
Posted: Mon Apr 09, 2018 6:12 pm
by Klaus
Try this, maybe we get a hint then:
Code: Select all
...
if it <> "" then
put it into theFilePath
Open thefilepath
answer the result
...
Re: How to custom an open stack file???
Posted: Mon Apr 09, 2018 6:23 pm
by Fasasoftware
hi klaus,
i have mac os yosemite....10.10.5... perhaps there's a bug....i don't know why...
thanks in any way lestroso
