SORT/de
From MCS Wiki AVR
< SORT(Difference between revisions)
m (1 revision) |
(→Example) |
||
(3 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | + | = <span class="f_Header">Funktion</span> = | |
− | + | Sortiert ein Array in aufsteigender Reihenfolge. | |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
Line 15: | Line 15: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | = <span class="f_Header"> | + | = <span class="f_Header">Anmerkungen</span> = |
<div style="padding: 0px; margin: 0px 0px 0px 4px;"> | <div style="padding: 0px; margin: 0px 0px 0px 4px;"> | ||
{| width="488" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;" | {| width="488" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;" | ||
Line 23: | Line 23: | ||
| valign="top" width="100%" style="width: 376px; border: 1px solid rgb(0, 0, 0);" | | | valign="top" width="100%" style="width: 376px; border: 1px solid rgb(0, 0, 0);" | | ||
− | + | Das erste Element des zu sortierenden Arrays. | |
|- style="vertical-align: top;" | |- style="vertical-align: top;" | ||
Line 30: | Line 30: | ||
| valign="top" width="100%" style="width: 376px; border: 1px solid rgb(0, 0, 0);" | | | valign="top" width="100%" style="width: 376px; border: 1px solid rgb(0, 0, 0);" | | ||
− | + | Anzahl der zu sortierenden Elemente. Optionaler Parameter. Standardmäßig werden alle Elemente sortiert. | |
|} | |} | ||
Line 36: | Line 36: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | + | Sortieren funktioniert für Byte, Word und Integer Arrays. | |
− | + | Die Routinen sind in der mcs.lib. | |
| | ||
Line 46: | Line 46: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | = <span class="f_Header"> | + | = <span class="f_Header">Siehe auch</span> = |
<span style="font-family: Arial;">NONE</span> | <span style="font-family: Arial;">NONE</span> | ||
Line 54: | Line 54: | ||
<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 60: | Line 60: | ||
' SORT.BAS | ' SORT.BAS | ||
' (c) 1995-2011 , MCS Electronics | ' (c) 1995-2011 , MCS Electronics | ||
− | ' | + | ' Dieses Programm demonstriert den SORT-Befehl. Ein Array wird sortiert. |
− | ' | + | ' SORT unterstützt Byte, Integer und Word Arrays. |
'------------------------------------------------------------------------------ | '------------------------------------------------------------------------------ | ||
$regfile = "m88def.dat" | $regfile = "m88def.dat" | ||
Line 69: | Line 69: | ||
$framesize = 30 | $framesize = 30 | ||
− | ' | + | 'Arrays DIMensionieren: |
Dim B(10) As Byte , I(10) As Integer , W(10) As Word | Dim B(10) As Byte , I(10) As Integer , W(10) As Word | ||
Dim J As Byte | Dim J As Byte | ||
− | ' | + | 'Auf Datenbereich zeigen: |
Restore Arraydata | Restore Arraydata | ||
− | ' | + | 'Daten lesen: |
For J = 1 To 10 | For J = 1 To 10 | ||
Read B(j) | Read B(j) | ||
Next | Next | ||
− | ' | + | 'Words lesen_ |
For J = 1 To 10 | For J = 1 To 10 | ||
Read W(j) | Read W(j) | ||
Next | Next | ||
− | ' | + | 'Integer lesen: |
For J = 1 To 10 | For J = 1 To 10 | ||
Read I(j) | Read I(j) | ||
Next | Next | ||
− | ' | + | 'Arrays sortieren: |
− | Sort B(1) , 10 ' 10 | + | Sort B(1) , 10 ' 10 Elemente |
− | Sort W(1) ' | + | Sort W(1) ' Alle Elemente |
Sort I(1) | Sort I(1) | ||
− | ' | + | 'Ergebnisse anzeigen: |
For J = 1 To 10 | For J = 1 To 10 | ||
Print J ; " " ; B(j) ; " " ; W(j) ; " " ; I(j) | Print J ; " " ; B(j) ; " " ; W(j) ; " " ; I(j) |
Latest revision as of 23:13, 9 March 2013
Contents |
Funktion
Sortiert ein Array in aufsteigender Reihenfolge.
Syntax
SORT array() [,elements]
Anmerkungen
array() |
Das erste Element des zu sortierenden Arrays. |
elements |
Anzahl der zu sortierenden Elemente. Optionaler Parameter. Standardmäßig werden alle Elemente sortiert. |
Sortieren funktioniert für Byte, Word und Integer Arrays.
Die Routinen sind in der mcs.lib.
Siehe auch
NONE
Beispiel
'------------------------------------------------------------------------------- ' SORT.BAS ' (c) 1995-2011 , MCS Electronics ' Dieses Programm demonstriert den SORT-Befehl. Ein Array wird sortiert. ' SORT unterstützt Byte, Integer und Word Arrays. '------------------------------------------------------------------------------ $regfile = "m88def.dat" $crystal = 8000000 $hwstack = 16 $swstack = 8 $framesize = 30 'Arrays DIMensionieren: Dim B(10) As Byte , I(10) As Integer , W(10) As Word Dim J As Byte 'Auf Datenbereich zeigen: Restore Arraydata 'Daten lesen: For J = 1 To 10 Read B(j) Next 'Words lesen_ For J = 1 To 10 Read W(j) Next 'Integer lesen: For J = 1 To 10 Read I(j) Next 'Arrays sortieren: Sort B(1) , 10 ' 10 Elemente Sort W(1) ' Alle Elemente Sort I(1) 'Ergebnisse anzeigen: For J = 1 To 10 Print J ; " " ; B(j) ; " " ; W(j) ; " " ; I(j) Next End Arraydata: Data 1 , 4 , 8 , 9 , 2 , 5 , 3 , 7 , 6 , 4 Data 1000% , 101% , 1% , 400% , 30000% , 20000% , 15000% , 0% , 999% , 111% Data -1000% , 101% , -1% , 400% , 30000% , 2000% , -15000% , 0% , 999% , 111%
Languages | English • Deutsch |
---|