Sign in to follow this  
Followers 0
eHrgo

7 Variables - Which one is the biggest?

15 posts in this topic

Hi all,

I have 7 variables, 7 positive values, I want to know which one is the biggest... is there any command to do that? I searched .. but found nothing.

Thanks

:whistle:


Sorry for my Bad English.

Share this post


Link to post
Share on other sites



Sorry for my bad english, i don't want to check there lenght. I want to check which one of my 10 variables is the highest. I can't use < > ..


Sorry for my Bad English.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If your question has not been answered, at least provide a list of the 7 variables you want to check and their current values.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Hi,

#include<Array.au3>
Global $values[7] = [10,54,3,56,234,324,33]
MsgBox(64, "Highest Value", _ArrayMax($values, 1))

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

Hi,

#include<Array.au3>
Global $values[7] = [10,54,3,56,234,324,33]
MsgBox(64, "Highest Value", _ArrayMax($values, 1))

So long,

Mega

You are assuming he's using an array (which of course is the easiest way) ... but I see no mention of an array being used, only the mention of 7 "different" variables.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

If this is just strings, then he can convert them to an array... but it seems that there a problem:

$String1 = 1
$String2 = 2
$String3 = 3
$String4 = 4
$String5 = 5
$String6 = 6
$String7 = 7

$StringsArr = StringSplit($String1 & "|" & $String2 & "|" & $String3 & "|" & $String4 & "|" & _
    $String5 & "|" & $String6 & "|" & $String7, "|")


$BiggestString = $StringsArr[1]
For $iArr = 1 To $StringsArr[0]
    If $StringsArr[$iArr] > $BiggestString Then $BiggestString = $StringsArr[$iArr]
Next

MsgBox(0, "", $BiggestString)

If we put in $String3 (for example) value that higher then 7, then will returned 7 as biggest value, this even if you use the _ArrayMax() function, and i don't know why...


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

$String1 = 1
$String2 = 2
$String3 = 3
$String4 = 7
$String5 = 5
$String6 = 6
$String7 = 4

$StringsArr = StringSplit($String1 & "|" & $String2 & "|" & $String3 & "|" & $String4 & "|" & _
    $String5 & "|" & $String6 & "|" & $String7, "|")


$BiggestString = 0
For $iArr = 1 To $StringsArr[0]
    If Number($StringsArr[$iArr]) > $BiggestString Then 
        $BiggestString = $StringsArr[$iArr]
        $nString = $iArr
    EndIf
Next

MsgBox(0, "", 'The biggest Num was: ' & $BiggestString & @CR & 'On $String' & $nString)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Or, you can do somthing like that, this will be 100% exact:

$String1 = 1
$String2 = 2
$String3 = 3
$String4 = 4
$String5 = 5
$String6 = 6
$String7 = 7

$BiggestString = $String1
If $String2 > $BiggestString Then $BiggestString = $String2
If $String3 > $BiggestString Then $BiggestString = $String3
If $String4 > $BiggestString Then $BiggestString = $String4
If $String5 > $BiggestString Then $BiggestString = $String5
If $String6 > $BiggestString Then $BiggestString = $String6
If $String7 > $BiggestString Then $BiggestString = $String7

MsgBox(0, "", $BiggestString)

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

MsCreatoR ... again.. the best that any of us would be doing is drawing at straws with guesses without the OP showing what is they are "exactly" trying to do...

But... there are many ways to do what you are showing... here's another if the string vars all had numbers on the end:

Dim $String1 = 1,$String2 = 2,$String3 = 3,$String4 = 7,$String5 = 5,$String6 = 6,$String7 = 4,$BiggestString = 0, $nString = 1
For $iCC = 1 To 7
    If Number(Eval('String' & $iCC)) > $BiggestString Then
        $BiggestString = Eval('String' & $iCC)
        $nString = $iCC
    EndIf
Next
MsgBox(0, "", 'The biggest Num was: ' & $BiggestString & @CR & 'On $String' & $nString)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

SmOke_N

Nice solution, but why the function _ArrayMax() not work like that?

the best that any of us would be doing is drawing at straws with guesses without the OP showing what is they are "exactly" trying to do

Agree! :whistle:

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

SmOke_N

Nice solution, but why the function _ArrayMax() not work like that?

Agree! :whistle:

I would assume that _ArrayMax() isn't working because the $array[n] is more than likely a string, rather than a number, the way you are doing it.... to be honest, I've never even tried _ArrayMax() so I wouldn't be the best to answer it. Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I would assume that _ArrayMax() isn't working because the $array[n] is more than likely a string, rather than a number, the way you are doing it.... to be honest, I've never even tried _ArrayMax() so I wouldn't be the best to answer it.

this works.. but it's for arrays.. err... added better example

;example
;string..
$str = ''
$aArray =  StringSplit('abc,abcd,ab,absdhjgh,123,34,ash34,sddf',',')
_Quick_Sort($aArray, 1, $aArray[0])
For $x = 1 To $aArray[0] 
    $str &= $aArray[$x] &@LF
Next

MsgBox(0,'',$str)


;variables
$str = ''
$1 = 'abc'
$2 = 'abcd'
$3 = 'ab'
$4 = 'sddf3466784534'
$5 = 'absdhjgh'
$6 = 'sddfgjughghjdfhffsdg4'

Local $aArray[8] = [7,$1,$2,$3,$4,$5,$6]

_Quick_Sort($aArray, 1, $aArray[0])
For $x = 1 To $aArray[0]
    $str &= $aArray[$x] &@LF
Next
MsgBox(0,'',$str)


Func _Quick_Sort(ByRef $SortArray, $First, $Last);Larry's code
   Dim $Low, $High
   Dim $Temp, $List_Separator
  
   $Low = $First
   $High = $Last
   $List_Separator = StringLen($SortArray[ ($First + $Last) / 2])
   Do
      While (StringLen($SortArray[$Low]) < $List_Separator)
         $Low = $Low + 1
      WEnd
      While (StringLen($SortArray[$High]) > $List_Separator)
         $High = $High - 1
      WEnd
      If ($Low <= $High) Then
         $Temp = $SortArray[$Low]
         $SortArray[$Low] = $SortArray[$High]
         $SortArray[$High] = $Temp
         $Low = $Low + 1
         $High = $High - 1
      EndIf
   Until $Low > $High
   If ($First < $High) Then _Quick_Sort($SortArray, $First, $High)
   If ($Low < $Last) Then _Quick_Sort($SortArray, $Low, $Last)
EndFunc ;==>_Quick_Sort
Edited by mrRevoked

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

Sorry for my bad english, i don't want to check there lenght. I want to check which one of my 10 variables is the highest. I can't use < > ..

oops. :whistle:


Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

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