English
Forum & Help

Sprachelement: var

 
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:
var a,b,c
a=10
b=20.5
c="Hallo Welt"
print a,b,c// gives 10 20.5 Hello World from

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:
var a=[10,20,30]
print a[1]// gives 20

Assoziative Arrays:
var a=["Magnet"=5,"Faktor"=5.5,"Farbe"="Grün"]
print a["Faktor"]// gives 5,5

Arrays as Objects:

Arrays as Objects:
var a,a.list
a.lodestone=5
a.factor=5.5
a.colour="Grün"
a.list=50
print a// gives magnet=5, faktor=5.5 farbe=Grün from, but not liste=50 there a.list through var eigenständig declared watts.

type of/ one variables relating:
var a="Test"
print var(a)// gives string from

Keywords: var,declare,gettype

 
12/01/14  
 



deference Änderung for Arraydeklaration:

from var o=array(10,20,30) becomes var o=[10,20,30]
 
12/06/14  
 



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.
 
05/13/15  
 




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

 
05/14/15  
 



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.
 
05/14/15  
 



alas and incidentally your row:
return  a + " = " + st(sqrt(a*a+b*b))

goes dank Space-Operator plenty plainer:
return  a + " = " + st sqrt a*a+b*b

and really anyway just so necessary:
return  a + " = " + sqrt a*a+b*b

because string+float = string
 
05/14/15  
 




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.
 
05/14/15  
 




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
 
05/15/15  
 



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.
 
05/15/15  
 




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.
 
05/15/15  
 



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)))
 
05/16/15  
 




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.
 
05/16/15  
 




Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

15.425 Views

Untitledvor 0 min.
RudiB.03/20/20
maroro07/25/16
Sascha Patzsch03/23/16
Pedro Miguel03/16/16
More...

Themeninformationen

this Topic has 2 subscriber:

iF (13x)
HofK (10x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie