Page 1 of 1

Ask file "selected filter" expression.

Posted: Fri Dec 06, 2013 4:12 pm
by boqsc
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.

Re: Ask file "selected filter" expression.

Posted: Fri Dec 06, 2013 5:01 pm
by Klaus
Hi boqsc,

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


Best

Klaus

Re: Ask file "selected filter" expression.

Posted: Fri Dec 06, 2013 6:50 pm
by SparkOut
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.

Re: Ask file "selected filter" expression.

Posted: Fri Dec 06, 2013 7:45 pm
by boqsc
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. :?

Re: Ask file "selected filter" expression.

Posted: Fri Dec 06, 2013 8:25 pm
by SparkOut
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.

Re: Ask file "selected filter" expression.

Posted: Sat Dec 07, 2013 9:37 am
by boqsc
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? :|

Re: Ask file "selected filter" expression.

Posted: Tue Aug 08, 2017 4:43 am
by bidgeeman
Posted in wrong thread. Sorry.
Bidge