![]() |
Forum Index : Microcontroller and PC projects : CMM2: Guide to writing portable reusable code
![]() ![]() |
|||||
Author | Message | ||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
I did SgnX() for precisely this reason. I was dealing with the usual signed INTs (7,15,31) plus a couple of oddies (6 and the wasteful 9 a whole byte for an extra bit+sign! ![]() It extends the sign bit of any length integer to make a MMBasic compliant version. http://www.fruitoftheshed.com/MMBasic.Sign-Extend-an-Integer.ashx |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
I did a similar article on FotS wiki. Might give you some input - or something to throw rotten fruit at http://www.fruitoftheshed.com/MMBasic.Some-Hints-Tips-for-writing-efficient-code.ashx |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1642 |
Hi mkopack73, Your response prompted me to dust off a few books I have and do a little checking on base 0 for arrays. Commodore C64, Commodore Pet, TRS-80, GW-Basic, QuickBasic and Apple basic all default to base 0 for arrays. Also, judging from a BBC micro listing I have, so did that. As far as I can see the 8-bit machines did not have the OPTION BASE directive to alter that. The earliest version of MMBasic on Geoff's site for the mono Maximite includes the OPTION BASE directive and it's been a part of MMBasic ever since as far as I know so that's not Peter's doing. Bill Keep safe. Live long and prosper. |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Are we still talking about this ? ![]() According to "The BASIC Handbook, 2nd Edition" it is part of ANSI Standard BASIC. Before that (?) it may have come from something called "Harris BASIC-V". Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
https://en.wikipedia.org/wiki/True_BASIC: "By the early 1980s, tens of millions of home computers were running some variation of Microsoft BASIC, which had become the de facto standard. The ANSI efforts eventually became pointless, as it became clear that these versions were not going to have any market impact in a world dominated by MS. Both versions were eventually ratified, but saw little or no adoption and the standards were later withdrawn." MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1642 |
Yes Tom, This whole base 0|1 business is a storm in a teacup. Over analysed, over discussed and over explained. Geoff's documents are all that are needed. I just don't like being told that I am wrong when I know I'm not. Bill Keep safe. Live long and prosper. |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Fair enough, I missed that occurrence, as it happens me neither ![]() MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
Huh, looks like you're right. I pulled out the old Commodore 64 User's Guide and looked it up and yeah, it was 0-indexed... I don't know why I have it in my head that it was 1-based... something from back in that era must have been for me to remember it this way. Pascal maybe (looking online, it looks like that might be what I'm thinking of, although it allows you to specify whatever you want for lower and upper bound indexes) ? Or an older version of BASIC I'm thinking of? Ah, it's FORTRAN that uses 1-index! That's probably what I'm thinking of... Something HAD to have been 1 based for the option to even come up... Even then I think it's dumb that you dimension based on the LAST index vs the SIZE you want, but whatever. It's still a concern when writing reusable code on this machine and still needs to be addressed in some way, so we haven't gotten rid of the reasoning for the section in the document I wrote, nor the mitigation approach suggested. |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
Ah, nice.. Yes some good things in there! |
||||
Womble![]() Senior Member ![]() Joined: 09/07/2020 Location: United KingdomPosts: 267 |
Nimue, you may find "Programming in GW-Basic" by P. K. McBride useful for ideas for your students. Originally published in 1989, and reprinted a number of times since, it is available on Google Books and can be previewed there. Not cheap, but you may have luck locating a used copy on ebay or abe books. I just bought another copy on ebay as I cannot find my original. It was the first programming book I bought circa 1990 when I acquired my first PC. If I find my original copy I will PM you, but it is probably buried in one of the 40+ boxes of books in my loft. Regards Womble |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |