Jump to content

[BUG] FileSaveDialog extension


MyEarth
 Share

Recommended Posts

The return value is the path and file name including extension.

It's a very simple process to get the extension from that, and worth figuring out yourself if you cannot do it after over 2 years here.

StringInStr and StringMid

Or simple StringSplit will suffice.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Developers

Retrieve the extension from the returned file in variable $var by getting the right 4 characters or use

#include <WinAPIShPath.au3>
_WinAPI_PathFindExtension ( $sPath )

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

MyEarth,

The dialog does not add an extension automatically - you still need to do it manually. That is why you do not see an extension. And this is a Windows "feature" - nothing to do with AutoiI. ;)

You need to add some code like this to check if it has been done:

$var = FileSaveDialog("Choose a name.", @ScriptDir, "Scripts (*.au3)|Text files (*.txt)", 2, "MYNAME")
If @error Then
    MsgBox(4096, "", "Save cancelled.")
Else
    Switch StringRight($var, 4)
        Case ".txt", ".au3"
            ; Good extension
        Case Else
            $sExt = InputBox("Add extension", "Please add an extension: '.txt' or '.au3'")
            $var &= $sExt
        EndSwitch
    MsgBox(4096, "", "You chose " & $var)
EndIf
All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

No, i don't belive. Ok i need to set manually the extension and i know, it's not a problem to add $var & $extension

But how i can set it if i don't have any returned value about extension from the FileSaveDialog? How can i know if a user select Scripts (*.au3) or Txt (*.txt)? 

Don't tell me I need to make two dialog, one for filename and one for extension :ermm:

I don't have any extension in the returned value, only:

C:PathMYNAME

Edited by MyEarth
Link to comment
Share on other sites

  • Developers

No, i don't belive. Ok i need to set manually the extension and i know, it's not a problem to add $var & $extension

But how i can set it if i don't have any returned value from the FileSaveDialog? How can i know if a user select Scripts (*.au3) or Txt (*.txt)? 

Don't tell me I need to make two dialog, one for filename and one for extension :ermm:

And again, i don't have any extension in the returned value, only:

C:PathMYNAME

What is the filename you selected or typed in the FileSaveDialog() box?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

MyEarth,

No, i don't belive

Fine, then you are on your own as far as I am concerned. :bye:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

$var = FileSaveDialog("Choose a name.", @ScriptDir, "Scripts (*.au3)|Text files (*.txt)", 2, "MYNAME")
If @error Then
    MsgBox(4096, "", "Save cancelled.")
Else
    MsgBox(4096, "", "You chose " & $var)
EndIf

2chpa2r.jpg

ip1vsm.jpg

What is the sense to make a multiple choice when i don't know what is the choice? That's all i what to know, what is the extension selected in the combobox and then i'll add it for save the file ( as i have say at the first post two different function based on that choice )

Edited by MyEarth
Link to comment
Share on other sites

Starg thanks that WinAPI function return the extension based on the combobox so without any other solution using the internal FileSaveDialog i'll use that.

But i think ( my opinion, without any offence for anyone ) Jos need to add to the internal FileSaveDialog the extension return value or is useless to add a multiple choice because i don't know what is the user choice from the combobox.

Edited by MyEarth
Link to comment
Share on other sites

  • Developers

Starg thanks that WinAPI function return the extension based on the combobox so without any other solution using the internal FileSaveDialog i'll use that.

But i think ( my opinion, without any offence for anyone ) Jos need to add to the internal FileSaveDialog the extension return value or is useless to add a multiple choice because i don't know what is the user choice from the combobox.

Understand what you are saying and know what this issue is now. It should be just a matter of setting .lpstrDefExt to "".

Just make a Bugreport and I won't be me making any changes to AutoIt3 core and "only" maintain the SciTE4AutoIt3 and Utilities stuff.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

With this Modification, your example will default to the first supplied extension and show "MYNAME.au3" when running your snippet in the FileName field:

$var = FileSaveDialog("Choose a name.", @ScriptDir, "Scripts (*.au3)|Text files (*.txt)", 2, "MYNAME")

When a filename without an extension is provided in the FileName field, the extension is added which is selected in the "Save as Type" dropdownbox to the returned value in $var.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Yes, perfect. Just for understand, for use this modification ( when you done it after the bug report ) i need to download a BETA version? Would be great if i can use it with the stable if is possible, a beta is always a beta. If is it not possible for now i'll use _WinAPI_GetSaveFileName

Link to comment
Share on other sites

  • Developers

Yes, perfect. Just for understand, for use this modification ( when you done it after the bug report ) i need to download a BETA version? Would be great if i can use it with the stable if is possible, a beta is always a beta. If is it not possible for now i'll use _WinAPI_GetSaveFileName

I have informed Jon about the modification that needs to be made to implement this change, but leave it to him to decide whether or not he wants to make the modification.

So just created the Bug report to get this on record and link to this thread and lets see what happens.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...