Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
Chaumaret
- Posts: 4
- Joined: Mon Aug 10, 2009 2:14 pm
Post
by Chaumaret » Fri Aug 14, 2009 10:18 am
Hello (again :lol)
In this code :
Code: Select all
ask file "Export picture as:" with type "JPEG File|jpg|JPEG" or type "GIF File|gif|GIFf"
put it into trep
answer trep
answer trep give only the name of file, not the name with the choice.
ex : foo (only) and not foo.gif if I choose .gif in ask dialog.
Could you help me please ? (I'm sure).
Thanks

-
bn
- VIP Livecode Opensource Backer

- Posts: 4171
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Fri Aug 14, 2009 10:39 am
Hello Chaumare again,
the type is in the result, you have to provide the .xxx extension yourself in case the user did not do it. You have to test for it.
try
Code: Select all
on mouseUp pMouseBtnNo
ask file "Export picture as:" with type "JPEG File|jpg|JPEG" or type "GIF File|gif|GIFf"
put the result into tType
put it into trep
answer tType & cr & cr & trep
end mouseUp
regards
Bernd
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Fri Aug 14, 2009 12:33 pm
Hi Chaumaret,
The problem here is that Revolution's save file dialog doesn't automatically check for the file extension. If the user types "myfile.gif" in the filen name field in the dialog, the result may contain JPEG. You'll have to check both the result and the file name. Personally, I wouldn't warn the user if an inconsistent choice has been made. I'd just let the file name prevail.
Code: Select all
constant dot = "."
on mouseUp pMouseBtnNo
ask file "Export picture as:" with type "JPEG File|jpg,jpeg|JPEG" or type "GIF File|gif|GIFf"
put the result into rslt
set the itemDel to dot
if last item of it is "gif" or last item of it is among the items of "jpeg.jpg" then
put it into trep
put last item of it into tType -- this type is different from Bernd's script
else if rslt contains "gif" then
put it into trep
put "gif" into tType -- this type is different from Bernd's script
else if rslt contains "jpeg" then
put it into trep
put "jpg" into tType -- this type is different from Bernd's script
end if
answer tType & cr & cr & trep
end mouseUp
Best,
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