| |
|
|
| var Bezeichner [ = worth ] [, Bezeichner [ = worth ], ...
Deklariert Variablenbezeichner and points them ggf. values To.
it can as much as you want variables prepares go, allows for Bezeichnernamen are letters and Digits and the first characters must one character his. too allows are The characters _ and .
Info: Var as function can uses to be whom Variablentyp zurückzuerhalten.
Related: § 5 - Datentypen
Examples of The usage of variables:
Einfache Variable:
Einfache Variable, kompaktere spelling:
var a=10,b=20.5,c="Hallo Welt"
print a,b,c// gives 10 20.5 Hello World from
aray:
Assoziative Arrays:
var a=["Magnet"=5,"Faktor"=5.5,"Farbe"="Grün"]
print a["Faktor"]// gives 5,5
Arrays as Objects:
Arrays as Objects:
type of/ one variables relating:
Keywords: var,declare,gettype |
|
|
| |
|
|
|
| deference Änderung for Arraydeklaration:
from var o=array(10,20,30) becomes var o=[10,20,30] |
|
|
| |
|
|
|
| New:
Var can also uses to be whom Variablentyp zurückzuerhalten. In this case is Var as function To use: var a=1.1;print var(a) //gives float from. |
|
|
| |
|
|
|
HofK | in the Context with the "Space-Operator" [...] at Präkompilierer would one optionales Sonderzeichen to Typermittlung for utterly Schreibfaule super. with of/ one polymorphen Funktionsdefinition sees one The reduction the Schreibstreassfaktors explicit.
proc poly a b c// the Präkompilierer depends the
// Typprüfung with optionalem Sonderzeichen (bspw °) would something for utterly Schreibfaule How ...
if ((°a==long)&&(°b==long)&&(°c==zero))
return "Das Result is: " + st(a-2*b)
elseif ((°a==string)&&((°b==long)||(°b==float))&&((°c==long)||(°c==float)))
return a + " = " + st(sqrt(a*a+b*b))
elseif ((°a==string)&&(°b==zero)&&(°c==zero))
return "Genau a Zeichenkette watts transfer."
// ... command to processing the Zeichenkette ...
elseif ((°a==string)&&((°b==long)||(°b==float))&&(°c==zero))
if (°b==long)
return "Übergabe: 1. Parameter Zeichenkette, 2. Parameter whole Zahl"
endif
if (°b==float)
return "Übergabe: 1. Param. is Zeichenkette, 2. Parameter Dezimalzahl"
endif
// ... command to processing the Zeichenkette and/or the number ...
elseif ((°a==string)&&((°b==long)||(°b==float))&&(°c==bool))
return "Parameterübergabe: 1. Zeichenkette, 2. number, 3. Wahrheitswert
// ... command to processing the three Parameter ...
else
return zero
endif
endproc
// so is it to derzeitiger reference with var( )
proc poly(a,b,c)
// Typprüfung with var()
if ((var(a)==long)&&(var(b)==long)&&(var(c)==zero))
return "Das Result is: " + st(a-2*b)
elseif ((var(a)==string)&&((var(b)==long)||(var(b)==float))&&((var(c)==long)||(var(c)==float)))
return a + " = " + st(sqrt(a*a+b*b))
elseif ((var(a)==string)&&(var(b)==zero)&&(var(c)==zero))
return "Genau a Zeichenkette watts transfer."
// ... command to processing the Zeichenkette ...
elseif ((var(a)==string)&&((var(b)==long)||(var(b)==float))&&(var(c)==zero))
if (var(b)==long)
return "Übergabe: 1. Parameter Zeichenkette, 2. Parameter whole Zahl"
endif
if (var(b)==float)
return "Übergabe: 1. Param. is Zeichenkette, 2. Parameter Dezimalzahl"
endif
// ... command to processing the Zeichenkette and/or the number ...
elseif ((var(a)==string)&&((var(b)==long)||(var(b)==float))&&(var(c)==bool))
return "Parameterübergabe: 1. Zeichenkette, 2. number, 3. Wahrheitswert
// ... command to processing the three Parameter ...
else
return zero
endif
endproc
|
|
|
| |
|
|
|
| if ((°a==long)&&(°b==long)&&(°c==null))
there could one still say, instead of:
°c==null
simply
c==null
because type zero can Yes only the value zero supplying - here So one Typenzeichen unnecessary.
so weitergedacht consider I naturally, whether not simply
a==long or s==string or f==float,
finally go here long, float etc not as function uses sonden could as Constant understood go. I must time herausbekommen whether the with something bite. |
|
|
| |
|
|
|
| alas and incidentally your row:
goes dank Space-Operator plenty plainer:
and really anyway just so necessary:
because string+float = string |
|
|
| |
|
|
|
HofK | ... because type zero can Yes only the value zero supplying - here So one Typenzeichen unnecessary ... always too yet these Sonderfälle
... incidentally your row: ...so far i was yet not at all! there's yet integrally beautiful plenty capability. |
|
|
| |
|
|
|
HofK | Hm, by which becomes clear, whether the latest Pluszeichen a Stringanfügung or a addition is? unfortunately is + Yes üblicherweise twice occupied.
return a + " = " + sqrt a*a+b*b |
|
|
| |
|
|
|
| the of type since höherwertige Result certainly whom type because only so without Datenverlust konvertiert go can. Höherwertig accordingly in this Order:
String Float Long Bool zero
Ergo is 1+"Test" always "1Test" very How "Test"+1 always "Test1" is, 1.1+2 is always 2.2 very How 2+1.1 always 2.2 is.
one can also say, what You with String verknüpfst is always String.
this here: 2.2+1+"hallo"+5.5+1 yields: 3.2Hello5.51, in this drop means of left to right ausargumentiert.
If one with the numbers in a Stringkonstante calculate wants then by long( or float( whom String konvertieren. |
|
|
| |
|
|
|
HofK | the was so far clear, had We also already to some Time in the Discussion - find I but straight not. Beautiful here again The konkrete List the Wertigkeit, would itself there [...] well make.
If I now not utterly schief lie, only therefore my Note concerning the mitdenkenden Präkompilierers, should then in the last Vereinfachung still return a + " = " + sqrt( a*a+b*b) stand, there Yes in the Ausgangszeile the Pythagoras anvisiert was. it be because, to sqrt becomes as long as numerisch "gedacht" as goes.
there's the . for Konkatenation with php and Konsorten then even eindeutiger and übersichtlicher. but whom point übersieht one too time faster, he's so lütt. |
|
|
| |
|
|
|
| iF (01.12.14)
Space-Operator (Freizeichen), really no Operator separate a spoke/ Syntaxeigenschaft, näheres moreover under: [...]
The row:
return a + " = " + st(sqrt(a*a+b*b))
can thoroughly so vereinfacht go:
return a + " = " + sqrt a*a+b*b
The Space-Operator is no logischer Operator separate one Syntaxmittel, the to whom logischen Operators aufgelöst and is not as log. Operators of left to right separate it can only of right to left aufgelöst go.
you have it with
> it be because, to sqrt becomes as long as numerisch "gedacht" as goes.
correctly. recognized. The Space-Operator can Kommas and clinging herbeizaubern anhand which whether it a function finds or a worth.
so would from:
proc Test a b c;endproc return a + " = " + st sqrt a*a+b*b Test a b c
proc Test(a,b,c);endproc return a + " = " + st(sqrt(a*a+b*b,Test(a,b,c))) |
|
|
| |
|
|
|
HofK | "Es be because, to sqrt becomes as long as numerisch "gedacht" as goes."
I had it hoped, but not absolutely expects, because derartig lästige Sonderzeichen sparendes, really vereinfachendes have I with whom gängigen Languages yet not seen. gives it the at all already somewhere?
sure must one it so bring into action, that The Übersichtlichkeit not To short comes. This will itself useful quick show.
The Präkompilierer with the Syntaxeigenschaft/Syntaxmittel Kodeergänzung through Space Operator earn possible a own Paragraphen, with § 7 Operators goes the Space Operator something under and is Yes then too no klassischer Operator.
the space, the Space Operator is a intelligenter Space Seperator, one intelligenter Trenner, one Space-Autoseparator short one Autoseparator, one polymorpher Seperator, so yet something polymorphes with InfinityProfan.
" ... the to whom logischen Operators aufgelöst becomes ... it can only of right to left aufgelöst go." is integrally important to that understanding and ought to into Paragraphen mere. Can whom zugrundeliegenden Algorithmus short/vereinfacht/clear present?
Freue me already auf's konstruieren and explain of Examples to Syntaxeigenschaft. |
|
|
| |
|
|