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 : MMBasic 4.4 Beta 1
Page 3 of 3 | |||||
Author | Message | ||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
1. I ran out of memory when I wrote the RENUMBER program. Chaining fixed the code space problem, and deleting my string arrays after use freed up memory. I was also careful to declare variables as Local in subroutines and functions if they were local to the routines. Once I did that I had no more memory problems. 2. Sounds good. 3. That sounds good too. I rarely use long strings, but I do use big multi-dimensional arrays of small strings. Having the option to reduce the maximum size of strings would help. The important thing is that I was able to write my program using the options you have already provided. Reducing the string size would have allowed me to fit more code into memory and reduced the need for chaining which would have been more convenient, but it it wasn't too difficult to work around. James My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
The added ,10 is indeed another way to do it. The square brackets though stand out more and make it clear it is a length. The square brackets should be optional too. If not used then a normal 256 byte string should be created to maintain backward compatibility. Another way of declaring fixed length string as used in other basic is: DIM strName AS STRING * n This syntax is a lot different then the one chosen in MMBasic and only Geoff knows which way would be better to implement. Microblocks. Build with logic. |
||||
kiiid Guru Joined: 11/05/2013 Location: United KingdomPosts: 671 |
I think in his example Hugh has given the definition of a two-dimensional array with 10-character strings. There is an optional ",10" extension after the closing bracket. This format is really the most consistent with BASIC way to go for strings. The question however is what does the string length represent - the maximum number of useful characters in a string, or the maximum number of useful characters PLUS an ending NUL character? It won't be a good idea to have the maximum strings length defined at the top. BASIC is known for its easy string operations and anything like that would only move it towards C style, which the BASIC is not. http://rittle.org -------------- |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Kid, i caught the ,10 the second time i read it and edited my post at the same time you made yours i think. I am not in favor of the added ,10 as it is against all the normal practices when defining variables. I am conditioned (brainwashed ha ha) after too many years reading and writing basic and C(#). I guess i think it is too subtle and invites errors. The square brackets are very obvious (when you first see it it will give you a 'Huh what is that feeling'), and i think that is a good thing. Fixed strings is 'against' normal basic practices but in environments with low amounts of memory or interfacing with the hardware it is a good addition. MMBasic does not use an ending NUL character. It uses a pascal type string where the length is in the front followed by the content. As such it should define the number of characters you can store in that string. Microblocks. Build with logic. |
||||
Juri74 Senior Member Joined: 06/02/2012 Location: ItalyPosts: 162 |
Secondly, would it be OK if fixed length strings were only implemented in arrays with different arrays allowed to have different sizes? And a third question, would an option at the beginning of the program to set the string size for all strings be better? Speak up! Geoff Hello Geoff 1) i run out of memory on almost all program i made, first time i used arrays of strings then i switched back to arrays of numbers, and made my work associating a number to a series of strings. 2) Yes! 3) i think that an option at the beginning of program would be useful, 99% times i use strings in arrays, and 99% times i use strings not in arrays they are long max 1 line of screen.. eventually i use longer strings but because i know that a string is long 255 so i try to take full advantage of it.. little off topic: is there a chance in the future that a pair of (i think) useful commands will be implemented? i mean INC(variable) and DEC(variable) and in their extended format INC(variable,min,max) and ofcourse DEC(variable,max,min) this could be stupid but it could replace a piece of code and run faster i actually use functions for the job Function INC(v,min,max) v=v+1:if v>max then v=min if v<min then v=min inc=v:end function Function DEC(v,min,max) v=v-1:if v<min then v=max if v>max then v=max dec=v:end function usage Variable=INC(Variable,min,max) and Variable=DEC(Variable,min,max) example value=INC(value,10,30) lives=DEC(lives,0,99) Juri |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
OK, it looks as if being able to specify a string length is needed. This will be a a very large job and may take some time. Your INC/DEC functions are neat but really the way that they should be implemented is as user defined functions - as you have already done. The only advantage in adding them to the language is that you would shave off a few microseconds but as I said before in this thread, any new additions need to deliver real value. Geoff Geoff Graham - http://geoffg.net |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6100 |
Hello Geoff 1) i run out of memory on almost all program i made, first time i used arrays of strings then i switched back to arrays of numbers, and made my work associating a number to a series of strings. 2) Yes! 3) i think that an option at the beginning of program would be useful, 99% times i use strings in arrays, and 99% times i use strings not in arrays they are long max 1 line of screen.. eventually i use longer strings but because i know that a string is long 255 so i try to take full advantage of it.. Juri Juri, I posted a method of using short strings a while ago. It might be useful for your programs. http://www.thebackshed.com/forum/forum_posts.asp?TID=5236&KW =short+string Jim VK7JH MMedit MMBasic Help |
||||
Page 3 of 3 |
Print this page |