highest or lowest variable in an array; how do you find it?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: highest or lowest variable in an array; how do you find it?

    I'll take a shot at it as well, but the gurus have already replied, this is just a little different.

    Code:
    i       var byte
    lowest  var byte
    highest var byte
    myarray var byte[50]
    
    for i = 0 to 48
       Highest= MyArray[i] MAX MyArray[i+1]
       Lowest= MyArray[i] MIN MyArray[i+1]
    next i
    ScaleRobotics, I hope you had good internet free holidays

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: highest or lowest variable in an array; how do you find it?

    I don't think Megahertz code will work as it is resetting the maximum and minimum value each pass thru the loop. NO testing is being done against the variables "Highest" and "Lowest"....
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: highest or lowest variable in an array; how do you find it?

    OOps, my mistake. Instead use the following:

    Code:
    i       var byte
    lowest  var byte
    highest var byte
    CheckHigh Var Byte
    CheckLow Var Byte
    myarray var byte[50]
    
    CheckHigh=0 : CheckLow=255
    for i = 0 to 48
       CheckHigh= MyArray[i] MAX MyArray[i+1]
       If CheckHigh>Highest then Highest=CheckHigh
       Lowest= MyArray[i] MIN MyArray[i+1]
       If CheckLow<Lowest then Lowest=CheckLow
    next i
    Thanks Dave for correcting me
    Last edited by Megahertz; - 13th July 2012 at 17:10.

  4. #4
    Join Date
    Dec 2009
    Location
    Kalamazoo
    Posts
    42


    Did you find this post helpful? Yes | No

    Default Re: highest or lowest variable in an array; how do you find it?

    thanks guys .
    i was thinking of doing it like post #2, and i thought there was an easier way to skin it. this really helps alot with all this options.
    NAG CON WIFE!
    WIFE VAR MOOD

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts