Jump to content
TheDcoder

AutoIt can't handle big data in arrays

Recommended Posts

Hello everyone :bye:, I am currently having some problems with this cut out from my latest project:

The project is called Magic Number Calculator, Spoiler Alert!

#include <Array.au3>
#include <Debug.au3>

Global Const $eAutoItIncludesFolder = @ProgramFilesDir & "\AutoIt3\Include"
Global Const $eAVIConstantsFile = $eAutoItIncludesFolder & "\AVIConstants.au3"
Global Const $eButtonConstantsFile = $eAutoItIncludesFolder & "\ButtonConstants.au3"
Global Const $eComboConstantsFile = $eAutoItIncludesFolder & "\ComboConstants.au3"
Global Const $eDateTimeConstants = $eAutoItIncludesFolder & "\DateTimeConstants.au3"
Global Const $eEditConstantsFile = $eAutoItIncludesFolder & "\EditConstants.au3"
Global Const $eGUIConstantsExFile = $eAutoItIncludesFolder & "\GUIConstantsEx.au3"
Global Const $eListboxConstantsFile = $eAutoItIncludesFolder & "\ListboxConstants.au3"
Global Const $eListViewConstantsFile = $eAutoItIncludesFolder & "\ListViewConstants.au3"
Global Const $eWindowsConstantsFile = $eAutoItIncludesFolder & "\WindowsConstants.au3"

; Debug
_DebugSetup()
$aArray = LoadConstants($eAVIConstantsFile & '|' & $eButtonConstantsFile & '|' & $eComboConstantsFile & '|' & $eDateTimeConstants & '|' & $eEditConstantsFile & '|' & $eGUIConstantsExFile & '|' & $eListboxConstantsFile & '|' & $eListViewConstantsFile & '|' & $eWindowsConstantsFile)
_DebugOut("Returned")
_ArrayDisplay($aArray)

Func LoadConstants($sFile)
    $aFiles = StringSplit($sFile, '|') ; Load the list of files to load
    _DebugOut("Loaded list of files")
    Local $aReturn = LoadConstants($aFiles[1]) ; Load the first file
    _DebugOut("Loaded the first file")
    For $i = 2 To $aFiles[0] ; Load remaining files
        $aTempArray = ConstantFileTo2DArray($aFiles[$i]) ; Store the contants to concatenate
        _DebugOut("Loaded " & $i & " Files")
        _ArrayConcatenate($aReturn, $aTempArray)
        _DebugOut("Concatenated")
    Next
    _DebugOut("Returning")
    Return $aReturn ; Return the Array
EndFunc   ;==>LoadConstants

Func ConstantFileTo2DArray($sFile)
    $aFile = FileReadToArray($sFile)
    Local $sLinesToBeDeleted = "0;" ; Remove line.no 1 because it always contains #include-once
    For $i = 0 To UBound($aFile) - 1
        If StringLeft($aFile[$i], 1) = ';' Or $aFile[$i] = "" Then $sLinesToBeDeleted &= $i & ';' ; Detect if the present line is a comment or empty ;)
    Next
    $sLinesToBeDeleted = StringTrimRight($sLinesToBeDeleted, 1) ; Trim the last semi-colon
    _ArrayDelete($aFile, $sLinesToBeDeleted) ; Delete empty lines
    For $i = 0 To UBound($aFile) - 1
        $aFile[$i] = StringStripWS($aFile[$i], $STR_STRIPALL) ; Remove any Space, CR, LF etc. chars from the string (Refer to StringStipWS's documentation for more info)
        $aFile[$i] = StringTrimLeftUntil('$', $aFile[$i], 1, False) ; Remove any Global Const before the variable
        If Not StringInStr($aFile[$i], ';') = 0 Then $aFile[$i] = StringTrimRightUntil(';', $aFile[$i]) ; Remove any comments (For example, like this comment trailing after the function :P)
    Next
    Local $aReturn[UBound($aFile)][2]
    $sLinesToBeDeleted = ""
    For $i = 0 To UBound($aFile) - 1
        $aTempArray = StringSplit($aFile[$i], '=', $STR_NOCOUNT) ; Split the Variable & Value
        $aTempArray[0] = StringTrimLeft($aTempArray[0], 1) ; Trim the dollar sign
        Assign($aTempArray[0], $aTempArray[1], 1) ; Assign the constants as variables (forced in local scope) for solving them using execute()
        $aTempArray[1] = Execute($aTempArray[1])
        Assign($aTempArray[0], $aTempArray[1], 1) ; Assign the calculated value again
        $aReturn[$i][0] = '$' & $aTempArray[0]
        $aReturn[$i][1] = $aTempArray[1]
        If Not IsInt($aTempArray[1]) Then $sLinesToBeDeleted &= $i & ';' ; Delete constants which are not intergers
    Next
    _ArrayDelete($aReturn, StringTrimRight($sLinesToBeDeleted, 1)) ; Delete constants which are not intergers
    Return $aReturn
EndFunc   ;==>ConstantFileTo2DArray

Func StringTrimLeftUntil($sDelimiter, $sString, $iOccurrence = 1, $bTrimDelimiter = True)
    $iDelimiterLen = StringLen($sDelimiter)
    $sString = StringTrimLeft($sString, StringInStr($sString, $sDelimiter, 2, $iOccurrence) + ($iDelimiterLen - 1))
    If $bTrimDelimiter = False Then $sString = $sDelimiter & $sString
    Return $sString
EndFunc   ;==>StringTrimLeftUntil

Func StringTrimRightUntil($sDelimiter, $sString, $iOccurrence = 1, $bTrimDelimiter = True)
    $iStringLen = StringLen($sString)
    $iDelimiterLen = StringLen($sDelimiter)
    $iOccurrence -= $iOccurrence * 2
    $sString = StringTrimRight($sString, ($iStringLen - StringInStr($sString, $sDelimiter, 2, $iOccurrence)) - ($iDelimiterLen - 1) + $iDelimiterLen)
    If $bTrimDelimiter = False Then $sString &= $sDelimiter
    Return $sString
EndFunc   ;==>StringTrimRightUntil

 

The code looks good, but if you run it AutoIt crashes :(... Any tips or suggestion to make it work again :ermm:?

Here is the error image: http://img4.imagetitan.com/img.php?image=11_capture2866.png

SciTE Output (Exit code is not constant):

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\TheDcoder\Desktop\New AutoIt v3 Script.au3" /UserParams    
+>15:31:59 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00004009  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0809)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\TheDcoder\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\TheDcoder\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.12.0)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\TheDcoder\Desktop\New AutoIt v3 Script.au3
+>15:31:59 AU3Check ended.rc:0
>Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\TheDcoder\Desktop\New AutoIt v3 Script.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
!>15:32:10 AutoIt3.exe ended.rc:-1073740771
+>15:32:10 AutoIt3Wrapper Finished.
>Exit code: 3221226525    Time: 12.07

