Page 1 of 1

Stages 75-78

Posted: Tue Dec 21, 2021 4:54 pm
by frank
- Support added for character types chr8, chr16 and chr32. See data types in documentation.
- for-loop changed to count-loop and support added for downward iteration. Keywords up and down required for iteration direction:

Code: Select all

count i up 1 to 9
  do
    ' ..
  end;
  
count i down 9 to 1
  do
    ' ..
  end;
- added function typof to return the code of an identifier's type.
- function asc added to return character's ascii code

- loop conditions while and until are now both allowed as first or last loop statement:

Code: Select all

loop do
  while x > 0;
  ' ...
end;

loop do
  ' ...
  while x > 0;
end;

loop do
  until x == 0;
  ' ...
end;

loop do
  ' ...
  until x == 0;
end;
- built-in subroutines stob, stow, stod added to write byte-, word- and dword-data to memory. Example code using stob to convert integer to binary string:

Code: Select all

func dec2bin(d: uint): str
  dim n: uint;
  dim r: str * 64;
  dim p: ptr;
do
  p = sadd(r);
  n = len(r);
  if d == 0 do
    n = n - 1;
    ' write character 0 (ascii code 48)
    stob(p + n, "0");
  end;

  loop do
    while d > 0;
    n = n - 1;
    stob(p + n, d % 2 + 48);
    d = d / 2;
  end;
  ' mid positions are one based, therefore n + 1
  dec2bin = mid(r, n + 1);
end;
- for consistency print and swap statements are now treated as subroutines and require parentheses

Code: Select all

swap(a, b);
print(a);
print(b);
print(); ' print linefeed
Syntax highlighting support for SharpBASIC added to the forum. 277 languages in total are supported for the code box. Simply add the language name behind the tag, e.g.: 'code=nasm'. See the Prism website for supported language names. SharpBASIC syntax highlighting is default and does not need to be added to the code box tag.