So... I don't know BASIC super well, but I do know Lua, and in Lua you can call defined functions. For example;
function abc() <-- Define function abc
print("ABC") <-- Basically Lua's version of DISP
end <-- End function abc
abc() <-- Call function abc
This code would print "ABC" to the output. Now, the best I've managed to do to achieve this effect with basic is use Goto's and Lbl's. These are extremely inefficient and confounding when you try to do anything of any real size, and the program I'm trying to make branches so much that I rather dislike the idea of a million If, Then, and Else statements. In Lua, you could do something like the following;
function ABCandDEF() <-- define function ABCandDEF
abc() <-- Call function abc (below) (Point A)
def() <-- Call function def (below) (Point C)
end <-- Close function ABCandDEF (Point E)
function abc() <-- defines function abc, like in the first example (Point B)
print("ABC")
end
function def() <-- defines function def, just like abc (Point D)
print("ABC")
end
ABCandDEF() <-- calls function ABCandDEF
The function ABCandDEF would first call abc (Point A), causing the program to jump there (Point B) and execute all the way through function abc, then jump back to the next line of ABCandDEF (Point C), in this case being the line, "def()", which would call def, jumping to that function (Point D), executing through that, then back to the next line of ABCandDEF (Point E), which in this case is an 'end', stopping the program.
So... The ultimate question... Is there a way to mimic this in BASIC (w/o Lbl's and Goto's)? A way to write and call functions, then return to the place where they were called?
function abc() <-- Define function abc
print("ABC") <-- Basically Lua's version of DISP
end <-- End function abc
abc() <-- Call function abc
This code would print "ABC" to the output. Now, the best I've managed to do to achieve this effect with basic is use Goto's and Lbl's. These are extremely inefficient and confounding when you try to do anything of any real size, and the program I'm trying to make branches so much that I rather dislike the idea of a million If, Then, and Else statements. In Lua, you could do something like the following;
function ABCandDEF() <-- define function ABCandDEF
abc() <-- Call function abc (below) (Point A)
def() <-- Call function def (below) (Point C)
end <-- Close function ABCandDEF (Point E)
function abc() <-- defines function abc, like in the first example (Point B)
print("ABC")
end
function def() <-- defines function def, just like abc (Point D)
print("ABC")
end
ABCandDEF() <-- calls function ABCandDEF
The function ABCandDEF would first call abc (Point A), causing the program to jump there (Point B) and execute all the way through function abc, then jump back to the next line of ABCandDEF (Point C), in this case being the line, "def()", which would call def, jumping to that function (Point D), executing through that, then back to the next line of ABCandDEF (Point E), which in this case is an 'end', stopping the program.
So... The ultimate question... Is there a way to mimic this in BASIC (w/o Lbl's and Goto's)? A way to write and call functions, then return to the place where they were called?