Ask file "selected filter" expression.

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

Post Reply
boqsc
Posts: 12
Joined: Mon Nov 11, 2013 5:13 pm

Ask file "selected filter" expression.

Post by boqsc » Fri Dec 06, 2013 4:12 pm

So after some hours of searching around forum and google i decided to make a thread here.
The simple thing i want to do is just change file name extension depending on selected file filter (.exe, .zip, etc) while saving it with ask dialog script.
However, have stuck here for a while, so any help will be appreciated.
Attachments
Ekrano kopija (6-ed).png

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

Re: Ask file "selected filter" expression.

Post by Klaus » Fri Dec 06, 2013 5:01 pm

Hi boqsc,

sorry, don't understand what you are looking for!?


Best

Klaus

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Ask file "selected filter" expression.

Post by SparkOut » Fri Dec 06, 2013 6:50 pm

On Windows

Code: Select all

ask file "What to save?:" with "My_File_Default_Name" with filter "Skript script,*.sk,JPEG,*.jpg,zip,*.zip"
The file type will be pre-populated with Skript script (*.sk) and you can choose to change to JPEG (*.jpg) or zip (*.zip)
You can put other pairs of "type,*.ext" filters as you see fit. Default filename is optional.

boqsc
Posts: 12
Joined: Mon Nov 11, 2013 5:13 pm

Re: Ask file "selected filter" expression.

Post by boqsc » Fri Dec 06, 2013 7:45 pm

Klaus wrote:Hi boqsc,

sorry, don't understand what you are looking for!?


Best

Klaus
No problem. It's mainly my fault.
SparkOut wrote:On Windows

Code: Select all

ask file "What to save?:" with "My_File_Default_Name" with filter "Skript script,*.sk,JPEG,*.jpg,zip,*.zip"
The file type will be pre-populated with Skript script (*.sk) and you can choose to change to JPEG (*.jpg) or zip (*.zip)
You can put other pairs of "type,*.ext" filters as you see fit. Default filename is optional.
Well i done it already before this thread:

Code: Select all

on mouseDown
   
end mouseDown

on menuPick theitem
   If theItem is "New script" then 
      If field "Code Field" is not empty then
         answer "Script is not save. Do you want to save it?" with "No" or "Yes"
      end if
   end if
      
      If theItem is "Open script" then
         answer file "Please choose script that will be loaded..." with type "Skript Script|sk" or type "Text File|txt"
      end if
      
      If theItem is "Save As..." then 
         ask file "Please choose a directory, where the script will be saved..."  with "Script.sk"  with type "Skript Script|sk" or type "Text File|txt"
         if the result is not "cancel" then
            if it ends with "sk" then
               open file it for write -- creates a file for Revolution to write to
               write Field "Code Field" to file it
               close file it 
            end if
         end if
      end if
      

end menuPick
But the problem is that when i set/change the file type in "Save as type", the output file extension didn't change...
Any ideas on how to change the output file extension using "Save as type"?
Later. when i have some more time - i make some pictures, that will make everything brighter, cause, for me it's hard to explain it in english language. :?

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Ask file "selected filter" expression.

Post by SparkOut » Fri Dec 06, 2013 8:25 pm

Ah, you want the filename to populate with "script.sk" and if the user changes the file extension type to "text (*.txt)" then you want the filename to change to "script.txt" right?
As far as I know, this is impossible.

boqsc
Posts: 12
Joined: Mon Nov 11, 2013 5:13 pm

Re: Ask file "selected filter" expression.

Post by boqsc » Sat Dec 07, 2013 9:37 am

SparkOut wrote:Ah, you want the filename to populate with "script.sk" and if the user changes the file extension type to "text (*.txt)" then you want the filename to change to "script.txt" right?
As far as I know, this is impossible.
Exactly! Too bad but i think the same... Is it even possible to see any way to do this in the future? :|

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Ask file "selected filter" expression.

Post by bidgeeman » Tue Aug 08, 2017 4:43 am

Posted in wrong thread. Sorry.
Bidge

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”