Jump to content

7 Variables - Which one is the biggest?


eHrgo
 Share

Recommended Posts

  • Moderators

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

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.

Link to comment
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

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
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...

 

Spoiler

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...

Spoiler

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

Link to comment
Share on other sites

  • Moderators

$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)

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.

Link to comment
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)

 

Spoiler

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...

Spoiler

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

Link to comment
Share on other sites

  • Moderators

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)

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.

Link to comment
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:

 

Spoiler

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...

Spoiler

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

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
Share on other sites

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()
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...