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 : cmm2: error with longish static+sub/function names
Author | Message | ||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Hi all, I'm running into an error when using statics with longish names. I have reduced the issue I'm seeing to the following short program: 'TRACE ON 'To show that problem occurs after n loops SUB foobarsubrout STATIC thisIsAveryLongVName% END SUB DO foobarsubrout LOOP When running this program I eventually get the following error: Error in line 4: Not enough variable memory The error only shows up after a number of passes through the DO LOOP as can be seen when you enable tracing. If I use shorter variable names, the issue disappears. Any idea what's wrong here? I'm guessing that the static variable name gets concatenated with the subroutine's name. The sum of the two is 33, which is a bit suspicious. Possibly some boundary condition isn't handled properly in FW? FW version is 5.05.05. /Epsilon. Epsilon CMM2 projects |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 2989 |
Interesting. Without the "e" on thisIsAveryLongVName% it doesn't fall over--with it, it does. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8516 |
Passed it on to Geoff as is is a generic MMBasic issue - same result on the Micromite |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5867 |
The sub name gets appended to the static variable name to create a unique name. This has to be a maximum of 32 characters. From the manual under COMMANDS/STATIC But I think it could/should be added to the earlier section on page 21 as well. Jim edit: A 'name too long' error message would help. Edited 2020-09-24 07:54 by TassyJim VK7JH MMedit MMBasic Help |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Thanks. That makes sense. Sorry I missed it in the User Guide. It is a bit strange though that the condition goes unnoticed for a while and then results in a 'Not enough variable memory' error. If I add one character to either the sub or the static, it does get flagged right away as a 'Variable name too long error'. Then again, I don't think it has to be MMBasic's job to prevent me from shooting myself in the foot at every corner Epsilon CMM2 projects |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8516 |
This is because the name match fails and each time the subroutine is called creates a new variable until the variable space is full. The new version of the firmware will give an appropriate error the first time you call the function Edited 2020-09-24 19:49 by matherp |
||||
Print this page |