| |
|
|
Michael Wodrich | Operators
Operators knows Profan first since the Version 6. before get mathematical and Verknüpfungs-Operationen over functions Done. The functions existieren from Kompatibilitätsgründen furthermore, can but for zukünfige versions of XProfan not guaranteeing go.
there's following Operators:
<b>Zuweisung:</b>
Var = expression | Wertzuweisung | |
with the Wertzuweisung any Variablentypen possible. The expression ought to of equal type his as Variable. some values go automatically konvertiert (Int <--> LongInt, Int+LongInt -> Float). for (String <--> Int) ought to one always Konvertierungsfunktionen using ( @LINKF:[Int], @LINKF:[Str]$ ).
<b>String:</b>
A$ + B$ | Strings verknüpfen; old: @Add$(A$,B$) | A$ = B$ | comparison: Gleichheit; old: @Equ$(A$,B$) | A$ <> B$ | comparison: Ungleichheit; old: @NEq$(A$,B$) | |
The Datentyp is here always of type String.
<b>Mathematisch:</b>
A% + B% | Addition; old: @Add(A%,B%) | A% - B% | Subtraktion; old: @Sub(A%,B%) | A% * B% | Multiplikation; old: @Mul(A%,B%) | A% / B% | Division; old: @Div(A%,B%) | A% B% | ganzzahlige Division: 5 2 = 2 (remainder falls lane); old: @Div&(A%,B%) | A% MOD B% | Modulo/Teilungsrest: 5 mod 2 = 1 (the remainder the Division); old: @Mod(A%,B%) | A% ^ B% | Potenz; old: @Pow(A%,B%) | |
The Datentyp Integer (<b>%</b>) standing here stellvertretend for: <b>%</b> (Integer), <b>&</b> (LongInt), <b>!</b> (Float).
<b>Relational:</b>
A% < B% | comparison: small as (less than); old: @LT(A%,B%) | A$ < B$ | comparison: small as (less than); old: @LT$(A$,B$) | A% <= B% | comparison: small or same (less or equal); (there were not as function) | A$ <= B$ | comparison: small or same (less or equal); (there were not as function) | A% > B% | comparison: greater as (greater than); old: @GT(A%,B%) | A$ > B$ | comparison: greater as (greater than); old: @GT$(A$,B$) | A% >= B% | comparison: greater or same (greater or equal); (there were not as function) | A$ >= B$ | comparison: greater or same (greater or equal); (there were not as function) | A% = B% | comparison: Gleichheit; old: @Equ(A%,B%) | A% <> B% | comparison: Ungleichheit; old: @NEq(A%,B%) | |
The Datentyp Integer (<b>%</b>) standing here stellvertretend for: <b>%</b> (Integer), <b>&</b> (LongInt), <b>!</b> (Float).
<b>Logisch:</b>
A% AND B% | logisches UND | A% OR B% | logisches ODER | NOT(A%) | logisches NOT (existing <b>nur</b> as function) | |
The Datentyp Integer (<b>%</b>) standing here stellvertretend for: <b>%</b> (Integer), <b>&</b> (LongInt).
<b>Binär:</b>
A% & B% | binäres UND | A% | B% | binäres ODER | A% << B% | Bits to left schieben (in Delphi: SHL) | A% >> B% | Bits to right schieben (in Delphi: SHR) | |
The Datentyp Integer (<b>%</b>) standing here stellvertretend for: <b>%</b> (Integer), <b>&</b> (LongInt).
If the - too Parameter part (How about with LINKP:[WINDOW] and the many <a href="https://XProfan.com/index.mx?online-Documentation-rubriken/rub8">Grafik-Befehlen</a>), is it necessary Subtraktionen einzuklammern, about: Window a%,(b% - 5) - (c% - 6),500
Anderenfalls can the Parser confusion get and there's Fehlermeldungen.
The Operators are following Hierarchiestufen eingeteilt:
1. | ^ | | | | | | | | 2. | MOD | AND | * | / | | & | >> | << | 3. | OR | + | - | | | | | | | 4. | = | > | < | | | | | | 5. | <> | >= | <= | | | | | | |
Info: The Hierarchie corresponds to vaguely the under PASCAL and weicht from the BASIC-Hierarchie ex. The Vergleichsoperatoren (level 4 + 5) are BASIC higher classed.
from BASIC: If A% > 6 AND A% <= 20 THEN <...> End If
becomes in XProfan: If (A% > 6) AND (A% <= 20) <...> EndIf
In PASCAL would one write: If (A > 6) AND (A <= 20) THEN BEGIN <...>; End;
Klammerung is How normally allows, about: C% = 5 * (A% + B%) Result! = 248 * d% / (e% + f%)
clinging can discretionary, d.h. until Stack-Überlauf, nested go.
<b>Wichtig:</b> respect tappt im dunkeln on The Klammersetzung. Version 7.5 pushing on Error, The Version 6.5 yet overlooking has! The Error Message "Zu little Parameter" in a row with verschachtelten functions/clinging deutet often on a Error in the Klammersetzung there!
<b>Achtung:</b> logical means, that the Result true (1) or wrong (0) is, with binären functions go The values bitweise verknüpft:
logical: 2 OR 4 yields 1, because at least of/ one the values <> 0 (= true) is
binary: @OR(2,4) or. 2 | 4 yields 6: %0010 OR %0100 = %0110
for speedy Berechnungen with Integer-Values, z.B. in creep, etc., there in XProfan additional some command, The faster and übersichtlicher are:
LINKP:[INC] V% | increased V% circa 1 | LINKP:[DEC] V% | erniedrigt V% circa 1 | LINKP:[ADD] V%,n | increased V% circa n | LINKP:[SUB] V%,n | erniedrigt V% circa n | |
(Hierbei standing <b>V%</b> for a arbitrary Integer- or Longint-Variable and <b>n</b> for a beliebigen expression.)
for the join of Strings (Zeichenketten) becomes the "+" akin: Text$ = "Du are " + Str$(old%) + " years old."
of course functions in some versions too: Text$ = "Du are ";Str$(old%);" years old."
however is only the Pluszeichen as Verknüpfungs-Operator definiert. It can therefore To fehlerhaften Programs lead, if not elaborate worked becomes.
<b>Hinweis:</b> The automatic Typumwandlung functions with einfachen variables. with functions, The a numerischen worth give back, won't always automatically transformed, therefore is here always The function @LINKF:[Str]$ To use! VOR and After whom Operators must one space stand. there some Operatorzeichen too in another Context using go, can Compiler and Interpreter otherwise fehlerhaften code produce.
|
|
|
| Programmieren, das spannendste Detektivspiel der Welt. | 07/31/05 ▲ |
|
|
|