Implementation of user-defined types usually goes hand in hand with support for a 'with' or 'using' statement. SharpBASIC supports up to three levels of nested with statements. These statements are fully managed by the compiler, i.e. they are not hard-coded at compilation time, except for address calculation of accessed fields. This means that a with statement is purely cosmetic and not affected by something like a jump statement. For more details, see the documentation about the with statement.
Up to the next stage.
Example (from the documentation):
Code: Select all
' SharpBASIC 'with' programming example
' -------------------------------------
incl "lib/sys.sbi";
record A is
x: int;
y: int;
end
record B is
z: int;
a: A;
end
dim a: A;
dim b: B;
main do
a.x = 5;
a.y = 4;
b.z = 10;
jump @calculate; ' this is ok
print(b.z); ' not printed
with b do ' block 1 (...)
with b.a do ' block 2 (..)
with a do ' block 3 (.)
@calculate;
..x = .x * ...z;
..y = .y * ...z;
end
end
end
with b do
with .a do
print(.x);
print(.y);
end
print(.z);
end
end