Sign in to follow this  
Followers 0
MrMikl

_ArraySort, AU3 (1.7.1) and multiple dim arrays

7 posts in this topic

Hi

I am trying to compare prices, along with other data, and simply list them in lowest price to highest price. I did see the listview control mentioned by someone else. In fact, in another forum, they gave the correct syntax that does not appear to be in the help screen.

At any rate, unless the Ubound is a even number and not an odd number, _ArraySort appears to work. No matter how I changed the parameters, _ArraySort blanks out the array.

#include <array.au3>

Dim $price[$max][$max]

Dim $Products[$max]

;load prices from database using a text file

; the prices do load cause I used a While loop to display the prices after the load and after sort

; Another PS DisplayArray function is no longer available in 1.7.1

$num = Int($num)

_ArraySort($price, 0, 0, 0, UBound($price, 1), 2)

; these parameters are the only ones that do not throw an error. I tried UBound($price, 2), etc

; it gives me a division error, the array must be an even number. To get the correct number, of 155,

; throws a division error.

; price{1][$loopnumber] = the record number. so I can arraign $price with the correct array entry

; for $Products

; When I try to find the record number, the array price[1][$loopnumber], $price[0][$loopnumber] is blank

; I will try the list view option next.

Exit

Is there ANY error checking in this compiler? There is no list of error codes. There seems to be no Try Catch or ON ERROR.

Am I using the BETA version?

Thanks for any answers you may provide

MrMikl

mrmikl@yahoo.com

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Check if you have in your array at zero index stored number of items. If so then in _ArraySort() you must specify $i_Base = 1 instead of $i_Base = 0

For check array content use _ArrayDisplay() - before/after sort.

EDIT: also instead

_ArraySort($price, 0, 0, 0, UBound($price, 1), 2)

try

_ArraySort($price, 0, 0, 0, UBound($price, 1) - 1, 2)

Edited by Zedna

Share this post


Link to post
Share on other sites

Just remember this

_ArrayDisplay

--------------------------------------------------------------------------------

Displays a 1-dimensional array in a message box.

1 dimension only

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Just remember this

1 dimension only

8)

You are right. Sometimes ago I made changed _ArrayDisplay2() for display at one line texts from all dimensions for that row together - for testing purposes. It's primitive correction to standard _ArrayDisplay()

Edited by Zedna

Share this post


Link to post
Share on other sites

hi

Thanks all but, I do know that _ArrayDisplay is for one dimensional arrays.

Thats not what the help file says, however, and the syntax is backwards. No one

has mentioned if I am using an older verision or a beta version, 1.7.1

At any rate, no, the examples you gave me for _ArraySort, but when it works,

_ArraySort will empty the array. I have tried to figure out what the meaning behind

some of the parameters mean, but the help file is very vague about this.

price[0] will all be empty strings or blanks and price[1] will be all zeros

They are all zero based, and it does not like a zero in the third numeric option.

I do redim the array before doing the sort, because I dont need a lot of empty values anyway.

If thats what you are thinking, it would put blanks on top. I did a while...wend loop and did a

MsgBox and printed each value. If I do NOT do the array sort, then its ok, but if do the sort, its

empty. a puzzle.

Mike

Share this post


Link to post
Share on other sites

I do redim the array before doing the sort, because I dont need a lot of empty values anyway.

If thats what you are thinking, it would put blanks on top. I did a while...wend loop and did a

MsgBox and printed each value. If I do NOT do the array sort, then its ok, but if do the sort, its

empty. a puzzle.

Post a stripped example that shows the issue you have, maybe that helps to understand what goes wrong .....

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi,

this topic has been closed in support section. What to do? Is it open/closed/answered?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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
Sign in to follow this  
Followers 0