vitoco Posted August 15, 2021 Share Posted August 15, 2021 1 hour ago, nebpehtira said: IF option = 1 THEN EXEC trimix ELIF option = 2 THEN EXEC mod Just write: IF option = 1 : EXEC trimix ELIF option = 2 : EXEC mod I mean, replace "THEN" by ":". 1 Quote Link to comment Share on other sites More sharing options...
Preppie Posted August 16, 2021 Share Posted August 16, 2021 THEN is used when there's only one possible outcome, otherwise you use IF...ENDIF (with optional ELIF and/or ELSE) which allows you to span multiple lines of code. Simple thing to do is never use THEN and you'll get to grips with it a lot faster. 1 Quote Link to comment Share on other sites More sharing options...
nebpehtira Posted August 16, 2021 Share Posted August 16, 2021 Thanks all - will have a play after work Quote Link to comment Share on other sites More sharing options...
nebpehtira Posted August 16, 2021 Share Posted August 16, 2021 Working nicely now, thanks! Quote Link to comment Share on other sites More sharing options...
+MrFish Posted August 16, 2021 Share Posted August 16, 2021 19 hours ago, vitoco said: Just write: IF option = 1 : EXEC trimix ELIF option = 2 : EXEC mod I mean, replace "THEN" by ":". Isn't this a job for: ON option EXEC trimix, mod, (etc.) Or is it not part of the language? Quote Link to comment Share on other sites More sharing options...
vitoco Posted August 16, 2021 Share Posted August 16, 2021 1 hour ago, MrFish said: Isn't this a job for: ON option EXEC trimix, mod, (etc.) Or is it not part of the language? No, it isn't. But you can request the feature in Fastbasic's issue tracker. Quote Link to comment Share on other sites More sharing options...
+MrFish Posted August 16, 2021 Share Posted August 16, 2021 3 minutes ago, vitoco said: No, it isn't. But you can request the feature in Fastbasic's issue tracker. I'd say it's a good one to add. TBXL uses it (as well as ON GO# -- line label), and even Atari BASIC has ON GOTO & GOSUB (which means TBXL has these too). Either that or add some type of SWITCH/CASE type structure. Quote Link to comment Share on other sites More sharing options...
FifthPlayer Posted August 16, 2021 Share Posted August 16, 2021 Atari BASIC also has the construct GOTO <expression> and GOSUB <expression>, where <expression> can evaluate to a line number at runtime. So in Atari BASIC you could write something like: 100 INPUT OPTION: GOSUB OPTION * 1000 where "trimix" starts at line 1000, "mod" starts at 2000, "end" starts at 3000, "min_od" starts at 4000 and so on. 1 Quote Link to comment Share on other sites More sharing options...
nebpehtira Posted August 17, 2021 Share Posted August 17, 2021 11 hours ago, MrFish said: I'd say it's a good one to add. TBXL uses it (as well as ON GO# -- line label), and even Atari BASIC has ON GOTO & GOSUB (which means TBXL has these too). Either that or add some type of SWITCH/CASE type structure. CASE would be good one to have. Working with BBC Basic on RISC OS I've found it nice and easy to work with. 1 Quote Link to comment Share on other sites More sharing options...
Preppie Posted August 17, 2021 Share Posted August 17, 2021 There's also a little trick that's useful for writing ten liners. IF a=1 THEN b=2:c=1 In this line c will equal 1 regardless of what value a has because the colon acts as a completely new line, unlike Atari BASIC where it acts as an extansion to the current line. IFa=1t.b=2:c=1 IFa=1:b=2:e.:c=1 As you can see, it save 2 bytes over using IF..ENDIF Quote Link to comment Share on other sites More sharing options...
stepho Posted August 18, 2021 Share Posted August 18, 2021 13 hours ago, Preppie said: IF a=1 THEN b=2:c=1 In this line c will equal 1 regardless of what value a has because the colon acts as a completely new line, unlike Atari BASIC where it acts as an extansion to the current line. I always mentor my junior colleagues to not do that in their C/C++ code. It leads to the next guy thinking that c=1 is also conditional when it isn't. Of course, when trying to bum every byte then you do what you need to do - but it's still gross. 1 Quote Link to comment Share on other sites More sharing options...
dmsc Posted August 18, 2021 Author Share Posted August 18, 2021 Hi all, and thank you for all responses! On 8/16/2021 at 2:31 PM, MrFish said: Isn't this a job for: ON option EXEC trimix, mod, (etc.) Or is it not part of the language? Not currently, as Vitoco said, FastBasic currently does not support the "ON/EXEC" statement. On 8/16/2021 at 4:37 PM, MrFish said: I'd say it's a good one to add. TBXL uses it (as well as ON GO# -- line label), and even Atari BASIC has ON GOTO & GOSUB (which means TBXL has these too). Yes, it could even make the editor shorter - as currently uses a long string of "IF KEY=*" for processing all keyboard commands. To correctly implement it, I would need a way to count the number of parameters in the parser, basically, the parser needs to transform this: ON expression EXEC A,B,,,E,F Into this: DATA targets() = A,B,0,0,E,F temp = expression IF temp > 0 AND temp <= 6 THEN EXEC targets(temp) This is specially difficult as the parser can't create arbitrary variables (in this case, "targets" and "temp"), so it would be better to define a new token that mixes all the above. i'm currently rewriting the cross-compiler, so the code is in a state of flux, but after that I will see if adding "ON/EXEC" is actually feasible - in the constraints of 8KB for the IDE. On 8/16/2021 at 7:44 PM, FifthPlayer said: Atari BASIC also has the construct GOTO <expression> and GOSUB <expression>, where <expression> can evaluate to a line number at runtime. So in Atari BASIC you could write something like: 100 INPUT OPTION: GOSUB OPTION * 1000 where "trimix" starts at line 1000, "mod" starts at 2000, "end" starts at 3000, "min_od" starts at 4000 and so on. That is not possible in FastBasic, as it does not have line numbers. Also, it is a very bad construct from the compiler point of view, as you can't easily predict the control-flow, making some optimizations imposible - in your example it even allows to jump to any line of the code!. I specifically removed "GOTO" from the language to simplify the parser and make the generated code faster. On 8/16/2021 at 4:37 PM, MrFish said: Either that or add some type of SWITCH/CASE type structure. On 8/17/2021 at 4:44 AM, nebpehtira said: CASE would be good one to have. Working with BBC Basic on RISC OS I've found it nice and easy to work with. That would not be as difficult, but IMHO, it does not add anything to the language not possible already, it is fairly easy to just do: X = expression IF X = 2 ; Case 2 ELIF X = 5 ; Case 5 ELIF X = 1234 ; Case 1234 ENDIF Have Fun! 2 Quote Link to comment Share on other sites More sharing options...
+MrFish Posted August 18, 2021 Share Posted August 18, 2021 5 minutes ago, dmsc said: i'm currently rewriting the cross-compiler, so the code is in a state of flux, but after that I will see if adding "ON/EXEC" is actually feasible - in the constraints of 8KB for the IDE. Why the constraint of 8 KB? 5 minutes ago, dmsc said: That would not be as difficult, but IMHO, it does not add anything to the language not possible already, it is fairly easy to just do: This was just a suggestion, failing ON/EXEC. Even though it's generally replicated with multi-line IF/ELIF, it's more about code organization and clarity. Quote Link to comment Share on other sites More sharing options...
dmsc Posted August 18, 2021 Author Share Posted August 18, 2021 Hi! Just now, MrFish said: Why the constraint of 8 KB? It is a self-imposed constraint to limit the growth of the language: Mi intent is for FastBasic to be small, simple and fast. So, every time I add something to the language, it needs to be tough as how to minimally add the feature and justify it's usefulness. Just now, MrFish said: This was just a suggestion, failing ON/EXEC. Even though it's generally replicated with multi-line IF/ELIF, it's more about code organization and clarity. Yes, I know. What I was trying to say is that IMHO, the current "IF/ELIF/ENDIF" structure gives good code clarity, without complicating the language. Have Fun! 3 Quote Link to comment Share on other sites More sharing options...
vitoco Posted August 18, 2021 Share Posted August 18, 2021 27 minutes ago, dmsc said: Quote This was just a suggestion, failing ON/EXEC. Even though it's generally replicated with multi-line IF/ELIF, it's more about code organization and clarity. Yes, I know. What I was trying to say is that IMHO, the current "IF/ELIF/ENDIF" structure gives good code clarity, without complicating the language. And about clarity and simplicity, it won't be possible to include PROC's parameters in the ON/EXEC list like in the actual EXEC!!! Quote Link to comment Share on other sites More sharing options...
dmsc Posted August 18, 2021 Author Share Posted August 18, 2021 Hi! 1 hour ago, vitoco said: And about clarity and simplicity, it won't be possible to include PROC's parameters in the ON/EXEC list like in the actual EXEC!!! Yes, you would need to write an "stub" to call PROC's with parameters: ON x EXEC A,B,C PROC A EXEC P 2, 3 ENDPROC Also, it could be abbreviated " O. x @ A, B, C ", with only one "@". Have Fun! Quote Link to comment Share on other sites More sharing options...
+mytek Posted August 19, 2021 Share Posted August 19, 2021 I just started playing around with FastBasic (V4.52), and decided to see if it would work at 80 columns with my XEP80-II, and Avery's Ultra driver. So far so good, although I have much to learn and presently no time, so this will have to go on the back burner for now. Nice to have the extra navigation keys PageUp and PageDown working from my TK-II and a PS/2 keyboard. And I was blown away to see that the IDE works as a full screen editor allowing me to move up and down the pages quite easily very much like being in a word processor. Nice job ? This just gives me the extra incentive I needed to get this project completed BTW, can FastBasic be an 8K cart image? Was thinking it would be kinda cool to have it as an alternate Basic in my 576NUC+. 6 Quote Link to comment Share on other sites More sharing options...
FifthPlayer Posted August 20, 2021 Share Posted August 20, 2021 1 hour ago, mytek said: BTW, can FastBasic be an 8K cart image? Was thinking it would be kinda cool to have it as an alternate Basic in my 576NUC+. I like this idea. Another benefit of self-limiting the IDE to 8K. 2 Quote Link to comment Share on other sites More sharing options...
+mytek Posted August 21, 2021 Share Posted August 21, 2021 On 8/19/2021 at 6:11 PM, FifthPlayer said: I like this idea. Another benefit of self-limiting the IDE to 8K. @dmsc hasn't logged in for over a month. I sure hope he's ok. Quote Link to comment Share on other sites More sharing options...
dmsc Posted August 21, 2021 Author Share Posted August 21, 2021 Hi! 1 hour ago, mytek said: @dmsc hasn't logged in for over a month. I sure hope he's ok. Yes, I'm ok... just very busy with my main job ? Have Fun! 5 Quote Link to comment Share on other sites More sharing options...
+mytek Posted August 21, 2021 Share Posted August 21, 2021 (edited) 1 hour ago, dmsc said: Hi! Yes, I'm ok... just very busy with my main job ? Have Fun! Good to hear Edited August 21, 2021 by mytek Quote Link to comment Share on other sites More sharing options...
nebpehtira Posted August 22, 2021 Share Posted August 22, 2021 On 8/20/2021 at 12:40 AM, mytek said: BTW, can FastBasic be an 8K cart image? Was thinking it would be kinda cool to have it as an alternate Basic in my 576NUC+. I like that idea too 2 Quote Link to comment Share on other sites More sharing options...
+mytek Posted August 22, 2021 Share Posted August 22, 2021 17 minutes ago, nebpehtira said: I like that idea too It would be best if @dmsc could compile it for this use (as an 8K cart). But it looks like that might have to wait until his job gives him a breather. 1 Quote Link to comment Share on other sites More sharing options...
+MrFish Posted August 22, 2021 Share Posted August 22, 2021 On 8/18/2021 at 11:19 AM, dmsc said: It is a self-imposed constraint to limit the growth of the language: Mi intent is for FastBasic to be small, simple and fast. So, every time I add something to the language, it needs to be tough as how to minimally add the feature and justify it's usefulness. Noble cause. On 8/19/2021 at 7:40 PM, mytek said: BTW, can FastBasic be an 8K cart image? Was thinking it would be kinda cool to have it as an alternate Basic in my 576NUC+. This would be a nice, additional justification for the constraint. 3 Quote Link to comment Share on other sites More sharing options...
+Philsan Posted September 20, 2021 Share Posted September 20, 2021 I made a video to show that you can code on real Atari too. Other modern languages cannot do it. This is a big difference! 3 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.