Jump to content

_ArrayAdd - function error


joiner
 Share

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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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
 Share

×
×
  • Create New...