Jump to content
Sign in to follow this  
brodie28

Problem with a script I am making

Recommended Posts

I am making a script which is supposed to get the highest 50 numbers of the data I put in.

I have worked out how to populate the array... My problem is how I can go about getting the highest 50 in order... DO I populate it first or sort them as I go... How should I sort them?

Share this post


Link to post
Share on other sites

I am making a script which is supposed to get the highest 50 numbers of the data I put in.

I have worked out how to populate the array... My problem is how I can go about getting the highest 50 in order... DO I populate it first or sort them as I go... How should I sort them?

_ArraySort() can sort the array Descending after which you can list the first 50 entries.

Make sure you save the values in numeric format in stead of alphanumeric by ysing the Number() function.

Edited by JdeB

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

Share this post


Link to post
Share on other sites

The problem I have is that there are four arrays.

I have

Names[50]

ids[50]

numbers[50]

They are all tied to each other so if I change the order of one array it will mess up the others.

Share this post


Link to post
Share on other sites

The problem I have is that there are four arrays.

I have

Names[50]

ids[50]

numbers[50]

They are all tied to each other so if I change the order of one array it will mess up the others.

The easiest way is to make it one Array like $Records[50][3]...

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

Share this post


Link to post
Share on other sites

How do I use functions like _ArrayMin with Multidimensional arrays?

I have the number saved at $array[1][0][0][0], $array[2][0][0][0] etc.

How would I use That function to find the smallest number?

Share this post


Link to post
Share on other sites

How do I use functions like _ArrayMin with Multidimensional arrays?

I have the number saved at $array[1][0][0][0], $array[2][0][0][0] etc.

How would I use That function to find the smallest number?

Think your are approaching it the wrong way.

Your Array has to be defined as:

Dim $Array[50][4]

Then the 4 values for the first record are set in this way:

$Array[0][0] = Number("Field 1 value")

$Array[0][1] = "Field 2 value"

$Array[0][2] = "Field 3 value"

$Array[0][3] = "Field 4 value"

Fill all 50 records and then sort the Array :

Here is an example program to get you started:

#include<array.au3>
Dim $Array[50][4]

;Then the 4 values for the first record are set in this way:
For $x = 0 to 49
    $Array[$x][0] = Random(1,100,1) 
    $Array[$x][1] = "Record:" & $x 
    $Array[$x][2] = "Field 3 value" 
    $Array[$x][3] = "Field 4 value" 
Next
;Fill all 50 records and then sort the Array :
_ArraySort($Array,1,0,0,4,0)
; Now list them
For $x = 0 to 49
    Msgbox (0," record:" & $x, " Field 1:" & $Array[$x][0] & @LF & _
    $Array[$x][1] & @LF & _
    $Array[$x][2] & @LF & _
    $Array[$x][3] & @LF)
Next

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

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  

×
×
  • Create New...