Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 19:58 28 Mar 2024 Privacy Policy
Jump to

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: Belgium
Posts: 255
Posted: 04:32pm 23 Sep 2020
Copy link to clipboard 
Print this post

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 States
Posts: 2989
Posted: 05:19pm 23 Sep 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 8516
Posted: 05:23pm 23 Sep 2020
Copy link to clipboard 
Print this post

Passed it on to Geoff as is is a generic MMBasic issue - same result on the Micromite
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 09:43pm 23 Sep 2020
Copy link to clipboard 
Print this post

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
  Quote  This command uses exactly the same syntax as DIM. The only difference is
that the length of the variable name created by STATIC and the length of the
subroutine or function name added together cannot exceed 32 characters.


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: Belgium
Posts: 255
Posted: 09:42am 24 Sep 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 8516
Posted: 09:47am 24 Sep 2020
Copy link to clipboard 
Print this post

  Quote  It is a bit strange though that the condition goes unnoticed for a while and then results in a 'Not enough variable memory' error.


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


To reply to this topic, you need to log in.

© JAQ Software 2024