|
Forum Index : Microcontroller and PC projects : MMB4W: Framebuffer creation wiping out my global array
| Author | Message | ||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 527 |
I've encountered an interesting problem. My global array g_values is being cleared after the framebuffer creation command. It runs with no issues on the first execution, but if I try to run it again, the global array is wiped out after the framebuffer creation. The problem does not happen if I use the framebuffer close instruction at the end of the program. Off course this is a simple example. In a real app with a infinite do/loop, it is very common during development, to break the app with ctrl+c, which causes the program not cleaning open resources or closing the framebuffer, which triggers the issue. Is this the expected behavior? Maybe is it happening with me because I'm running MMB4W on wine? option explicit option base 0 option angle degrees option default float dim g_values(10)=(0,1,2,3,4,5,6,7,8,9,10) ? "Before framebuffer create" ? g_values(0) ? g_values(1) ? g_values(2) framebuffer create mm.hres, mm.vres ? "After framebuffer create" ? g_values(0) ? g_values(1) ? g_values(2) Output: ![]() Edited 2025-11-13 16:16 by LeoNicolas |
||||
| Supertech Regular Member Joined: 13/11/2016 Location: AustraliaPosts: 54 |
Interesting. I am running a project under RP2040 V6.00.03 some time now. However this particular result seems very similar re Array loosing data. Mine is a bit different but results the same. Unable to paste, but is simple. 1. I have a single array holding 15, 10 length text words. Eg. Cond$(16)... but empty of say "Heating", "Cool" etc. I also have a condn() integer array that stores 0 or 1 for latter use. 2. I use one sub, n = 0 to 15 to preload these texts. Works fine. 3. Now this next sub matches the 2. Preloads like this, Sub collect_conditions For n = 0 to 15 If TU sensor > xyz then condn(n) = 1 else condn(n) = 0 If..... If.... Next n End sub Within for..next the condn(n) loads perfect, just like string one does. BUT past next n, the condn(n) whole data array is blanked all back to zeros! Both arrays are global. Explicit active. Your post has reminded me as it may be related? Thank you. Im not good with names |
||||
| Supertech Regular Member Joined: 13/11/2016 Location: AustraliaPosts: 54 |
Thanks Leo |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4142 |
Does it rely on any particular Pico features (I/O etc)? I'm wondering if it could be tested on other MMBasic variants e.g. MMB4W, MMB4L? Peter inevitably would like the smallest example - which may be the Pico one of course. John |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 5464 |
Hi Leo, On pico we have observed several issues when framebuffer is not created first. In some cases we get a nice error message. But in the transition from V5.09.00 to V6.00.03 I had to adjust several programs that defined framebuffers after array definitions, to bring the framebuffer definition first. This was especially needed in games that work on both Game*Mite and PicoVGA. The LCD on the Game*Mite requires the use of FRAMEBUFFER F, but VGA does not. Regards, Volhout PicomiteVGA PETSCII ROBOTS |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10583 |
It is a mmb2W specific issue. As a workaround type FRAMEBUFFER CLOSE at the command prompt before re-running the program Edited 2025-11-13 21:03 by matherp |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |