My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
syntaxexample  
Hier sind Syntax Beispiele
Updated Apr 22, 2009 by crazy.pr...@gmail.com

Introduction

Hier wird der Syntax anhand eines kleinen Beispieles erklärt.

Details

// If Abfragen:

if (1==1 || 1=0 ^^ 1>3 % 1<4 && 4>=1) {

TBasic.print("Hallo Welt")
} elseif (1==math.rand(1,2)) //Statt elseif geht auch otherwise {
TBasic.print("Ansonstenif")
} else {
TBasic.print("Falsch!")
} TBasic.Waitkey()

//Until Schleife local index:int {

index:+1 TBasic.print("Bei Index" & index)
} until(index>4)

//For Schleife for (index=0 TO 10) {

TBasic.print("For Schleife: " & index)
}

//While Schleife index=0 while (index<5 {

TBasic.print("While Schleife: " & index)
} /
Ein Kommentar über mehrere Zeilen!
/

//String example local MeinString:String MeinString="Hallo Welt!" & Tstring.mid("gluck",2,1) Tbasic.print (MeinString) Tbasic.print (Tstring.len(Meinstring))

//Float Example local meinfloat:Float=5.4 Tbasic.print(meinfloat)

//Goto example goto ("Sinnloser Sprung!") Tbasic.print("Ich werde nie angezeigt!!111") label("Sinnloser Sprung!")

//inline Bytecode Example Inlinebytecode {

//Hier könnte bereits vorkompilierter Mist stehen
}

//rechen example local meinint:int=5*4-2+(5-1*1)^3+Tmath.rand(4,5)-Tmath.cos(20) print (meinint)

//Konstanten example local MeineConst:const=100 'Der Datentyp ist immer String print (MeineConst)

//Function example print(Outputtext())

function outputtext:int(text:String) {

print(text) return (5)
}

function Outputnothing:Void() {

print(""Hallo Welt)
}

//Klassen example global Carlist:Tlist=New TList Type TAuto {

//Felder PUBLIC {
Field x:int Field y:int
} PRIVATE {
Field Image:TImage
}
//Methoden method Draw () {
self.Image.Drawimage(self.x,self.y) //This geht auch
} method New() {
Basic.Print("Auto wurde erstellt") Carlist.Listaddlast(self)
} method Delete() {
Basic.Print("Auto wurde gelöscht") Carlist.RemoveList(Self)
}
} Type Lastwagen Extends TAuto {
PRIVATE {
field Movespeed:int
} method Draw() {
TBasic.Print("Ein Lastwagen wird gezeichnet") Super.Draw()
}
} Tgraphic.Init(640,480) local car:TAuto=new (TAuto) car.x=10 car.y=10 car.Draw() Tgraphic.Flip()

TBasic.Waitkey()

if (1==1 && //Befehle über mehrere Zeilen (ist Optional)

2==2 && 3==3)
{
TBasic.Print("BLubb")
} //Pointer Example local meinint:Int=10 local MeinPointer:TPointer=meinint.Adress() //Meinint ist ja auch ein Objekt print (MeinPointer0) //Es arbeitet genau wie ein Array

//Arrays local meinArray:int10 meinarray1=10 print(meinarray1)

Powered by Google Project Hosting