|
Forum Index : Microcontroller and PC projects : CMM2: Line continuation character, SWAP
| Author | Message | ||||
| bar1010 Senior Member Joined: 10/08/2020 Location: United StatesPosts: 197 |
FreeBASIC uses the underscore character for line continuation. Do we have something similar to use in the editor? If not, could we have this functionality added? Also I have seen a SWAP command in QuickBASIC which swaps the values of two variables. Could we have this functionality added? |
||||
| thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4398 |
I will save Peter some time: Line continuation: see http://www.thebackshed.com/Forum/ViewTopic.php?TID=12819 SWAP: probably not as the 128 tokens available for MMBasic commands has been reached on the CMM2 - it's an architectural limitation. Best wishes, Tom Edited 2021-06-08 05:31 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
| thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4398 |
Note that because parameters are pass by reference you could write SUBroutines to provide your own SWAP, you'd need one per type and unfortunately you'd have to pay a significant performance penalty over an inbuilt command. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1769 |
I think, that is correct. But it's easy to make your own: For example, you might define a subroutine to swap two values, as follows: (CMM2 manual p27) SUB Swap a, b LOCAL t t = a a = b b = t END SUB ... or write a short CSUB Regards Michael ‚My name is Ozymandias, king of kings Look on my works, ye Mighty, and despair!‘ Nothing beside remains. Round the decay Of that colossal wreck, boundless and bare The lone and ... |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
it is likely you will only ever use SWAP in one or two places in any given program. The overhead of a SUB makes for a very slow SWAP. If you are doing it in tight loops (e.g. in a sort function), better to do it inline for big increase in speed. All things speed-wise are relative of course |
||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 625 |
There is a nice old challenge with the swap function. How can we do it without creating a third variable? ![]() Edited 2021-06-08 09:19 by LeoNicolas |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4378 |
Does it work with floating point, not to mention strings... LOL John |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 9135 |
Now there's a thought ... Swap the variable pointers, not the variables. Edited 2021-06-08 16:40 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |