moechofe 2021-08-06 16:06

@Timo: Is it possible to add ON-GOTO and ON-GOSUB?

was8bit 2021-08-07 06:03

As i understand, lowres NX is 99.9% finished... it is rather robust as is...

There is a way to accomplish what you want....


was8bit 2021-08-07 06:04

Personally, i like power of SUBS...

was8bit 2021-08-07 06:07

Your posted example uses line numbers as well as : seperated commands... neither of which are used by lowres...

If you are familiar with these, you should be familiar with assembly languuge, and lowres NX implements many of these features already ;) PEEK POKE INC DEC...etc..l

Timo 2021-08-07 08:47

ON GOTO/GOSUB/CALL could be implemented with jump labels instead of line numbers. The ":" separator in the example is not really part of these commands, so no problem.

As I explained in the last release message, I'm not really working on LowRes NX anymore. In fact, adding a new command is fun sometimes, but of course I would have to build and publish it for all platforms (manually), which is the annoying part. Just for one command, which doesn't really bring anything new to the system, it's not worth the trouble, sorry.

moechofe 2021-08-07 10:07

Yes, I understand your point @Timo about to the time spent for one new feature. If later you found motivation to work on it again, I think it will be a nice to have. The purpose of ON-GOTO in not to add a new tool to the language, but to reduces the cost in token and CPU usage.

was8bit 2021-08-07 13:32

@moechofe, the exact example you posted is limited to incremental cardinal numbers starting with 1, and all numbers included (1,2,3,4,5,6,etc) ...

My most common application is when i am using the background data as memory (rather than using arrays) and each char# found must be processed seperately....

in this case, Timo advised to do a one time check that either bypasses (found a blank space) or goes on to process (found a non-blank)... this speeds things up ... then for processing i usually have about a dozen random #'s under 256 that are seperately processed.... your code would check all 255 or so possibilities when in reality i only need around 12 checks...

Also, how about checks for text variables?

... one last thought, programming style.... i usually avoid a gosub unless several different parts of my code are using identical blocks of code.. in that instance, i will use GOSUB to reduce code, and it also makes it easier to edit changes to that one block of code rather trying to find and re-edit that code that is copied thruout several times...

moechofe 2021-08-07 20:40

@was8bit I shouldn't put the link to the example, you get it wrong.
I just want something to goto somewhere according to a number from 0 to x. That's all.
It is called branch table in assembly. https://en.wikipedia.org/wiki/Branch_table
And the same kind of behavior can be achieved using ON-GOTO in Basic.

was8bit 2021-08-08 06:33

I can see its use, for sure... :)

nathanielbabiak 2021-08-18 11:50

Branch tables (with optimal binary trees, even) are still possible in LowRes NX, you just have to code it yourself (and it looks really confusing).

My upload of the 3d raycasting demo uses one.

Log in to reply.