BASIC: New Commands

If you have feature requests, this is the place to post them. Please note your idea may already be something we have already discussed and decided against, or something we are working on privately, and we cannot be held responsible for any similarities in such instance. Whilst we cannot respond to every suggestion, your idea will be read and responded to where possible. Thank you for your input!
geek504
Posts: 95
Joined: Wed Aug 26, 2020 4:52 pm

BASIC: New Commands

Post by geek504 »


LOCATE (GW-BASIC) or HTAB and VTAB (Applesoft BASIC)

MOD (modulo)

ELSE (would be nice)

 

User avatar
StephenHorn
Posts: 565
Joined: Tue Apr 28, 2020 12:00 am
Contact:

BASIC: New Commands

Post by StephenHorn »


I have a feeling that "ELSE" would be the hardest one out of that lot. XD

Developer for Box16, the other X16 emulator. (Box16 on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
TomXP411
Posts: 1785
Joined: Tue May 19, 2020 8:49 pm

BASIC: New Commands

Post by TomXP411 »


Yes, I would really, really like to see LOCATE. 



ELSE isn't that hard... Commodore did it on the 128. ELSE has to be on the same line as the IF/THEN. So the parser just skips forward in the line when the IF is false and looks for an ELSE.

The problem is that this makes IF/THEN slower, since the parser has to work through the whole line when the condition is false. And it's very easy to reverse the IF condition and GOTO over a block of code, so I'm not sure ELSE is actually necessary or useful. 

But LOCATE and MOD are definitely useful. MOD makes certain type of math much faster (especially when doing byte conversions and base conversions), and LOCATE really should have been part of the command set since the beginning. 

 

TomXP411
Posts: 1785
Joined: Tue May 19, 2020 8:49 pm

BASIC: New Commands

Post by TomXP411 »



3 hours ago, geek504 said:




LOCATE (GW-BASIC) or HTAB and VTAB (Applesoft BASIC)



MOD (modulo)



ELSE (would be nice)



 



Add these as feature requests, here:

https://github.com/commanderx16/x16-rom/issues

LOCATE is actually already on the list: https://github.com/commanderx16/x16-rom/issues/128

ELSE and MOD are not yet there, so adding those as suggestions might be nice.

Create a separate issue for each of the two commands and prefix the title with "Feature Request." So:


  • Feature Request: ELSE statement


  • Feature Request: MOD operator


 

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

BASIC: New Commands

Post by BruceMcF »



4 hours ago, geek504 said:




LOCATE (GW-BASIC) or HTAB and VTAB (Applesoft BASIC)



MOD (modulo)



ELSE (would be nice)



 



ELSE could be a matter of someone integrating the 128 code into the current Basic and doing a pull request.

LOCATE ... AT-XY in Forth ... with just the first two parameters is just making a Kernel call available.The third option to turn off the cursor for "silent" placement of text graphics is also valuable, especially since that was done in the C64 with magic locations.

For GET-XY, CURSOR(0|1) where 0 is the X and 1 is the Y would work.

Note: ELSE is in the feature requests, just a lot further back.

SerErris
Posts: 172
Joined: Sat Aug 08, 2020 9:18 am

BASIC: New Commands

Post by SerErris »


I agree, I do not see any reason for else.

You do not need to do anything it works out of the box like that:


Quote




 



10 A=0

20 IF A>0 THEN PRINT "SOMETHING":A=0:GOTO100

30 REM ELSE

40 PRINT "SOMETHING ELSE"

50 A=1

100 REM CONTINUE

110 PRINT "WE LEFT"



 



So we even have a ELSE with multiple lines already in it. Yes it is a little bit different to write but it is not an issue and easy to understand after you  worked with it. 

geek504
Posts: 95
Joined: Wed Aug 26, 2020 4:52 pm

BASIC: New Commands

Post by geek504 »



9 hours ago, TomXP411 said:




Feature Request: MOD operator



Done!

geek504
Posts: 95
Joined: Wed Aug 26, 2020 4:52 pm

BASIC: New Commands

Post by geek504 »



3 hours ago, SerErris said:




So we even have a ELSE with multiple lines already in it. Yes it is a little bit different to write but it is not an issue and easy to understand after you  worked with it.



Agreed. ELSE would be nice but not essential since it can be done using IF/THEN/GOTO. It's actually better not to have it for two reasons:

1. Use less ROM space; BUT if we have 128-512K ROM, why not?

2. Easier transition to assembly language programming which is really COMPARE/BRANCH/JUMP style.

I only suggested for the sole purpose of teaching kids how to program and ELSE would be nice to have! Two-character variable names is tough to teach with... I'm thinking for teaching just programming maybe GW-BASIC is better, but if I wanted to teach hardware too, moving from GW-BASIC to C64 BASIC would be quite "painful"!

SerErris
Posts: 172
Joined: Sat Aug 08, 2020 9:18 am

BASIC: New Commands

Post by SerErris »


Maybe it is good to start very basic and work your way up. The same is true for if then else. It is either else or goto, does not matter. Most languages do not have a goto instruction. The problem is that else is very slow the goto variant is also much faster which is most likely not a concern. Easier to read for someone not that familiar with a simple basic or even assembler dialect, so maybe it is good to implement and have options, however even the C128 implementation is very limited (one line if instruction)

TomXP411
Posts: 1785
Joined: Tue May 19, 2020 8:49 pm

BASIC: New Commands

Post by TomXP411 »



1 hour ago, SerErris said:




Most languages do not have a goto instruction.



Quite the opposite is true... while modern, fad languages tend to leave it out (Python is a notable example), the keyword and operation is in most programming languages. C, C++, and C# all have it, for example, and Microsoft gives a pretty compelling use case in the c# documentation. 

In fact, out of the current languages labeled as most popular, 7 of them have explicit GOTO statements. And as you go back in time, it gets difficult to find a language without an unconditional branch statement before Java. (There was one, "BLISS", but I don't think anyone has heard of it outside of academic circles.)

 

Post Reply