BASIC · lesson 15 of 30 · Data, functions and the command lineName a block of lines
sub gives a block a name and values to work with.
15-sub.yab Download 15-sub.yab
rem A sub is a block of lines with a name
title("Disks")
print "four disks"
title("Network")
print "two ports"
sub title(text$)
local i
print text$
for i = 1 to len(text$)
print "-";
next i
print
end sub
Terminal
$ yabasic 15-sub.yab
Disks
-----
four disks
Network
-------
two portsExercise
Write a sub that prints a text in the middle of a 40 character line.