Stage 94-95: Structures
Posted: Tue Mar 01, 2022 6:42 pm
Currently, structures (aka user-defined types) are being implemented. Structures in SharpBASIC work the same as in most other languages.
The following example has been compiled and run successfully. The next step is to implement nested structures.
The following example has been compiled and run successfully. The next step is to implement nested structures.
Code: Select all
' SharpBASIC structure 1
' ----------------------
incl "lib/sys.sbi";
struc SPerson is
fname: str;
sname: str;
dname: str;
age: uint;
end
dim person: SPerson;
dim size: uint;
main do
person.fname = "John ";
person.sname = "Smith";
person.dname = person.fname + person.sname;
print(person.dname);
person.age = 53;
print(person.age);
size = len(person);
print(size);
end