- 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;
- 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;
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;
Code: Select all
swap(a, b);
print(a);
print(b);
print(); ' print linefeed