Jump to content
joiner

_ArrayAdd - function error

Recommended Posts

this is a project. over 3000 lines of main code

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

what reasons can be?

Share this post


Link to post
Share on other sites

What version do you have as that appears on line 111 whereas v 3.3.14.5 it appears on line 156?  When I said post your code, I mean post what your $vValue is as it's obviously an issue with splitting the $vValue.

Share this post


Link to post
Share on other sites
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

Share this post


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 :)


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

sorry, it was not exactly expressed

if the data is incorrect, the function(_ArrayAdd) should return an error
 

;~ array.au3

If Not IsArray($avArray) Then Return SetError(1, 0, -1)

$vValue - always string

when I am mistaken, it points to my line, but not to a line in udf

Thanks for the discussion. I will think

 

Share this post


Link to post
Share on other sites

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

Share this post


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

Share this post


Link to post
Share on other sites

.. 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

Share this post


Link to post
Share on other sites

This is an example of the formation of arrays. I will not pester you with questions. Waiting for updates from the user of my program

Share this post


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

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

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 sksbir
      Hi
      Trying this from autoit v3.3.14.5 and SCITE 3.19.102.1901.0 :
      help file , page "Language Reference - Variables" , sample autoit script about maps:

      Maps must be declared before use by defining their scope using the 'Global/Local/Static' keywords. Local $mControls[]
      So is my test script : only with this local declation.
      -check syntax is OK
      - running script : 

      test.au3" (13) : ==> Variable subscript badly formatted.: Local $mControls[] Local $mControls[^ ERROR ->14:51:49 AutoIt3.exe ended.rc:1
      any clue ?
    • 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
×
×
  • Create New...