This is based on the XBase Shapes Example using a draft scripting language tentatively called "L".
// Shapes example in "L", version 1.0c
//------------------MAIN--------------------
sub Main
// Open shapes table
var shapes = open("shapes", #driver std) // #driver is a named parameter
delete(shapes) // empty out table (for example only)
// Add rectangle (normally done in a form or other method)
newshape shapes, "rec", 10, 20
shapes.width = 5
shapes.height = 6
// Add circle
newshape shapes, "cir", 15, 25
shapes.radius = 8
// Loop thru shapes
moveTop(shapes)
while getnext(shapes)
doSomething shapes
endWhile
//
newshape shapes, "rec", 0, 0
shapes.width = 15
shapes.height = 15
shapes.width = 30
draw(shapes)
close(shapes)
end sub
//--------------------------------------
sub Draw(t) // draw current record
select t.shapetype
case "rec"
outln "Drawing rectangle at ( $t.x , $t.y ) Width: $t.width , Height: $t.height "
case "cir"
outln "Drawing circle at ( $t.x , $t.y ) Radius: $t.radius "
otherwise
outln "Error: invalid shape: " & shapetype
end Select
end sub
//--------------------------------------
sub MoveTo(t, newX, newY) // move coordinates in current shape record
t.x = newX
t.y = newY
end sub
//--------------------------------------
sub RMoveTo(t, newX, newY) // move relative coordinates in current record
t.x = @ + newX // same as t.x = t.x + newx
t.y = @ + newY
end sub
//--------------------------------------
sub NewShape(t, pShapetype, px, py) // create a new shape record
addnew(t)
t.shapeType = pShapetype
moveto(t, px, py)
endSub
//--------------------------------------
sub DoSomething(t)
draw(t)
RMoveTo(t, 100, 100)
draw t // parenths optional in some cases
end sub
//--------------------------------------