NiceBoy1234

Autoit modification date

9 posts in this topic

#1 ·  Posted (edited)

I am trying to dynamically get folders and their modification date, I was orientated by this:

; Initial Launch, grab current GetTime
$file1_1 = FileGetTime("X:\aescripts\testimg", 0, 1)

Timecheck()

Func Timecheck()

      $file1_2 = FileGetTime("X:\test\testimg", 0, 1)

      If $file1_1 == $file1_2 Then
         ConsoleWrite("Folder 1 not modified" & @CRLF);
      ElseIf $file1_1 <> $file1_2 Then
         ConsoleWrite("Folder 1 modified" & @CRLF)
      EndIf

; Initial Launch, grab current GetTime
$file1_1 = FileGetTime("X:\test\testimg", 0, 1)

EndFunc

; Initial Launch, grab current GetTime
$file1_1 = FileGetTime("X:\test\testimg", 0, 1)

While 1
    Sleep(5000)
    Timecheck()
WEnd


That works, but it is not dynamic.

So I did code following but it does not work properly.

 

   Local $sFootage_01 = "Z:\Footage\ClothImgs\"    

      Local $aFileListFootageFolder_01 = _FileListToArray($sFootage_01, "*")

      ; Initial Launch, grab current GetTime
      For $i = 0 To UBound($aFileListFootageFolder_01) - 1
         $newFootageFolder_01 = $sFootage_01 & $aFileListFootageFolder_01[$i]
         $getTimeNewFootageFolderInit_01 = FileGetTime($newFootageFolder_01, 0, 1)
         ConsoleWrite("First Filename " & $newFootageFolder_01 & @CRLF)
      Next

   Func Timecheck()

      Local $aFileListFootageFolderRe_01 = _FileListToArray($sFootage_01, "*")

      If @error = 1 Then
         ConsoleWrite("not valid path" & @CRLF)
         Exit
      EndIf
      If @error = 4 Then
         ConsoleWrite("could not find any data" & @CRLF)
         Exit
      EndIf

      For $i = 0 To UBound($aFileListFootageFolderRe_01) - 1
         $newFootageFolder_01 = $sFootage_01 & $aFileListFootageFolderRe_01[$i]
         ConsoleWrite("ArrH " & $aFileListFootageFolderRe_01[$i] & @CRLF)
         $getTimeNewFootageFolder_01 = FileGetTime($newFootageFolder_01, 0, 1)
         ConsoleWrite("ZZZ First Filename " & $newFootageFolder_01 & @CRLF)

         Local $aGetTimeNewFootageFolder_01 = _FileListToArray($newFootageFolder_01, "*")
         For $u = 0 To UBound($aGetTimeNewFootageFolder_01) -1
             If $getTimeNewFootageFolderInit_01 == $getTimeNewFootageFolder_01 Then
                ConsoleWrite($newFootageFolder_01 & " has not been changed" & @CRLF)
             ElseIf($getTimeNewFootageFolderInit_01 <> $getTimeNewFootageFolder_01 And $aGetTimeNewFootageFolder_01[0] == 11) Then
                ConsoleWrite("File 1 has been changed and has " & $aGetTimeNewFootageFolder_01[0] & " images" & @CRLF)
                ConsoleWrite("Time 1.1: " & $getTimeNewFootageFolderInit_01 & @CRLF & "1.2: " & $getTimeNewFootageFolder_01 & @CRLF)
                WinKill($hWnd, "")
                Sleep(8000)
                RunCm()
                ListFolders()
                ExitLoop
             ElseIf($getTimeNewFootageFolderInit_01 <> $getTimeNewFootageFolder_01 And $aGetTimeNewFootageFolder_01[0] <> 11) Then
                ConsoleWrite("Path " & $newFootageFolder_01 & " modification date has changed, number of images: " & $aGetTimeNewFootageFolder_01[0] & " files/folders" & @CRLF)
             Else
                ConsoleWrite("Else Statement" & @CRLF)
             EndIf
         Next
      Next


      $aFileListFootageFolderInit_01 = _FileListToArray($sFootage_01, "*")

      ; Initial Launch, grab current GetTime
      For $i = 0 To UBound($aFileListFootageFolder_01) - 1
         $newFootageFolder_01 = $sFootage_01 & $aFileListFootageFolder_01[$i]
         $getTimeNewFootageFolderInit_01 = FileGetTime($newFootageFolder_01, 0, 1)
      Next
   EndFunc

      $aFileListFootageFolderInit_01 = _FileListToArray($sFootage_01, "*")

      ; Initial Launch, grab current GetTime
      For $i = 0 To UBound($aFileListFootageFolder_01) - 1
         $newFootageFolder_01 = $sFootage_01 & $aFileListFootageFolder_01[$i]
         $getTimeNewFootageFolderInit_01 = FileGetTime($newFootageFolder_01, 0, 1)
      Next

   ; check every 5s if files in footage folder has been changed
   While 1
      Sleep(5000)
      ConsoleWrite("While Loop " & @CRLF)
      Timecheck()
   WEnd

It always goes to the first ElseIf Statement and tells me that the files have been changed.
So I printed out the modification dates and this varaible shows correctly the current modification date of the subfolder $getTimeNewFootageFolder_01 and this
$getTimeNewFootageFolder_01 does show another modification date of another folder which I do not understand.

Again the code (not dynmaic one) above works, but trying to make it dynmacly did not work.
 

Edited by NiceBoy1234

Share this post


Link to post
Share on other sites



Not exactly sure what you are wanting to do?
Are you just wanting the dates of all files in a folder?
To do a comparison with the same files in another folder?

And to be honest, I prefer things simple, so big long names and busy looking code does my head in.
I keep things simple, that I can understand at a glance, even if that means using extra steps and lines.
Similar names also don't help, as it takes me away, checking what they are all the time.
None of that is intuitive to holding an overall picture/map/structure in one's head.

But each to their own.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I Basically want to check if the modification date of a folder has changed.
I tried to make the code above dynamically, if you would copy the first part of the code and change the path you may would understand it better.

Edited by NiceBoy1234

Share this post


Link to post
Share on other sites

Not sure what you mean by dynamic?

Why are you checking every 5 seconds?


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Are you wanting to continually monitor the same folder indefinitely for changes?

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I check every 5 seconds, because if the user creates another folder, that folder gets checked to.
I check for folders in the following path :

Z:\Footage\ClothImgs\

If there are folder I check for their file size ( in this case they got images ) and the modification date.
So if I delete a file or something similiar the modification date of that folder changes and I will do something ...

So Yeah one could say that I want to check indefinitely the folder/s for changes.

Edited by NiceBoy1234

Share this post


Link to post
Share on other sites

By my reckoning, you keep assigning to the same variable ($getTimeNewFootageFolderInit_01) for every sub-folder. And perhaps you also need to use a backslash between source folder and sub-folder? (i.e. $sFootage_01 & "\" & $aFileListFootageFolder_01[$i])

; Initial Launch, grab current GetTime
      For $i = 0 To UBound($aFileListFootageFolder_01) - 1
         $newFootageFolder_01 = $sFootage_01 & $aFileListFootageFolder_01[$i]
         $getTimeNewFootageFolderInit_01 = FileGetTime($newFootageFolder_01, 0, 1)
         ConsoleWrite("First Filename " & $newFootageFolder_01 & @CRLF)
      Next

Those two things strike me as issues that need dealing with.

But I don't know, I'm getting awfully muddled by your naming convention, which makes it hard to troubleshoot. It seems to me you might be getting things mixed up, but I'm not really sure.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Results of three hours working with less brainy brain:

File Monitor!

#include <File.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Opt('TrayAutoPause', 0)

Global Const $sPathtoCheck = @ScriptDir ; "Z:\Footage\ClothImgs\"

If Not FileExists($sPathtoCheck) Then
    DirCreate($sPathtoCheck)
    If Not FileExists($sPathtoCheck) Then
        MsgBox(48, 'Error', 'Unable to create folder.')
        Exit
    EndIf
EndIf

FileChangeDir($sPathtoCheck)
OnAutoItExitRegister('_OnExit')

Global $g_ahObj[2]
$g_ahObj[0] = _WinAPI_FindFirstChangeNotification($sPathtoCheck, $FILE_NOTIFY_CHANGE_FILE_NAME)
$g_ahObj[1] = _WinAPI_FindFirstChangeNotification($sPathtoCheck, $FILE_NOTIFY_CHANGE_LAST_WRITE)

If (Not $g_ahObj[0]) Or (Not $g_ahObj[1]) Then
    MsgBox(48, 'Error', 'Unable to create change notification.')
    Exit
EndIf

Local $tObjs = DllStructCreate('ptr;ptr')
Local $paObj = DllStructGetPtr($tObjs)
DllStructSetData($tObjs, 1, $g_ahObj[0])
DllStructSetData($tObjs, 2, $g_ahObj[1])

Global $aListFileChecked, $aListTimeFileChecked, $sOldFileTime
Global $aListFileToCheck, $aListTimeFileToCheck, $sCurFileTime
Global Const $aArray[1] = [0]

$aListFileChecked = _FileListToArray($sPathtoCheck, "*", $FLTA_FILES)
If Not IsArray($aListFileChecked) Then $aListFileChecked = $aArray
For $i = 1 To $aListFileChecked[0] - 1
    $aListFileChecked[$i] = $aListFileChecked[$i] & "|" & FileGetTime($aListFileChecked[$i], $FT_MODIFIED, $FT_STRING)
    ConsoleWrite("+ File: " & _RetunFileOrTime($aListFileChecked[$i], 0) & "  - Time: " & _RetunFileOrTime($aListFileChecked[$i], 1) & @CRLF)
Next

TraySetToolTip("Right click to me and Click Exit to Exit")
TrayTip("File Monitor", "Right click to TrayIcon and Click Exit to Exit", 3)

Local $iID
While 1
    Sleep(1)
    $iID = _WinAPI_WaitForMultipleObjects(2, $paObj, 0, 0)
    If $iID = 0 Or $iID = 1 Then
        _CheckFileTime()
        If Not _WinAPI_FindNextChangeNotification($g_ahObj[$iID]) Then
            MsgBox(48, 'Error', 'Unexpected error.')
            _OnExit()
        EndIf
    Else
        ContinueLoop
    EndIf
WEnd

Func _RetunFileOrTime($FileAndTime, $Type = 0); 1 Time
    ;ConsoleWrite("> " &$FileAndTime&" - "&$Type& @CRLF)
    If Not StringInStr($FileAndTime, "|") Then Return $FileAndTime
    If $Type <> 1 Then Return StringLeft($FileAndTime, StringInStr($FileAndTime, "|") - 1)
    Return StringTrimLeft($FileAndTime, StringInStr($FileAndTime, "|"));TIME
EndFunc   ;==>_RetunFileOrTime

Func _CheckFileTime()
    ConsoleWrite("- Some file is changed: Modified/Created/Deleted " & @CRLF)
    $aListFileToCheck = _FileListToArray($sPathtoCheck, "*", $FLTA_FILES, False)
    If Not IsArray($aListFileToCheck) Then $aListFileToCheck = $aArray
    For $i = 1 To $aListFileToCheck[0] - 1
        $aListFileToCheck[$i] = $aListFileToCheck[$i] & "|" & FileGetTime($aListFileToCheck[$i], $FT_MODIFIED, $FT_STRING)
        ;ConsoleWrite("! File: " &_RetunFileOrTime($aListFileToCheck[$i],0)&"  - Time: "& _RetunFileOrTime($aListFileToCheck[$i],1)& @CRLF)
        For $x = 1 To $aListFileChecked[0] - 1
            If _RetunFileOrTime($aListFileToCheck[$i], 0) = _RetunFileOrTime($aListFileChecked[$x], 0) Then
                If _RetunFileOrTime($aListFileToCheck[$i], 1) <> _RetunFileOrTime($aListFileChecked[$x], 1) Then
                    ConsoleWrite("! File is changed: " & _RetunFileOrTime($aListFileToCheck[$i], 0) & @CRLF)
                    ExitLoop
                EndIf
            EndIf
        Next
    Next
    $aListFileChecked = $aListFileToCheck
EndFunc   ;==>_CheckFileTime

Func _OnExit()
    For $i = 0 To 1
        If $g_ahObj[$i] Then
            _WinAPI_FindCloseChangeNotification($g_ahObj[$i])
        EndIf
    Next
    ;DirRemove($sPathtoCheck, 1)
EndFunc   ;==>_OnExit

 

Edited by Trong

Regards,
 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

.

Edited by NiceBoy1234

Share this post


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

  • Similar Content

    • Valnurat
      By Valnurat
      Hi.
      A user have to be a member of specific groups. If the user is a member of 1 of the below groups it has to a member of "Mailuser_". If not then I need to add user to the "Mailuser_".
      But how can I search in the array. In the code I do If...then, but it will just jump to my next if...then and search in that "index". But that is not what I want. It seems that I have to do a new For...To, right? But there have to be a easier way to do this.
       
      Func FindADInfo() Local $sUsersSource, $sBackupFolder, $sSiteHomePath, $sFileOpenDialog Local $aSamAccountName[1][1], $aTempSamAccountName[1] For $i = 0 to UBound($aAllMailSites) - 1 if $aAllMailSites[$i] <> "" then if $bDebugMode Then ConsoleWrite("Collecting AD info for " & StringRight($aAllMailSites[$i], 2) & StringMid($aAllMailSites[$i], StringInStr($aAllMailSites[$i], ",") - 2, 2) & @CRLF) Else _FileWriteLog($hFile, "Collecting AD info for " & StringRight($aAllMailSites[$i], 2) & StringMid($aAllMailSites[$i], StringInStr($aAllMailSites[$i], ",") - 2, 2)) EndIf $aSamAccountName = _AD_GetObjectsInOU($aAllMailSites[$i] & ",OU=company,DC=AD,DC=company,DC=ORG", "(&(objectcategory=person)(objectclass=user))",2, "sAMAccountName,distinguishedName,displayname", "displayname") _ArrayDelete($aSamAccountName, 0) for $x = 0 to UBound($aSamAccountName) -1 if StringInStr($aSamAccountName[$x][1],"Resources") = 0 Then local $aUserGroups = _AD_GetUserGroups($aSamAccountName[$x][1]) _ArrayDisplay($aUserGroups,$aSamAccountName[$x][0]) if IsArray($aUserGroups) Then for $y = 1 to UBound($aUserGroups) -1 ;MsgBox(0,"",$aUserGroups[$y]) If StringInStr($aUserGroups[$y],"Office365_E3_SharedMailBox") <> 0 Or StringInStr($aUserGroups[$y],"Office365_E3_OPP_EXO_SPO") <> 0 Or StringInStr($aUserGroups[$y],"Office365_E3_OPP_EXO_SFBPLUS") <> 0 Or StringInStr($aUserGroups[$y],"Office365_E3_OPP_EXO_SFB") <> 0 Or StringInStr($aUserGroups[$y],"Office365_E3_OPP") <> 0 Or StringInStr($aUserGroups[$y],"Office365_E3_FULL") <> 0 Or StringInStr($aUserGroups[$y],"Office365_E1_EXO") <> 0 Then If StringInStr($aUserGroups[$y],"Mailuser_") = 0 Then ConsoleWrite($aSamAccountName[$x][0] & " Add to mailgroup") EndIf EndIf Next EndIf EndIf Next EndIf Next EndFunc ;==>FindADInfo  
    • rootx
      By rootx
      I write this script to compare to array, well Do you have a better way to do it?
      #include <Constants.au3> #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> $a = FileSelectFolder("seleziona cartella A",@ScriptDir) $fold_A = _FileListToArrayRec($a,"*",2,1,0,1) $b = FileSelectFolder("seleziona cartella B",@ScriptDir) $fold_B = _FileListToArrayRec($b,"*",2,1,0,1) $tota = UBound($fold_A)-1 $totb = UBound($fold_B)-1 If $tota > $totb Then findx($fold_A,$fold_B) Else findx($fold_B,$fold_A) EndIf Func findx($min,$max) For $i = 0 To UBound($min)-1 $found = _ArraySearch($max, $min[$i]) If $found = -1 Then ConsoleWrite($min[$i]&@CRLF) EndIf Next EndFunc  
    • VaishnaviBUtpat
      By VaishnaviBUtpat
      <!DOCTYPE html> <html lang="en" xml:lang="en" style="height: 100%;" xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style> * { margin: 0; padding: 0; } .th-lk { color: #3665d0; font-family: Arial; font-size: small; text-decoration: none; } .th-lk { vertical-align: 0px; } .th-menu2 .th-lk { line-height: 2em; margin-bottom: 0px; margin-right: 0px; overflow: hidden; padding: 0; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; width: 100%; } .th-menu2 .th-lk { color: black; font-weight: bold; } .th-menu2 > li > .th-lk { display: block; padding-left: 8px; width: auto; } .th-menu2 .th-menu2-sub-item .th-lk, .th-menu2 .th-menu2-sub-item-hov .th-lk { margin-right: 20px; } .th-menu2-sub-item { position: relative !important; } .th-menu2 .th-menu2-item, .th-menu2 .th-menu2-item-hov, .th-menu2 .th-menu2-sub-item, .th-menu2 .th-menu2-sub-item-hov { background-repeat: repeat-x; border-left-style: solid; border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-style: solid; border-top-width: 1px; height: 2em; list-style: none; margin-bottom: 0px; padding: 0; width: 100%; } .th-menu2 .th-menu2-item, .th-menu2 .th-menu2-item-hov, .th-menu2 .th-menu2-sub-item, .th-menu2 .th-menu2-sub-item-hov { background-color: #ECECEC; background-image: url(sap_skins/default/styling/lshape/chg_butt_det_nav.gif); border-left-color: #d3d1ce; border-right-color: #d3d1ce; border-top-color: #d3d1ce; border-top-width: 0px; } .th-menu2 { border: 0 solid black; left: 0px; list-style: none; margin: 0; padding: 0; position: relative; } .th-menu2 { z-index: 10006; } .th-menu2 { background-color: white; } div { zoom: 1; } .th-sc-content { left: 0px; position: absolute; top: 0px; } .th-sc-container { left: 0px; overflow: hidden; position: relative; top: 0px; } .th-sc-top { position: relative; } .th-sc-top, .th-sc-content, .th-sc-container, .th-sc-buttondown, .th-sc-buttonup { width: 172px; } .th-sc-buttonup, .th-sc-container { z-index: 10101; } .th-sc-top { z-index: 10100; } body, td, th { font-family: Arial,Helvetica,sans-serif; font-size: small; } .th-l-navcontainer, .th_l_downcontainer { border-right-style: solid; border-right-width: 1px; width: 172px; } .th-l-navcontainer, .th_l_downcontainer { background-color: white; border-right-color: #d3d1ce; } body, html { margin: 0px; border: 0; margin: 0; } </style> </head> <body><form name="myFormId" id="myFormId" action="/sap(ZT1TVVJEWDFWVFVsOWZYMTlmTWpNNU9UWmZXWTlwZG5telZ1RGhBSUFBQ3Nyc2tBPT0=)/bc/bsp/sap/crm_ui_frame/BSPWDApplication.do?sap-client=100&amp;sap-language=EN&amp;sap-domainrelax=min" method="post" target="WorkAreaFrame2"><div class="th-ajax-area" id="rootAreaDiv"><div id="C1_W1_V2" tgt="" dhe="false"><table width="100%" style="table-layout: fixed;" cellspacing="0" cellpadding="0"><tbody><tr><td><table width="100%" style="table-layout: fixed;" cellspacing="0" cellpadding="0"><tbody><tr valign="top"><td class="th-l-navcontainer" id="th_l_navcontainer"><div class="th-sc-top" id="C1_W1_V2_thescroll" style="height: 786px;"><div class="th-sc-container" id="C1_W1_V2_thescroll_scbox" style="height: 786px;"><div class="th-sc-content" id="C1_W1_V2_thescroll_sccontent"><div class="th-ajax-area" id="C1_W1_V2_$navbar"><div id="C7_W35_V36" tgt="" dhe="true" excevt="" intevt="c:C7_W35_V36:C1_W1_V2_C7_W35_V36_MainNavigationLinks.do;" automode="true"><div class="th-ajax-area" id="C1_W1_V2_C7_W35_V36_MainNavigationLinks.do"><ul class="th-menu2" id="C7_W35_V36_mainmenu" style="width: 171px;"><li class="th-menu2-sub-item"><a title="Sales Cycle" class="th-lk" id="C7_W35_V36_UTL-SLS" onclick="htmlbSubmitLib('htmlb',this,'thtmlb:link:click:0','myFormId','C7_W35_V36_UTL-SLS','UTL\x2dSLS\x2dWC',0);return false" onfocus="thSaveKbFocus(this);" oncontextmenu="return false;" href="javascript:void(0)">Sales Cycle</a></li></ul></div></div></div></div></div></div></td></tr></tbody></table></td></tr></tbody></table></div></div></form></body> </html> How to capture above HTML element using AutoIT
    • cu0x
      By cu0x
      Hello guys,
       
      im trying to solved a problem that I have.
       
      Need to get some chinese text from an old Wise script, and in the wise file says f.e. Ù×÷ϵͳ¡£ ÇëÉý¼¶Ä. Is there any way to convert it to traditional chinese?
       
      Already tryied the following code...
       
      #include <MsgBoxConstants.au3> Example() Func Example() ; Define the string that will be converted later. ; NOTE: This string may show up as ?? in the help file and even in some editors. ; This example is saved as UTF-8 with BOM. It should display correctly in editors ; which support changing code pages based on BOMs. Local Const $sString = "Ù×÷ϵͳ¡£ ÇëÉý¼¶Ä" ; Temporary variables used to store conversion results. $dBinary will hold ; the original string in binary form and $sConverted will hold the result ; afte it's been transformed back to the original format. Local $dBinary = Binary(""), $sConverted = "" ; Convert the original UTF-8 string to an ANSI compatible binary string. $dBinary = StringToBinary($sString) ; Convert the ANSI compatible binary string back into a string. $sConverted = BinaryToString($dBinary) ; Display the resulsts. Note that the last two characters will appear ; as ?? since they cannot be represented in ANSI. DisplayResults($sString, $dBinary, $sConverted, "ANSI") ; Convert the original UTF-8 string to an UTF16-LE binary string. $dBinary = StringToBinary($sString, 2) ; Convert the UTF16-LE binary string back into a string. $sConverted = BinaryToString($dBinary, 2) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF16-LE") ; Convert the original UTF-8 string to an UTF16-BE binary string. $dBinary = StringToBinary($sString, 3) ; Convert the UTF16-BE binary string back into a string. $sConverted = BinaryToString($dBinary, 3) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF16-BE") ; Convert the original UTF-8 string to an UTF-8 binary string. $dBinary = StringToBinary($sString, 4) ; Convert the UTF8 binary string back into a string. $sConverted = BinaryToString($dBinary, 4) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF8") EndFunc ;==>Example ; Helper function which formats the message for display. It takes the following parameters: ; $sOriginal - The original string before conversions. ; $dBinary - The original string after it has been converted to binary. ; $sConverted- The string after it has been converted to binary and then back to a string. ; $sConversionType - A human friendly name for the encoding type used for the conversion. Func DisplayResults($sOriginal, $dBinary, $sConverted, $sConversionType) MsgBox($MB_SYSTEMMODAL, "", "Original:" & @CRLF & $sOriginal & @CRLF & @CRLF & "Binary:" & @CRLF & $dBinary & @CRLF & @CRLF & $sConversionType & ":" & @CRLF & $sConverted) EndFunc ;==>DisplayResults Thanks a lot!
    • Jibberish
      By Jibberish
      I am trying to add data to an array and I keep getting the error "Subscript used on non-accessible variable ".
      #include <array.au3> ; Includes, etc ~ ~ ~ Local $aOptionsArray[3] $aOptionsArray = CheckboxesAndRadioButtons() _ArrayDisplay($aOptionsArray) Func CheckboxesAndRadioButtons() ; Create Checkboxes and Radio Buttons and read the results ~ ~ ~ ; Radio Buttons to Array ; $aOptions[0] = $bTestSelectForever ; $aOptions[1] = $bTestSelect3Times ; $aOptions[2] = $bTestSelectOnce If $bSelect1 = 1 Then $aOptions[0] = "True" Else $aOptions[0] = "False" <<< This is where the error occurs. EndIf If $bSelect2 = 1 Then $aOptions[1] = "True" Else $aOptions[1] = "False" EndIf If $bSelect3 = 1 Then $aOptions[2] = "True" Else $aOptions[2] = "False" EndIf Return $aOptions EndFunc Is putting data into an array while in a If - Then - Else illegal?