Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MMBasic parameter List Bug?
Author | Message | ||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
Am I doing something wrong or have I mis-read the manual or ...? It seems that if the first (non-whitespace) character after a subroutine call is an open bracket, then the entire list of parameters must be enclosed in extra brackets. Edit: I am testing this on a CMM2. Do other platforms behave similarly? > ? mm.device$ Colour Maximite 2 > ? mm.info(version) 5.0702 > list ' test subroutine call testme 1,2,3,4 testme 2/2,2,3,4 testme (1+1)/2,2,3,4 ' broken? testme ((1+1)/2,2,3,4) testme 2/2,(1+3)/2,3,4 end sub testme a,b,c,d print a,b,c,d end sub > run 1 2 3 4 1 2 3 4 2 0 0 0 1 2 3 4 1 2 3 4 > Edited 2022-11-29 12:10 by vegipete Visit Vegipete's *Mite Library for cool programs. |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3165 |
You are correct. If the parameter list starts with a bracket, then the parameter list must also be terminated with a bracket (ie, all the parameters must be enclosed within the brackets). When subroutines were added to MMBasic (a long, long time ago) it was made mandatory that the parameter list be enclosed within brackets as specified in the ANSI Standard. But later the brackets were made optional. These days the user manuals and most programs do not use brackets. So you can use two forms: mysub(arg1, arg2, etc) or mysub arg1, arg2, etc You have stumbled across this "feature" of the interpreter where it spotted the starting bracket and assumed that the whole parameter list was bracketed. This applies to all versions of MMBasic. Geoff Geoff Graham - http://geoffg.net |
||||
Print this page |