Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/14/2024 in all areas

  1. You are probably confused by the difference between 0-based and 1-based arrays. @TheDcoder has created a helpful tutorial on arrays. This contains, for instance, an explanation of this particular topic. Excerpt : UBound returns the no. of elements in an array with the index starting from 1! That's right, you need to remove 1 from the total no. of elements in order to process the array because the index of an array starts with 0! So append a simple - 1 to the statment:
    2 points
  2. the For $i = 1 To $sNewName[0+1] is wrong, it does not work. Because as I mentioned above, $sNewName[0+1] = Celeste, i.e. For $i = 1 To Celeste ??
    1 point
  3. You will tell me. ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- _Example() ; ----------------------------------------------- Func _Example() Local $file_to_read = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\FileListing.txt" Local $aList = FileReadToArray($file_to_read) ;~ Local $iLineCount = @extended ;~ _ArrayDisplay($aList) ; ----------------------------------------------- $Audio_folder = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\Audio\" Local $aFile = _FileListToArray($Audio_folder, "*.*", $FLTA_FILES) ;~ _ArrayDisplay($aFile) ; ----------------------------------------------- For $i = 1 To $aFile[0] ;~ FileMove($Audio_folder & $aFile[$i], $Audio_folder & $aList[$i - 1] & ".wma", $FC_OVERWRITE) ConsoleWrite("FileMove:" & $Audio_folder & $aFile[$i] & ", " & $Audio_folder & $aList[$i - 1] & ".wma" & @CRLF) Next EndFunc ;==>_Example ; -----------------------------------------------
    1 point
  4. a good tool when working with arrays is _ArrayDisplay($aArray1) to visualize things, believe me , it helps ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- _Example() ; ----------------------------------------------- Func _Example() Local $file_to_read = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\FileListing.txt" Local $aArray1 = FileReadToArray($file_to_read) Local $iLineCount = @extended ;~ _ArrayDisplay($aArray1) ; ----------------------------------------------- $file_to_write = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\Audio\" Local $aArray2 = _FileListToArray($file_to_write, "*.*", $FLTA_FILES) ;~ _ArrayDisplay($aArray2) ; ----------------------------------------------- For $i = 0 To $iLineCount - 1 ;~ FileMove($file_to_write & $aArray2[$i + 1], $file_to_write & $aArray1[$i] & ".wma", $FC_OVERWRITE) ConsoleWrite("FileMove:" & $file_to_write & $aArray2[$i + 1] & ", " & $file_to_write & $aArray1[$i] & ".wma" & @CRLF) Next EndFunc ;==>_Example ; ----------------------------------------------- as well as the correct nomenclature ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- _Example() ; ----------------------------------------------- Func _Example() Local $file_to_read = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\FileListing.txt" Local $aList = FileReadToArray($file_to_read) Local $iLineCount = @extended ;~ _ArrayDisplay($aList) ; ----------------------------------------------- $Audio_folder = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\Audio\" Local $aFile = _FileListToArray($Audio_folder, "*.*", $FLTA_FILES) ;~ _ArrayDisplay($aFile) ; ----------------------------------------------- For $i = 0 To $iLineCount - 1 ;~ FileMove($Audio_folder & $aFile[$i + 1], $Audio_folder & $aList[$i] & ".wma", $FC_OVERWRITE) ConsoleWrite("FileMove:" & $Audio_folder & $aFile[$i + 1] & ", " & $Audio_folder & $aList[$i] & ".wma" & @CRLF) Next EndFunc ;==>_Example ; -----------------------------------------------
    1 point
  5. Nah ...that needs to be removed again ... needed that for some debugging. Updated Beta. Thanks
    1 point
  6. Send(Chr(094) & "{"& Chr(097) &"}") ;~ send: ctrl + a (select all) Send(Chr(094) & "{"& Chr(099) &"}") ;~ send: ctrl + c (copy) ConsoleWrite(ClipGet() & @CRLF)
    1 point
  7. use ResourcesEX.au3 ! Example: ExampleIconOnGUI.zip
    1 point
  8. Note that you don't need the empty square brackets: Local $aArry = ['a','b','c'] works as well. There is one more incentive to omit []: it's the syntax for declaring a Map in the beta (and most probably future releases). #AutoIt3Wrapper_Version=B ;(B/P) Use Beta or Production for AutoIt3 and Aut2Eex. Default is P Local $a[0] ; an empty array ConsoleWrite(VarGetType($a) & @LF) Local $aa = [] ; an empty array (preferrable syntax) ConsoleWrite(VarGetType($aa) & @LF) Local $b[] = [1, 2, 3] ; an initialized array ConsoleWrite(VarGetType($b) & @LF) Local $bb = [1, 2, 3] ; an initialized array (preferrable syntax) ConsoleWrite(VarGetType($bb) & @LF) Local $c[] ; a Map under beta (or syntax error under release) ConsoleWrite(VarGetType($c) & @LF) The similarity between declarations of $b and $c may lead to confusion when Maps become solid. Also by the time the beta has been out and since it doesn't show regressions I'd consider it release-class. One more point: the size of an array is UBound($aArray), while UBound($aArray) - 1 which is the index of the last element.
    1 point
  9. I thought this function may be useful to some people. It works in almost the same way as the core AutoIt function StringStripWS. The difference is that you can specify any characters to be stripped. Note: The function is case sensitive ;======================================================================================================== ; ; Function Name: _StringStripChr($sString_In, $sChr, $iFlags = 2, $iCount = 0) ; Description: ; Parameters: ; $sString_In - The string to be stripped ; $sChr - The characters to be stripped (case sensitive) ; $iFlags - Flag to indicate the type of stripping that should be performed (add the flags together for multiple operations): ; 1 = strip leading instances of characters in $sChr ; 2 (Default) = strip trailing instances of characters in $sChr ; 4 = Replace multiple instances of characters in $sChr with a single instance ; 8 = strip all instances of $sChr (over-rides all other flags) ; $iCount - The max number of leading or trailing instances of $sChr to strip ; 0 (Default) = Strip all ; ; Requirement: None. ; Return Value: Stripped string ; Author: Bowmore ; ; Notes: ; ; Examples: ; _StringStripChr("AAAAbdcaefgA", "A", 3, 0) ; would return ; "bdcaefg" ; ; _StringStripChr("AAAAbdcaefgA", "A", 2, 0) ; would return ; "AAbdcaefg" ; ; _StringStripChr("ABCAAbdcaefgA", "AB", 7, 0) ; would return ; "CAbdcaefg" ; ; _StringStripChr("ABCAAbdcaefgA", "ABe", 8, 0) ; would return ; "Cbdcafg" ; ;======================================================================================================== Func _StringStripChr($sString_In, $sChr, $iFlags = 2, $iCount = 0) Local $sNewString = $sString_In Local $sChr1 = "" If (BitAND($iFlags, 8) = 8) Then For $i = 1 To StringLen($sChr) $sChr1 = StringMid($sChr, $i, 1) $sNewString = StringReplace($sNewString, $sChr1, "", 0, 1) Next Else If (BitAND($iFlags, 4) = 4) Then For $i = 1 To StringLen($sChr) $sChr1 = StringMid($sChr, $i, 1) $sNewString = StringRegExpReplace($sNewString, $sChr1 & "{2,}", $sChr1) Next EndIf If (BitAND($iFlags, 2) = 2) Then If $iCount = 0 Then While (StringInStr($sChr, StringRight($sNewString, 1), 1)) $sNewString = StringTrimRight($sNewString, 1) WEnd Else For $i = 1 To $iCount If (StringInStr($sChr, StringRight($sNewString, 1), 1)) Then $sNewString = StringTrimRight($sNewString, 1) Else ExitLoop EndIf Next EndIf EndIf If (BitAND($iFlags, 1) = 1) Then If $iCount = 0 Then While (StringInStr($sChr, StringLeft($sNewString, 1), 1)) $sNewString = StringTrimLeft($sNewString, 1) WEnd Else For $i = 1 To $iCount If (StringInStr($sChr, StringLeft($sNewString, 1), 1)) Then $sNewString = StringTrimLeft($sNewString, 1) Else ExitLoop EndIf Next EndIf EndIf EndIf Return $sNewString EndFunc ;==>_StringStripChr EDIT: Corrected name of function used in examples. Fixed option 4 to work as described. Fixed case sensitivity issue with options 1 and 2
    1 point
×
×
  • Create New...