![]() |
Forum Index : Microcontroller and PC projects : uM2(+): Weird bug to be aware of
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10400 |
I've now been able to simply demonstrate the bug which I think is the problem in these threads. Thread 1 Thread 2 The bug is definitely in both versions 5.1 and 5.2. I've let Geoff know separately. Basically there is some strange interaction between OPTION EXPLICIT OPTION AUTORUN ON and CONST and LOCAL when used in MM.STARTUP To demonstrate the bug load the following test program Option explicit
option default NONE option autorun on dim integer e=4 print e pause 1000 end Sub mm.startup Const a=2 Local integer b=a\2 print b End Sub type CPU RESTART and MM.STARTUP will execute as expected and print "1" type RUN and the main program will run as expected and print "4". This of course also enables autorun Now type CPU RESTART again. We expect MM.STARTUP to run and then the main program to run. MM.STARTUP runs and prints "1" but the main program fails with the error Here is the full trace The following also gives the bug: Sub mm.startup
local integer a=2 Local integer b=a\2 print b End Sub Note if you change MM.STARTUP to [code]Sub mm.startup Const a=2 print a\2 End Sub[/code] The bug no longer happens ![]() |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2447 |
the following code also fails: a=2
Option EXPLICIT from the 5.2 manual: if the word "should" is replaced with "MUST", and it is stressed that it needs to be placed in MM.STARTUP if this file is used, is the observed behaviour mitigated? it kind of makes sense that both of the program spaces need to operate under the same set of 'rules', as they both share the same single variable space. perhaps Option EXPLICIT needs to be changed so that it is aware of already defined variables? cheers, rob :-) |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10400 |
This nearly works except that if mm.startup is in the library when you load a new program then the OPTION EXPLICIT isn't active until you restart. See trace below |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2447 |
would it help if option explicit was a persistent setting, like option autorun is? it would then become a 'personal style' setting like selecting the colours in an editor, etc. myself, i never use the library functions, mm.startup or mm.prompt. they make keeping track of what the micromite is doing unnecessarily confusing. cheers, rob :-) |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |