 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
NoviceARRAY Guest
|
Posted: Sat Jan 26, 2008 1:20 am Post subject: Eval Question |
|
|
Hi, I have this question about evaluation of vars.
If I have something like this
CONTAINER1=100
CONTAINER2=150
CONTAINER3=2500
CONTAINER4=300
..
..
..
..
CONTAINER99=100
and so forth, ... where the Var is structured like CONTAINERn (n=1-??)... and where each one equal to some number. I might have (any) number of these CONTAINERS generated.... how can I understand which CONTAINER # holds the largest number, and store the name of the Var in another var, WHICHONE? So, if I did a
MSGBOX, %WHICHONE%
Would result in CONTAINER3 using the above example parameters.
Thank you for helping me to figure this out. Have a very nice day. |
|
| Back to top |
|
 |
Mustang
Joined: 17 May 2007 Posts: 375 Location: England
|
Posted: Sat Jan 26, 2008 3:14 am Post subject: |
|
|
| Code: | Container1=100
Container2=150
Container3=2500
Container4=300
ContainerCount=4
ContainerHighest=0
Loop, %ContainerCount%
{
If ( Container%A_Index% > ContainerHighest )
{
ContainerHighest := Container%A_Index%
WhichOne = Container%A_Index%
}
}
MsgBox, %WhichOne% |
|
|
| Back to top |
|
 |
NoviceARRAY Guest
|
Posted: Sat Jan 26, 2008 4:29 pm Post subject: |
|
|
Brilliant! I was never so good at math, but this helps me a great deal. Thank you so much for your earlier diagram.
Could you please help me take this one step further, and perhaps turn it into a special function? You see, I actually have 4 of these containers, with decreasing levels of importance to evaluate.
So it visually would look like/flow like,
Container1_Level1=400
Container2_Level1=500
Container3_Level1=2000
Container4_Level1=2500
Container5_Level1=50
Container6_Level1=2000
Container7_Level1=50
Container1_Level2=250
Container2_Level2=5500
Container3_Level2=1000
Container4_Level2=1500
Container5_Level2=500
Container6_Level2=1100
Container7_Level2=500
Container1_Level3=2150
Container2_Level3=1500
Container3_Level3=51000
Container4_Level3=100
Container5_Level3=5
Container6_Level3=700
Container7_Level3=6
Container1_Level4=2150
Container2_Level4=1500
Container3_Level4=51000
Container4_Level4=100
Container5_Level4=150000
Container6_Level4=300
Container7_Level4=1
So, in association, Container1_Level1, Container2_Level2, Container3_Level3, Container4_Level4 ... are all associated to each other in the same number group.
It would look like this spread out:
Container4, with 2500,1500,100,100
Container6, with 2000,1100,700,300
Container3, with 2000,1000,51000,51000
Container2, with 500,5500,1500,1500
Container1, with 400,250,2150,2150
Container7, with 50,500,6,1
Container5, with 50,500,5,150000
There may be 100 containers... but only (4) Levels of numbers.
But, what I want to do simply is, if the Variables are structured like this (After having been generated in a loop), I want to kind of sort this tree of data, and understand which Container based on preference of the Level, Level 1 being top priority, is the Winner from the group (much like how a Spreadsheet would Auto-Sort a table in decreasing values from the first Column) ... you can see where for example Container 7 wins over Container 5 since the 3rd spot (level3) has the 5000. I just threw a 150000 in the Container 5 last spot to demonstrate the logic here.
So, basically same idea here, ping MsgBox %WHICHONE% would I hope tell me Container4
Can you see this easier than I can? I was messing with loops and such, and what I have doesn't work at all (!) and I'm afraid the end result is very unreliable and something of a Frankenstein experiment than anything graceful, instead of being totally sure I am getting the right result.... from a sea of data.
Best wishes, Novice. |
|
| Back to top |
|
 |
NoviceARRAY Guest
|
Posted: Sat Jan 26, 2008 4:32 pm Post subject: |
|
|
Oops, one slight correction,
This sentence above should actually say to be formed correct:
So, in association, Container1_Level1, Container1_Level2, Container1_Level3, Container1_Level4 ... are all associated to each other in the same number group.  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|