Stage 94-95: Structures

Follow the development of the SharpBASIC compiler and share your thoughts and ideas.
Locked
User avatar
frank
Site Admin
Posts: 40
Joined: Sun Nov 21, 2021 12:04 pm
Location: Netherlands
Contact:

Stage 94-95: Structures

Post by frank »

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.

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
Keep it simple!
Locked