Jump to content
Sign in to follow this  
Adolfik

Find largest value

Recommended Posts

Adolfik

I couldn't find it anywhere ;/ so I need to ask here

I got few values like

$1,$2,$3

all are just numbers and I need to find which one of them is the biggest one.

Thanks :blink:

Share this post


Link to post
Share on other sites
Melba23

Adolfik,

How about putting the values into an array and using _ArrayMax? ;)

I couldn't find it anywhere

It is in the Help file! :blink:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
ClayB

How are the values stored? Excel spreadsheet, text file, data structure (array, linked list, etc)? If it is in a text file, is there any other data in the file?

Share this post


Link to post
Share on other sites
cageman

simple way is with if statements.

if $1>=$2 and $1>=$3 Then
$max=$1;
elseif $2>=3 Then
$max=$2;
else
$max=$3;
endif

Share this post


Link to post
Share on other sites
Pottery

Examples

#include <Array.au3>
Dim $Array[4]
$Array[0] = 4
$Array[1] = 9
$Array[2] = 1
$Array[3] = 5
MsgBox(64, 'Example #1', 'The biggest value is ' & _ArrayMax($Array) & '.')

#include <Array.au3>
Dim $Array[4]
$Array[0] = 4
$Array[1] = 9
$Array[2] = 1
$Array[3] = 5
_ArrayDisplay($Array)

#include <Array.au3>
Dim $Array[4]
For $i = 0 to 3
    $Array[$i] = Random(0, 99)
Next
MsgBox(64, 'Example #3', 'The biggest value is ' & _ArrayMax($Array) & '.')
_ArrayDisplay($Array)

Share this post


Link to post
Share on other sites
koman92040

Is there any way to do this with a mufti denominational array, using only one collum?

Share this post


Link to post
Share on other sites
water

"mufti denominational array"? Or do you mean a "multi dimensional array"?

BTW: You necro a thread that is nearly 2 years old.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
koman92040

pardon my spelling "multi dimensional array" here's what i'm doing, I'm using one array to store The Hostame, IP address and Ping response time in a 2 dimensional array (5 by 3) then bases on the Ping response value launch a remote assistance session.

So far I have

TCPStartup()
$input = InputBox(@ScriptName, "Hostname:",)
If @error Then
TCPShutdown()
Exit
EndIf
$hostname = StringStripWS($input, 8)
Dim $ping[5][3] = [[4],[$hostname],[$hostname & ".example.com"],[$hostname & ".in.example.com"],[$hostname & ".corp.in.example.com"]]
While 1
For $loop = 1 To $ping[0][0]
  $ping[$loop][1] = TCPNameToIP($ping[$loop][0])
  $ping[$loop][2] = Ping($ping[$loop][1])
Next
For $loop = 1 To $ping[0][0]
  If $ping[$loop][2] Then
   TrayTip("Launching Connection", "Remote Assistance is launching a connection to " & $ping[$loop][0] & " at " & $ping[$loop][1] & " wich responded in " & $ping[$loop][2] & "ms", 30)
   Run("msra.exe /offerra " & $ping[$loop][1])
   ExitLoop
  EndIf
Next
WEnd
TCPShutdown()

but right now it users the first pingable FQDN, i want the fastest responding FQDN.

I realize this is an old post, i goggled and found this topic and thought it was applicable to what i'm doing. If

Share this post


Link to post
Share on other sites
water

I would use something like this to use the fastest connection:

$input = InputBox(@ScriptName, "Hostname:",)
If @error Then Exit
TCPStartup()
$hostname = StringStripWS($input, 8)
Global $ping[5][3] = [[4],[$hostname],[$hostname & ".example.com"],[$hostname & ".in.example.com"],[$hostname & ".corp.in.example.com"]]
Global $iFastestValue = 9999999999999, $iFastestIndex = 0
While 1
    For $loop = 1 To $ping[0][0]
        $ping[$loop][1] = TCPNameToIP($ping[$loop][0])
        $ping[$loop][2] = Ping($ping[$loop][1])
        If $ping[$loop][2] > 0 And $ping[$loop][2] < $iFastestValue Then
            $iFastestValue = $ping[$loop][2]
            $iFastestIndex = $loop
        EndIf
    Next
    TrayTip("Launching Connection", "Remote Assistance is launching a connection to " & $ping[$iFastestIndex][0] & " at " & $ping[$iFastestIndex][1] & " wich responded in " & $ping[$iFastestIndex][2] & "ms", 30)
    Run("msra.exe /offerra " & $ping[$iFastestIndex][1])
    ExitLoop
WEnd
TCPShutdown()
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
koman92040

Thanks so much!

Share this post


Link to post
Share on other sites
water
:D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×