Jump to content

Problem with _ArraySort


Recommended Posts

Hey guys, could one of you please attempt to duplicate this problem... or tell me what I'm doing wrong.

Code Sample:

#include <array.au3>
$file = @ScriptDir & "\test.ini"
$aData = IniReadSection($file, "Settings")
_ArraySort($aData) ; sort descending
_ArrayDisplay($aData)

INI Sample:

[Settings]
081728=x
082139=y
082555=p
082911=u

Error I am receiving:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\xxxxx\My Documents\AutoIt Scripts\Testing\testing.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams    
+>08:39:10 Starting AutoIt3Wrapper v.1.9.4
>Running AU3Check (1.54.10.0)  from:C:\Program Files\AutoIt3
+>08:39:10 AU3Check ended.rc:0
>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\xxxxx\My Documents\AutoIt Scripts\Testing\testing.au3"  
C:\Program Files\AutoIt3\Include\array.au3 (666) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
$t = $array[$i] 
$t = ^ ERROR
->08:39:11 AutoIT3.exe ended.rc:1
+>08:39:12 AutoIt3Wrapper Finished
>Exit code: 1   Time: 2.525

It never gets to the _ArrayDisplay

Thanks,

-Spook

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

My first thought was that you need to skip sorting element zero, however....

This works:

#include 
$file = @ScriptDir & "\test.ini"
$aData = IniReadSection($file, "Settings")
_ArraySort($aData, 0, 1, 1, 1) ; sort ascending
_ArrayDisplay($aData)oÝ÷ Ù8b±Ú²}ý·
+«­¢+Ø¥¹±Õ(ÀÌØí¥±ôMÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈíÑÍй¥¹¤ÅÕ½Ðì(ÀÌØíÑô%¹¥IMÑ¥½¸ ÀÌØí¥±°ÅÕ½ÐíMÑÑ¥¹ÌÅÕ½Ðì¤)}ÉÉåM½ÉÐ ÀÌØíѰİİİĤìͽÉÐ͹¥¹)}ÉÉå¥ÍÁ±ä ÀÌØíÑ
Link to comment
Share on other sites

Hey guys, could one of you please attempt to duplicate this problem... or tell me what I'm doing wrong.

Hi,

Works fine in 3.2.11.0

That corrected array sort to automatically detect 2D array ubound in parameter 4 (see helpfile)

Otherwise, set it manually

Best, Randall

Link to comment
Share on other sites

Hi,

Works fine in 3.2.11.0

That corrected array sort to automatically detect 2D array ubound in parameter 4 (see helpfile)

Otherwise, set it manually

Best, Randall

The help file I have does not expound on the ubound parameter very much.

Could you elaborate?

[edit]

I've tried from 0-5 in that parameter and they all fail

[/edit]

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Thanks for the help guys,

looks like (through trial and error) it was the $i_dim parameter that was causing the problem.

This works for me:

#include <array.au3>
$file = @ScriptDir & "\test.ini"
$aData = IniReadSection($file, "Settings")
_ArraySort($aData,1,1,0,2,0); sort descending
_ArrayDisplay($aData)

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Thanks for the help guys,

looks like (through trial and error) it was the $i_dim parameter that was causing the problem.

This works for me:

#include <array.au3>
$file = @ScriptDir & "\test.ini"
$aData = IniReadSection($file, "Settings")
_ArraySort($aData,1,1,0,2,0); sort descending
_ArrayDisplay($aData)
Correct!

I meant 4th parameter after the arrayname!

Oh well. why did you not just use 3.2.11.0 ?; its easier!

; ArSort.au3
#include <array.au3>
$file = @ScriptDir & "\testers.ini"
$aData = IniReadSection($file, "Settings")
_ArrayDisplay($aData)
_ArraySort($aData,1,1,UBound($aData,1)-1,UBound($aData,2),0) ; sort descending on 1st column (0)
_ArrayDisplay($aData,"sort descending on 1st column (0)")
_ArraySort($aData,1,1,UBound($aData,1)-1,UBound($aData,2),1) ; sort descending on 2nd column (1)
_ArrayDisplay($aData,"sort descending on 2nd column (1)");sort descending on 2nd column (1))

;_ArraySort ( ByRef $a_Array [, $i_Descending [, $i_Base=0 [, $i_Ubound=0 [, $i_Dim=1 [, $i_SortIndex=0 ]]]]] )
best, randall [above is all for 3.2.10.0]
Link to comment
Share on other sites

Oh well. why did you not just use 3.2.11.0 ?; its easier!

I was tempted... but there are other people who may also use the larger code that I am working on and they are all on 3.2.10.0.

The word beta scares them for some reason. :D

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...