![]() |
FUNCTIONS again - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: FUNCTIONS again (/showthread.php?tid=1029) |
FUNCTIONS again - RandomiserUsr - 02-27-2021 If you compile the following code FUNCTION A(text as STRING) Print B("Test") RETURN 0 END FUNCTION FUNCTION C(text as STRING) Print B("Test") RETURN 0 END FUNCTION FUNCTION B(text as STRING) Print ("Test") RETURN 0 END FUNCTION you will get inputmud.bas:137: error: 'B' is neither an array nor a function. inputmud.bas:135: warning: [W150] Parameter 'text' is never used inputmud.bas:144: warning: [W100] Using default implicit type 'float' for 'C' inputmud.bas:144: error: 'B' is neither an array nor a function. inputmud.bas:143: warning: [W150] Parameter 'text' is never used inputmud.bas:149: warning: [W100] Using default implicit type 'float' for 'B' inputmud.bas:148: warning: [W150] Parameter 'text' is never used but moving function B above like below compiles okay So I guess it's a TOP Down design where the functions in the same .BAS should be ordered FUNCTION B(text as STRING) Print ("Test") RETURN 0 END FUNCTION FUNCTION A(text as STRING) Print B("Test") RETURN 0 END FUNCTION FUNCTION C(text as STRING) Print B("Test") RETURN 0 END FUNCTION Great tool Thanks Ken RE: FUNCTIONS again - boriel - 02-28-2021 (02-27-2021, 12:15 PM)RandomiserUsr Wrote: If you compile the following code That is. If you want to reference a function before being declare, use DECLARE: https://zxbasic.readthedocs.io/en/docs/declare/ RE: FUNCTIONS again - RandomiserUsr - 02-28-2021 (02-28-2021, 05:31 PM)boriel Wrote:(02-27-2021, 12:15 PM)RandomiserUsr Wrote: If you compile the following code Palm Face moment! I even read that earlier this week! Sorry for the spam :-) thanks again Ken |