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 : New version of MMBasic (ver 4.3)
Page 3 of 3 | |||||
Author | Message | ||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
Agghh, another bug! At least they are getting more obscure. Thanks, it will be fixed in the next version. Geoff Geoff Graham - http://geoffg.net |
||||
ratall Newbie Joined: 27/11/2012 Location: AustraliaPosts: 12 |
Hi Geoff Sorry to bug you again. But I think I may have found another bug. Option base 1 LabelCount = 1 If LabelCount>0 then Dim Labels$(LabelCount) Gives an error of Error: Invalid array dimension I don't know about anybody else but I do have the annoying habit of counting stuff then creating an array to keep it in (not too big, not too small. Just right ) and occasionally there is only one. I do have a work round so again not urgent. The program I'm working on currently uses "option base 1" so my work round is to change it to "option base 0", add 1 to all array sizes at the dim and carry on as though I am still using "option base 1". Ignoring element 0 of the the array. Thanks R. |
||||
ajkw Senior Member Joined: 29/06/2011 Location: AustraliaPosts: 290 |
from the mmbasic manual DIM. Specifies variables that have more than one element in a single dimension, i.e., arrayed variables. edit/add: so the behavior of getting an error when trying to dimension an array of 1 element is correct as things stand. However I can see that with your idea of dynamically dimensioning arrays that when you have a count of 1 you have a problem. It would generally speaking be unusual to need to declare an array of 1 element, perhaps Geoff would explain for you if this is a convention (to only be able to dimension arrays with 2 or more elements) or if there is a technical obstruction to declaring an 1 element array. Cheers, Anthony. |
||||
ratall Newbie Joined: 27/11/2012 Location: AustraliaPosts: 12 |
Thanks for pointing that out I missed it. I am afraid I made an assumption based what some other basics let me get away with. May be I should treat arrays as self contained objects and store the length in element zero. Or may be a terminator in the last element in case of string arrays. Waste not want not. Sorry for wasting time. Thanks for your help. R. |
||||
ajkw Senior Member Joined: 29/06/2011 Location: AustraliaPosts: 290 |
Would be handy spot to store the number of elements |
||||
ratall Newbie Joined: 27/11/2012 Location: AustraliaPosts: 12 |
And it has the added bonus that when you erase the array it goes too. |
||||
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1101 |
Hi ratal, Have a look at my recent post on stack, queue's and lists - these may prove usefull to you if you need multiple pidgeon holes for small strings rather than arrays and has the advantage of being able to pass to subroutines. Cheers, Doug. ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
There are a few functions in other basic that can be usefull with arrays. REDIM with optional preserve to make arrays smaller or bigger. LBOUND and UBOUND to get the lower and upper bound of an array. I am not sure if these were only in newer basic versions. Microblocks. Build with logic. |
||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
Print "Goto 100" will have problems. Good pickup. Thanks. Maybe I can treat text within double quotes like a remark - trim it out while I process everything else, then put it back together again. I'll think about it. James It took a little work to handle text within double quotes and lines resizing when different length linenumbers were inserted, but I think it's finally debugged. I'll start a new thread so I don't clutter up the 4.3 thread. James My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
Page 3 of 3 |
Print this page |