Jump to content

Get the extion of a file


PantZ4
 Share

Recommended Posts

How to get the extion(spelling?) of a file?

Like

If $msg = $GUI_EVENT_CLOSE Or $msg = $exit Then ExitLoop
        If $msg = $selectfilebutton Then
            GUICtrlSetData($statusgroup,"Status: Select File to Optimize")
            GUISetState(@SW_DISABLE,$GuiWindow)
            $file = FileOpenDialog("Select File to Optimize",@WorkingDir,"All Compatible File Types (*.w3m;*.w3x;*.wts;*.j)|Warcraft 3 Maps (*.w3m;*.w3x)|JASS Scripts (*.j)|String Files (*.wts)|Text Files (*.txt)|All Files (*.*)",1)
            $CheckHasEnableBoolean = 0
            If $file = "" Then
                GUICtrlSetData($filenamelabel,"File: No file selected")
                GUICtrlSetTip($selectfilebutton,"Press this button to select the file to optimize")
                GUICtrlSetData($helplabel1,"Select the file to optimize: "&@LF&"Works with maps (.w3m and .w3x), JASS scripts and string files.")
            Else
                GUICtrlSetData($filenamelabel,"File: "&$file)
                GUICtrlSetTip($selectfilebutton,$file)
                GUICtrlSetData($helplabel1,"Go now to Script Optimization"&@LF&"Or press Select File button again to choose another file")
            EndIf
            GUICtrlSetData($statusgroup,"Status: Waiting...")
            GUISetState(@SW_ENABLE,$GuiWindow)
            GUISetState(@SW_HIDE,$GuiWindow)
            GUISetState(@SW_SHOW,$GuiWindow)
        EndIf

But it didn't work.

Thank you ;)

Link to comment
Share on other sites

How to get the extion(spelling?) of a file?

After this I want it to check what file it is. I have tryed:

If $file = "*.w3x" Then

But it didn't work.

at least two options....

1.) Preferred: _PathSplit() - see help file

2.) StringInStr($file,".w3x") - see help file

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

at least two options....

1.) Preferred: _PathSplit() - see help file

2.) StringInStr($file,".w3x") - see help file

Cheers

Kurt

How does the _PathSplit() works?

My code:

$TestPath = _PathSplit($file, $szDrive, $szDir, $szFName, $szExt)
                $TestPath[3] = $filename

And $filename retruns to ""

Helpfile:

Return Value

Returns an array with 5 elements where 0 = original path, 1 = drive, 2 = directory, 3 = filename, 4 = extension

But maybe I shall not say $TestPath[3] = $filename?
Link to comment
Share on other sites

How does the _PathSplit() works?

as shown in the help file sample...

#include <file.au3>

$filename = "C:\temp\test.w3x"
Dim $szDrive, $szDir, $szFName, $szExt
$SplittedPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)

if ($szExt = ".w3x") then
   msgbox(0,"INFO", "HuHu ... found a magic W3X file...")
endif
oÝ÷ Ù«©mz¹Ú¶+Þjëh×6#include <file.au3>

$filename = "C:\temp\test.w3x"
Dim $szDrive, $szDir, $szFName, $szExt
$SplittedPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)

if ($SplittedPath[4] = ".w3x") then
   msgbox(0,"INFO", "HuHu ... found a magic W3X file...")
endif

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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...