Wednesday, 5 February 2014

Mouse click --> Draw a shape

Simple

GraphicsWindow.MouseDown = mousedown
Sub mousedown
  a = Shapes.AddEllipse(10,10)
  Shapes.Move(a, GraphicsWindow.mousex, GraphicsWindow.mousey)
EndSub





Complex (Put a litle array)

GraphicsWindow.MouseDown = mousedown
i = 0
Sub mousedown
  a[i]=Shapes.AddEllipse(10,10)
  Shapes.Move(a[i], GraphicsWindow.mousex, GraphicsWindow.mousey)
  TextWindow.WriteLine(a[i])
  i = i + 1
EndSub

Mouse move --> Draw a shape

GraphicsWindow.mousemove = mousemove
Sub mousemove
  x = GraphicsWindow.MouseX
  y = GraphicsWindow.MouseY
  TextWindow.WriteLine(x + " " + y)
  sh = Shapes.AddEllipse(5,5)
  Shapes.Move(sh, x, y)
EndSub


Terminating / disrupting main loop with mouse event

GraphicsWindow.MouseDown = mousedown
For i = 0 To 1000000
  GraphicsWindow.Drawellipse(i,i,i,i)
  Program.Delay(1000)
EndFor

Sub mousedown
  Program.End()
EndSub

Penggunaan 12 verb tenses

File

Operation type:
- Read
- Write
- Directory


Read:
- Readcontents
- Readline




 Write:
- Writecontents
- Writeline
- Insertline
- Appendcontents

Shape

Small basic introduces us the object of:
- rectangle
- ellipse
- triangle
- line
- image
- text

Operation of rectangle:
- addrectangle

Operation of ellipse:
- addellipse

Operation of triangle:
- addtriangle

Operation of line:
- addline

Operation of image:
- addimage

Operation of text:
- addtext
- settext

Global operation:
- Remove
- move
- Rotate
- Zoom
- Animate
- Getleft
- Gettop
- Getopacity
- Setopacity
- Hideshape
- Showshape

Controls (Small Basic)

Controls that introduced by small basic:
- button
- textbox
- multiline textbox

Operation to button:
- Addbutton
- Getbuttoncaption
- setbuttoncaption


Operation to textbox:
- addtextbox
- gettextboxtext
- settextboxtext

Operation to multiline textbox:
- addmultilinetextbox

Operation to all:
- Remove
- move
- setsize
- hidecontrol
- showcontrol

Script example:

Controls.AddButton("button1", 10, 0)
Controls.AddTextBox(10, 30)
Controls.AddMultiLineTextBox(10,60)

Output:

Contoh penggunaan file setting

Untuk mensetting besar (width dan height) shape ellipse.

x = File.ReadContents("e:/data/data1.txt")
y = File.ReadContents("e:/data/data2.txt")
TextWindow.WriteLine(x)
TextWindow.WriteLine(y)
Shapes.AddEllipse(x,y)