Jump to content

_ArrayAdd - function error


Recommended Posts

  • Developers
1 hour ago, joiner said:

user of my program sent this error. I can not repeat the error

Well, You need to provide a reproducer of the issue when you want any proper help as the provided information is not much to go on.
Likely this line returns something the func can't cope with:

_ArrayToString($aArray_1, '<>')

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
2 hours ago, joiner said:

the error is not in my code, but in the library

Nope, not true. The error indicates that your array is out of bounds, i.e either the element index is out of the defined range or the variable itself is not an array. Nothing to do with the library.

I suggest you thorougly sanitize any input from the user and see if that error still happens :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
  • Developers

Agree we need to catch as many errors where possible but we also expect the coder to be due diligent in checking data thrown at the functions.
Just show us a scriptlet that replicates the issue so we can determine whether the UDF needs changes or not.  

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
Local $sortmod[0][2], $sortdis[0][2], $sortothers[0][2], $picdis[0][2]
Local $ksgtc = $objc.Keys()
For $i = 0 To UBound($ksgtc) - 1
    $gtitm = $objc.Item($ksgtc[$i]);always array
    If $gtitm[0] == 'mod' Then
;~      _GETCHNIT($sortmod, $ksgtc[$i], $i)
    Else
        If $gtitm[9] = 128 Then
            If $gtitm[0] == 'pic' Or $gtitm[0] == 'ico' Then
                _ArrayAdd($picdis, $i & '|' & _ArrayToString($gtitm, '<>'))
            Else
                _ArrayAdd($sortdis, $i & '|' & _ArrayToString($gtitm, '<>'))
            EndIf
        Else
            _ArrayAdd($sortothers, $i & '|' & _ArrayToString($gtitm, '<>'))
        EndIf
    EndIf
Next

this is the part of the code that causes the error

Jos, thank

Edited by joiner
Link to post
Share on other sites
  • Developers

.. but that is not a runnable code so doesn't replicate the issue, so doesn't help anybody to determine what the actual issue is. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
2 hours ago, joiner said:

This is an example of the formation of arrays

No, its not.  It is an example of you hoping arrays are formed and then attempting to slam whatever result comes back into an existing array (with qualifications that the returned data may not even meet...).  We will require real data and runnable scripts or this is going to be tedious.

Here is an example of the $picdis branch working, you could craft an example that doesnt work in the same manner if your concern is accurate.

;picdis example

#include<array.au3>

Local $sortmod[0][2], $sortdis[0][2], $sortothers[0][2], $picdis[0][2]
;~ Local $ksgtc = $objc.Keys()
For $i = 0 To 0
    local $gtitm[10]= ['ico',1,2,3,4,5,6,7,8,128];$gtitm = $objc.Item($ksgtc[$i]);always array
    _ArrayDisplay($gtitm)
    If $gtitm[0] == 'mod' Then
;~      _GETCHNIT($sortmod, $ksgtc[$i], $i)
    Else
        If $gtitm[9] = 128 Then
            If $gtitm[0] == 'pic' Or $gtitm[0] == 'ico' Then
                _ArrayAdd($picdis, $i & '|' & _ArrayToString($gtitm, '<>'))
            Else
                _ArrayAdd($sortdis, $i & '|' & _ArrayToString($gtitm, '<>'))
            EndIf
        Else
            _ArrayAdd($sortothers, $i & '|' & _ArrayToString($gtitm, '<>'))
        EndIf
    EndIf
    
    _ArrayDisplay($picdis)
Next

 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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.

  • Similar Content

    • By arunkw
      I have a spreadsheet - daily routine which has two columns: activity and time as shown here
      | Activity             | Time     | |----------------------|----------| | Sleep               |  6:00 am | | Toilet              |  6:15 am | | Get ready for gym  |  6:30 am | | Exercise            |  7:50 am | | ... more things      |  9:00 pm | | ... still more       | 10:45 pm | | Sleep               |  6:00 am |   I wanted to find out, say in C1 which activity is current for me using now() I.e., if it’s 6:45am on my watch, it should show me Exercise  in C1 Thanks to Adam D. PE, this formula works like magic to get the result =VLOOKUP(MOD(NOW(),1),{B2:B,A2:A},2,1)   Now, I want to reproduce same result in autoit, how to do that? To have easy solution say, I copy-paste spreadsheet data in array directly in code, right? Use for loop and run the above vlookup function and show the answer using tooltip. How to achieve this? please help.  
    • By goku200
      I have an Autoit script that lists files from a folder into an array list. Is there a way to separate the filenames by an underscore and include the id, version, name and date into separate columns in Excel.
      Example of filename:
      12345_v1.0_TEST Name [12345]_01.01.2022.html
      12345 would be in one column
      v1.0 would be in another column
      TEST Name [12345] would be in another column
      01.01.2022 would be in another column
      .html would be in another column
      Note: filenames always change each day.
      Here is my code that lists the files into column C and then writes the column Headers into Column D, E, F, G. Just need some help with separating them into columns by the _ delimiter
       
    • By mLipok
      Usually when I collect data from DataBase I need to give EndUser a possibility to select rows which should be taken in the processing loop.
      I was searching on the forum and I'm not able to find any UDF or even example of how to select data from array.
      I have my own solutions but I think they are not worth posting on the forum as it is very old code and I am looking for a better solution.

      Could anybody point me to some examples/solutions ?

      Thank you in advance.
      @mLipok
    • By EmilyLove
      I have a string containing the full path of an executable and an array of executables without their paths. I am trying to compare the string to the list in the array and if a match is found, remove it from the array. The entry get removed from the array successfully, and after checking its return result, uses it to update the ubound if it succeeded, but it doesn't want to update to the new value. Any ideas what I am doing wrong? It acts like it is read-only.
      #include <Array.au3> #include <File.au3> Local $sApp_Exe = "F:\App\Nextcloud\nextcloud.exe" Local $aWaitForEXEX = [3, "Nextcloud.exe", "nextcloudcmd.exe", "QtWebEngineProcess.exe"] For $h = 1 To $aWaitForEXEX[0] If StringInStr($sApp_Exe, $aWaitForEXEX[$h]) <> 0 Then $iRet = _ArrayDelete($aWaitForEXEX, $h) If $iRet <> -1 Then $aWaitForEXEX[0] = $iRet ;this line doesn't work. $aWaitForEXEX[0] doesn't update and shortly gives Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.: _ArrayDisplay($aWaitForEXEX) EndIf Next  
    • By vinnyMS
      #Include <Array.au3> #include <Constants.au3> $s = FileRead("2.txt") Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _ArrayDisplay($w) i have this script that returns 3 columns  
       
      i need to copy the  Col 0 and Col 1 as text to paste on notepad or excel
      you will have to create a "copy" button if possible
      array.au3 2.txt
×
×
  • Create New...