struct
Purpose
Create a structured variable type
Description
Allows the user to create their own complex variable types. This allows the grouping of related information into a single variable
Syntax
struct name
type1 field1
...
typen fieldn
endStruct
Arguments
name name of the structure
field1 name of the first field
type1 type of the first field
fieldn name of the last field
typen type of the last field
Example
struct shape
string name
int sides
int size
vector pos
int col
endStruct
shape shapes[3]
shapes[0] = [ .name = "triangle", .sides=3, .size=150, .pos = { 400, 150 }, .col = red ]
shapes[1] = [ .name = "square", .sides=4, .size=150, .pos = { 400, 500 }, .col = yellow ]
shapes[2] = [ .name = "pentagon", .sides=5, .size=150, .pos = { 800, 150 }, .col = blue ]
shapes[3] = [ .name = "hexagon", .sides=6, .size=150, .pos = { 800, 500 }, .col = green ]
loop
clear()
printAt( 0, 0, "Press A to show labels" )
c = controls( 0 )
for i = 0 to 4 loop
drawShape( shapes[i], c.a )
repeat
update()
repeat
function drawShape( s, label )
circle( s.pos.x, s.pos.y, s.size, s.sides, s.col, 0 )
if label then
drawText( s.pos.x - s.size/2, s.pos.y, s.size / 5, black, s.name )
endIf
return void
Associated Commands