Jump to content

Recommended Posts

i would like to check file if the extention was changed,

if the extention was changed show message " number 1"

if the extention had no change so the message will be " number 2 "

here is my script :

 Local $iEncoding = FileGetEncoding("C:\Users\oronyo.hp430-oronyo\Desktop\1.dat") ; Retrieve the file encoding of the current script.
    If @error Then
        MsgBox(0, "", "Error: Could not obtain the file encoding.")
        Else
        MsgBox(0, "", "FileGetEncoding: The value returned was: " & $iEncoding) ; The value returned for this example should be 0 or $FO_ANSI.
    EndIf

Link to post
Share on other sites

I'm not sure if I understand correctly.  Do you actually mean extension, or do you mean encoding as your example shows/uses?

Basically, you need to know what encoding is expected first, then you can write logic to display a message if it is not what was expected; for example below I used AND logic and a nested IF statement.

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

;~ Local $iExpectedEncoding = $FO_UTF8
Local $iExpectedEncoding = $FO_UTF8_NOBOM

Local $iEncoding = FileGetEncoding(@ScriptFullPath) ; Retrieve the file encoding of the current script.
If @error Then
    MsgBox($MB_SYSTEMMODAL, "", "Error: Could not obtain the file encoding.")
Else
    If BitAND($iEncoding,$iExpectedEncoding) Then
        MsgBox($MB_SYSTEMMODAL, "", "FileGetEncoding Matches Expected Encoding")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "FileGetEncoding DOES NOT MATCH" & @CRLF & "The value returned was: " & $iEncoding)
    EndIf
EndIf

 

Another tip, when posting code on the forum use the < > symbol, then paste your code in the pop-up window after it loads.

Edited by spudw2k
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...