Snippet to determinate what variable got the lowest value

Morgan

Пользователь
Регистрация
30.11.2015
Сообщения
118
Благодарностей
12
Баллы
18
Hi.

I have been making a template in zennoposter were i get 5 values, I have converted those values into the correct integer format using reg exp. and javascript.

I do now look to return the variable with the lowest value, just like the Math.min(varA,VarB,varC) Except that i want to return the variable name itself to use it in a switch to decide my next action.

Maybe there is some easier way also, i tried to store values in a table to search but failed to do so.

Thanks

 

Tobbe

Client
Регистрация
01.08.2013
Сообщения
428
Благодарностей
148
Баллы
43
Put it to a list, sort, then List Processing -> Get Line - and put it to a variable.

 
  • Спасибо
Реакции: Morgan

Morgan

Пользователь
Регистрация
30.11.2015
Сообщения
118
Благодарностей
12
Баллы
18

Tobbe

Client
Регистрация
01.08.2013
Сообщения
428
Благодарностей
148
Баллы
43
Thanks, but that will return the integer, i would like the variable name to be returne :-)
If you take the first line, that will be the lowest value. So instead of getting the variable name, you can set the lowest value to a variable name of your choice.
Gonna need further examples of what you're trying to do, otherwise I don't see why this shouldn't work for you.

I don't think it's possible to get the variable name, but I'm sure there's some workaround.
 

Morgan

Пользователь
Регистрация
30.11.2015
Сообщения
118
Благодарностей
12
Баллы
18
If you take the first line, that will be the lowest value. So instead of getting the variable name, you can set the lowest value to a variable name of your choice.
Gonna need further examples of what you're trying to do, otherwise I don't see why this shouldn't work for you.

I don't think it's possible to get the variable name, but I'm sure there's some workaround.
Ok, I will try as good as i can.

There is 5 rows of text i am getting which all contains an area along with a timer, i have stored the timer in seconds to a variable named the area, and then i want to check which are has the lowest timer at this given point so i can set the pause and interact with the correct area.

I know a way i could do this by using 5 if boxes which all contains England<American&&England<Brazil&&England<South-Africa with a false line going to next bog America<England&&America<Brazil&&America<South-Africa and so on and just nest them all together, but it would been great if i could get the variable name and use a switch with all the variables name like this:

Default:
England:
America:
Brazil:
South-Africa:

Just to keep my template a bit more tidy and efficent :-)
 

Tobbe

Client
Регистрация
01.08.2013
Сообщения
428
Благодарностей
148
Баллы
43
If you have the latest version you can use this function, I don't so I still haven't tested it.
[+] Two new options have been added to operations with tables: Sorting by columns and Remove dublicates by columns.
So instead of putting it to a list, you put it to a table, and the table would look like this:
England|50
America|20
Brazil|10
South-Africa|30
Then sort with the function mentioned above.
Brazil|10
America|20
South-Africa|30
England|50
Then Table -> Get Line -> To Variables.

 
  • Спасибо
Реакции: Morgan
Регистрация
16.05.2014
Сообщения
145
Благодарностей
23
Баллы
18

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)