Jump to content

Recommended Posts

Posted

Hello.

How would I split it up, so I get a list of extensions to save the file as?

instead of: txt,ini, it would be

.txt

.ini

After that I need to get the extension with a msgbox, I don't need the file path, only the extension that the user selected, is that possible? I can think of a way of how that would be done, maybe someone knows?

  • Moderators
Posted

legend,

You could write your own dialog. Here is a proof of concept script using my ChooseFileFolder UDF:

#include <GUIConstantsEx.au3>
#include <Constants.au3>

#include "ChooseFileFolder.au3"

Global $aDrives = DriveGetDrive("ALL")
Global $sDrives = ""
For $i = 1 To $aDrives[0]
    ; Only display ready drives
    If DriveStatus($aDrives[$i] & '\') <> "NOTREADY" Then $sDrives &= "|" & StringUpper($aDrives[$i])
Next

$sExt = "txt|ini"
$sDef_Ext = "txt"

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0xC4C4C4)

GUICtrlCreateLabel("Choose Drive", 10, 10, 90, 20)
$cCombo_Drive = GUICtrlCreateCombo("", 100, 10, 60, 20)
GUICtrlSetData($cCombo_Drive, $sDrives)
$cTreeView = GUICtrlCreateTreeView(10, 50, 200, 200)
GUICtrlCreateLabel("Choose Drive", 10, 270, 90, 20)
$cCombo_Ext = GUICtrlCreateCombo("", 100, 270, 60, 20)
GUICtrlSetData($cCombo_Ext, $sExt, $sDef_Ext)

GUISetState()

; Register UDF message handler
_CFF_RegMsg()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cCombo_Drive
            $sRoot = GUICtrlRead($cCombo_Drive) & "\"
            ; Create drive treeview and wait for a selection
            $sSel = _CFF_Embed($cTreeView, $sRoot, "*.*", 12)
            $sNew_Ext = GUICtrlRead($cCombo_Ext)
            $sCurr_Ext = StringRegExpReplace($sSel, "^.*\.", "")
            ; Change extension if required
            If $sCurr_Ext <> $sNew_Ext Then
                $sSel = StringReplace($sSel, "." & $sCurr_Ext, "." & $sNew_Ext)
            EndIf
            GUIDelete($hGUI)
            MsgBox($MB_SYSTEMMODAL, "Filename", $sSel)
    EndSwitch

WEnd
Please ask if you have any questions. :)

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

 

Posted

This is one way of getting the ext used in a msg box, using iniwrite could list them for you.

Local $var = FileSaveDialog("Your File", @DesktopDir & "\", "", 1)

$ext = StringRight($var, 4)
MsgBox(0, "File Extension is", $ext)

But is sounds like you want this list in the FileSaveDialog built in.

Kinda vague

Posted

my way to get the extension:

$file = "bla.bla2s.extension"

$FileExtension = StringSplit($file,".",1)
$FileExtension = $FileExtension[$FileExtension[0]]

MsgBox(0,"Test1",'The file extension is: "'&$FileExtension&'"')




$file = "test.txt"

$FileExtension = StringSplit($file,".",1)
$FileExtension = $FileExtension[$FileExtension[0]]

MsgBox(0,"Test2",'The file extension is: "'&$FileExtension&'"')

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
  • Recently Browsing   0 members

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