MAX/de
(Difference between revisions)
m (1 revision) |
(→Example) |
||
Line 87: | Line 87: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | = <span class="f_Header"> | + | = <span class="f_Header">Beispiel</span> = |
<br/><source lang="bascomavr"> | <br/><source lang="bascomavr"> | ||
Line 99: | Line 99: | ||
'----------------------------------------------------------------------------------------- | '----------------------------------------------------------------------------------------- | ||
− | $regfile = "m48def.dat" ' | + | $regfile = "m48def.dat" ' Mikrocontroller |
− | $crystal = 4000000 ' | + | $crystal = 4000000 ' Taktfrequenz |
− | $baud = 19200 ' | + | $baud = 19200 ' Baudrate |
$hwstack = 32 ' default use 32 for the hardware stack | $hwstack = 32 ' default use 32 for the hardware stack | ||
$swstack = 10 ' default use 10 for the SW stack | $swstack = 10 ' default use 10 for the SW stack | ||
Line 107: | Line 107: | ||
− | ' | + | ' Diese Funktionen arbeiten nur mit BYTE- und WORD-Arrays !!!!! |
'Dim some variables | 'Dim some variables | ||
Dim Wb As Byte , B As Byte | Dim Wb As Byte , B As Byte | ||
− | Dim W(10) As Word ' | + | Dim W(10) As Word ' oder benutzen Sie ein Byte-Array |
− | ' | + | 'Füllen des Word-Arrays mit Werten von 1 bis 10 |
For B = 1 To 10 | For B = 1 To 10 | ||
W(b) = B | W(b) = B |
Revision as of 01:22, 10 March 2013
Contents |
= (**COPIED FROM ENGLISH PAGE**) === Action
Returns the maximum value of a byte or word array.
Syntax
var1 = MAX(var2)
MAX(ar(1), m ,idx)
Remarks
var1 |
Variable that will be assigned with the maximum value. |
var2 |
The first address of the array. |
|
|
|
The MAX statement can return the index too |
Ar(1) |
Starting element to get the maximum value and index of. |
M |
Returns the maximum value of the array. |
Idx |
Return the index of the array that contains the maximum value. Returns 0 if there is no maximum value. |
The MIN() and MAX() functions work on BYTE and WORD arrays only.
See also
Beispiel
'----------------------------------------------------------------------------------------- 'name : minmax.bas 'copyright : (c) 1995-2005, MCS Electronics 'purpose : show the MIN and MAX functions 'micro : Mega48 'suited for demo : yes 'commercial addon needed : no '----------------------------------------------------------------------------------------- $regfile = "m48def.dat" ' Mikrocontroller $crystal = 4000000 ' Taktfrequenz $baud = 19200 ' Baudrate $hwstack = 32 ' default use 32 for the hardware stack $swstack = 10 ' default use 10 for the SW stack $framesize = 40 ' default use 40 for the frame space ' Diese Funktionen arbeiten nur mit BYTE- und WORD-Arrays !!!!! 'Dim some variables Dim Wb As Byte , B As Byte Dim W(10) As Word ' oder benutzen Sie ein Byte-Array 'Füllen des Word-Arrays mit Werten von 1 bis 10 For B = 1 To 10 W(b) = B Next Print "Max number " ; Max(w(1)) Print "Min number " ; Min(w(1)) Dim Idx As Word , M1 As Word Min(w(1) , M1 , Idx) Print "Min number " ; M1 ; " index " ; Idx Max(w(1) , M1 , Idx) Print "Max number " ; M1 ; " index " ; Idx End
Languages | English • Deutsch |
---|