Thanks in Advance, TD :D

Edited by TheDcoder
code correction

A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

Yes: Please provide the error message you get so we know what the problem "exactly" is.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

@water Added debug details :)

 

P.S Is that code working for you?


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

P.S Is that code working for you?

No. On Windows 7 I get  "Loaded list of files" in the debug window over and over again until the script crashes.
After a quick glance at your code I think you are passing the wrong parameter.

Func LoadConstants($sFile)
    $aFiles = StringSplit($sFile, '|') ; Load the list of files to load
    _DebugOut("Loaded list of files")
    Local $aReturn = LoadConstants($sFile) ; Load the first file

should be

Func LoadConstants($sFile)
    $aFiles = StringSplit($sFile, '|') ; Load the list of files to load
    _DebugOut("Loaded list of files")
    Local $aReturn = LoadConstants($aFiles[1]) ; Load the first file

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

@water :doh:Fixed it... But It didn't solve the problem :(


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

What do you now get in the debug window?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

@water Same repetition of "Loaded list of files" :(


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

Why do you recursively call LoadConstants?
Right now you call LoadConstants until the universe falls apart. You need to define a condition when to exit the recursion.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Right now you call LoadConstants until the universe falls apart.

On which line :huh:?


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

In function LoadConstants you call LoadConstants you call LoadConstants you call LoadConstants you call LoadConstants you call LoadConstants you call LoadConstants ...


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

@water :oops: Thanks! I used LoadConstants instead of ConvertConstantsTo2DArray

 

TD :)


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

Creative use of the ternary operator :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

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

    • By Blitzkid
      Hello, i want to search several directories for files with the largest numbers behind them (Like "video123") . They dont have a datatype. But there are also files with longer names and datatypes in these folders (Like "video778.mp4"). Is it possible to filter the _FileListToArray Syntax from
      to smth. like
       
      Here is my Code
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> #include <File.au3> $filedir = @ScriptDir & "\" _checkfile() Func _checkfile() ConsoleWrite("______________________" & @CRLF) Local $arr[3] = ["music", "picture", "video"] For $i = 0 To UBound($arr) - 1 Local $arrayfiles = _FileListToArray($filedir & $arr[$i], $arr[$i] & "*", 1) If @error = 1 Then ConsoleWrite($arr[$i] & "Error 1") EndIf If @error = 4 Then ConsoleWrite($arr[$i] & "Error 2") ;Exit EndIf $arrayfilter = _ArrayMax($arrayfiles, 0, 1) Global $stringfiles = StringReplace($arrayfilter, $arr[$i], "") ConsoleWrite($arrayfilter & @CRLF) Next EndFunc ;==>_checkfile  
    • By jmp
      Script running good but error in line 7.
      When i run this script :
      #include <IE.au3> #include <Array.au3> $oIE = _IEAttach ("Shop") $oTable = _IETableGetCollection ($oIE, 1) $aTableData = _IETableWriteToArray ($oTable) For $inumber = 1 To UBound($aTableData) -1 $table = $aTableData[4][$inumber] MsgBox(0, "", $table) Next I got Error: array variable has incorrect number of subscripts or subscript dimension range exceeded
    • By nacerbaaziz
      Good morning guys, i hope that you're all well.
      guys, i have a problem and i hope that you can help me
      i've created an 3d array
      the array Contain a Categories info
      as folow
      $array[n][0][0] = Categorie name
      $array[n][0][1] = Categorie file path
      $array[n][0][2] = Categorie contents number
      $array[n][m][0] = link name
      $array[n][m][1] = link url
      $array[n][m][2] = link section name
      in my tool i want to add an option to delete a Category
      as you know the Categorie mean that must delete a region from the array
      when i tried to use _arrayDelete
      with the 2d array it work well
      but here i couldn't find any way to do that, can any one help me please?
      thanks in advance.
    • By nacerbaaziz
      hello sirs, please help me
      i tried to create a function that read a folder files to 3d array
      e.g
      $array[n][0][0] = ctName
      $array[n][0][1] = ctFilePath
      $array[n][0][2] = crtsections number
      $array[n][m][0] = KeyName
      $array[n][m][1] = KeyVal
      $array[n][m][2] = keySectionName
       
      that the array
      when i put one file into the folder all things work fine
      but when i put more than one file
      the last file worked fine but the others only the first key is showing
      please can you help me to correct this problem
      here is the example with the folder
      please accept my greetings
      and thanks in advance
       
      array3d.zip
    • By nacerbaaziz
      good morning everybody.
      today i liked to share an small example with you
      which it an function to read the registry values as an array
      the result array is 2d array witch
      $a_array[n][0] = value name
      $a_array[n][1] = value Data
      $a_array[0][0] = values count
      here's the function

      #include <Array.au3> #include <WinAPIReg.au3> #include <APIRegConstants.au3> Local $a_array = _RegReadToArray("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run") If @error Then     MsgBox(16, "error", @error)     Exit EndIf _ArrayDisplay($a_array) Func _RegReadToArray($s_RegKey)     Local $a_KeySplitInfo = StringSplit($s_RegKey, "\\", 2)     If UBound($a_KeySplitInfo) <= 1 Then         $a_KeySplitInfo = StringSplit($s_RegKey, "\", 2)         If UBound($a_KeySplitInfo) <= 1 Then Return (1, 1, 0)     EndIf     Local $H_KeyInfo = "", $s_RegKeyInfo = ""     Switch $a_KeySplitInfo[0]         Case "hklm", "HKEY_LOCAL_MACHINE", "hklm64", "HKEY_LOCAL_MACHINE64"             $H_KeyInfo = $HKEY_LOCAL_MACHINE         Case "hkCu", "HKEY_CURRENT_USER", "hkCU64", "HKEY_CURRENT_USER64"             $H_KeyInfo = $HKEY_CURRENT_USER         Case "hkCr", "HKEY_CLASSES_ROOT", "HKCR64", "HKEY_CLASSES_ROOT64"             $H_KeyInfo = $HKEY_CLASSES_ROOT         Case "HKU", "HKEY_USERS", "HKU64", "HKEY_USERS64"             $H_KeyInfo = $HKEY_USERS         Case Else             Return SetError(2, 2, 0)     EndSwitch     _ArrayDelete($a_KeySplitInfo, 0)     $s_RegKeyInfo = _ArrayToString($a_KeySplitInfo, "\")     Local $H_KeyInfoOpen = _WinAPI_RegOpenKey($H_KeyInfo, $s_RegKeyInfo, $KEY_READ)     Local $A_KeyInfo = _WinAPI_RegQueryInfoKey($H_KeyInfoOpen)     If @error Then Return SetError(1, 1, 0)     _WinAPI_RegCloseKey($H_KeyInfoOpen)     Local $A_RegVal[$A_KeyInfo[2] + 1][2]     Local $iV = 1, $s_RegRead = ""     While 1         $s_RegVal = RegEnumVal($s_RegKey, $iV)         If @error <> 0 Then ExitLoop         $s_RegRead = RegRead($s_RegKey, $s_RegVal)         If Not (@error) Then             $A_RegVal[$iV][0] = $s_RegVal             $A_RegVal[$iV][1] = $s_RegRead         EndIf         $iV += 1     WEnd     $A_RegVal[0][0] = UBound($A_RegVal) - 1     If $A_RegVal[0][0] >= 1 Then         Return $A_RegVal     Else         Return SetError(3, 3, 0)     EndIf EndFunc   ;==>_RegReadToArray
      i hope you benefit from it
      with my greetings
×
×
  • Create New...