slviajero / tinybasic

A BASIC interpreter for Arduino, ESP, RP2040, STM32, Infineon XMC and POSIX with IoT and microcontroller features.
GNU General Public License v3.0
197 stars 32 forks source link

Documentation request #23

Closed EncomLab closed 2 years ago

EncomLab commented 2 years ago

This may not be a direction you are interested in, but it would be nice to have a basic outline of how to add additional tokens and functions to the interpreter. I add a WDT based reset command and token, but am having trouble adding commands with arguments (servo and motor speed commands). I stripped out the DWRITE code and dropped in a servo command which worked fine, but I don't understand the numbering attached to the tokens and how how they relate to the BASE token.

If you don't want to get into extensibility I fully understand.

slviajero commented 2 years ago

Actually I wrote a little tutorial on how to extend the language:

https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands

Maybe this helps. If you want to do something more complicated, please tell me.
I can create some template functions.

Best, Stefan

Am 05.07.2022 um 15:16 schrieb Encom Lab @.***>:

This may not be a direction you are interested in, but it would be nice to have a basic outline of how to add additional tokens and functions to the interpreter. I add a WDT based reset command and token, but am having trouble adding commands with arguments (servo and motor speed commands). I stripped out the DWRITE code and dropped in a servo command which worked fine, but I don't understand the numbering attached to the tokens and how how they relate to the BASE token.

If you don't want to get into extensibility I fully understand.

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/23, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56FTOPGC2RTPV645PHTVSQYRRANCNFSM52WF6C4Q. You are receiving this because you are subscribed to this thread.

pgrobelniak commented 2 years ago

Ha, good to know there is this documentation :) I've been able to add few (not very useful) commands myself in my fork.

wt., 5 lip 2022, 22:41 użytkownik Stefan Lenz @.***> napisał:

Actually I wrote a little tutorial on how to extend the language:

https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands < https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands

Maybe this helps. If you want to do something more complicated, please tell me. I can create some template functions.

Best, Stefan

Am 05.07.2022 um 15:16 schrieb Encom Lab @.***>:

This may not be a direction you are interested in, but it would be nice to have a basic outline of how to add additional tokens and functions to the interpreter. I add a WDT based reset command and token, but am having trouble adding commands with arguments (servo and motor speed commands). I stripped out the DWRITE code and dropped in a servo command which worked fine, but I don't understand the numbering attached to the tokens and how how they relate to the BASE token.

If you don't want to get into extensibility I fully understand.

— Reply to this email directly, view it on GitHub < https://github.com/slviajero/tinybasic/issues/23>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACSY56FTOPGC2RTPV645PHTVSQYRRANCNFSM52WF6C4Q . You are receiving this because you are subscribed to this thread.

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175478463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4ZW22ALUVL33YKQWRADFLVSSMYFANCNFSM52WF6C4Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

slviajero commented 2 years ago

Just had a look. You added a keyword to position the cursor. This functionality is always there ;-)

Try to do

@X=10: @Y=8: PRINT „Something“;

The special variables @X, @Y are the cursor postions. They are read / write.

Best, Stefan

Am 05.07.2022 um 22:51 schrieb Paweł Grobelniak @.***>:

Ha, good to know there is this documentation :) I've been able to add few (not very useful) commands myself in my fork.

wt., 5 lip 2022, 22:41 użytkownik Stefan Lenz @.***> napisał:

Actually I wrote a little tutorial on how to extend the language:

https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands < https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands

Maybe this helps. If you want to do something more complicated, please tell me. I can create some template functions.

Best, Stefan

Am 05.07.2022 um 15:16 schrieb Encom Lab @.***>:

This may not be a direction you are interested in, but it would be nice to have a basic outline of how to add additional tokens and functions to the interpreter. I add a WDT based reset command and token, but am having trouble adding commands with arguments (servo and motor speed commands). I stripped out the DWRITE code and dropped in a servo command which worked fine, but I don't understand the numbering attached to the tokens and how how they relate to the BASE token.

If you don't want to get into extensibility I fully understand.

— Reply to this email directly, view it on GitHub < https://github.com/slviajero/tinybasic/issues/23>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACSY56FTOPGC2RTPV645PHTVSQYRRANCNFSM52WF6C4Q . You are receiving this because you are subscribed to this thread.

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175478463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4ZW22ALUVL33YKQWRADFLVSSMYFANCNFSM52WF6C4Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175485805, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56ENKHBC75RX6M37G4LVSSN5RANCNFSM52WF6C4Q. You are receiving this because you commented.

EncomLab commented 2 years ago

This is great! I had reverse engineered most of it but my error was trying add a new commands as -128 and -129. The RESET I added does work as -128 but I will move it to the correct spot. Do we need to change the "#define NKEYWORDS 3+19+13+12+11+5+2+7+7+7+12" to include additional KEYWORDS?

slviajero commented 2 years ago

not really anymore it was from an earlier code that was much simpler. by the way, reset exists alteady as CALL 0. xcall can be used as a general command for things like this.

Sent from my iPhone

On Jul 6, 2022, at 1:11 AM, Encom Lab @.***> wrote:

 This is great! I had reverse engineered most of it but my error was trying add a new commands as -128 and -129. The RESET I added does work as -128 but I will move it to the correct spot. Do we need to change the "#define NKEYWORDS 3+19+13+12+11+5+2+7+7+7+12" to include additional KEYWORDS?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

EncomLab commented 2 years ago

Just tested that - it works on my 1284 SBC but have no idea why lol. I used the WDT library and this: void soft_restart() { do { wdt_enable(WDTO_15MS); for (;;) { } } while (0); }

pgrobelniak commented 2 years ago

Just had a look. You added a keyword to position the cursor. This functionality is always there ;-) Try to do @x=10: @y=8: PRINT „Something“; The special variables @x, @y are the cursor postions. They are read / write. Best, Stefan Am 05.07.2022 um 22:51 schrieb Paweł Grobelniak @.>: Ha, good to know there is this documentation :) I've been able to add few (not very useful) commands myself in my fork. wt., 5 lip 2022, 22:41 użytkownik Stefan Lenz @.> napisał: > Actually I wrote a little tutorial on how to extend the language: > > > https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands > < > https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands > > > > Maybe this helps. If you want to do something more complicated, please > tell me. > I can create some template functions. > > Best, > Stefan > > > Am 05.07.2022 um 15:16 schrieb Encom Lab @.>: > > > > > > This may not be a direction you are interested in, but it would be nice > to have a basic outline of how to add additional tokens and functions to > the interpreter. I add a WDT based reset command and token, but am having > trouble adding commands with arguments (servo and motor speed commands). I > stripped out the DWRITE code and dropped in a servo command which worked > fine, but I don't understand the numbering attached to the tokens and how > how they relate to the BASE token. > > > > If you don't want to get into extensibility I fully understand. > > > > — > > Reply to this email directly, view it on GitHub < > #23>, or unsubscribe < > https://github.com/notifications/unsubscribe-auth/ACSY56FTOPGC2RTPV645PHTVSQYRRANCNFSM52WF6C4Q > >. > > You are receiving this because you are subscribed to this thread. > > > > — > Reply to this email directly, view it on GitHub > <#23 (comment)>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AA4ZW22ALUVL33YKQWRADFLVSSMYFANCNFSM52WF6C4Q > . > You are receiving this because you are subscribed to this thread.Message > ID: @.> > — Reply to this email directly, view it on GitHub <#23 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56ENKHBC75RX6M37G4LVSSN5RANCNFSM52WF6C4Q. You are receiving this because you commented.

I suspected i might have missed something like that :D thanks. i wrote few commands to tinker with the terminal modes/resolutions just for the sake of tinkering

slviajero commented 2 years ago

Its a little bit weird. The function void(* callzero)() = 0; compiles to a subroutine call to address 0. Flash address 0 on AVR is the start of the application code. Works on all Arduino Havard machine types of core.

Am 06.07.2022 um 12:03 schrieb Encom Lab @.***>:

Just tested that - it works on my 1284 SBC but have no idea why lol. I used the WDT library and this: void soft_restart() { do { wdt_enable(WDTO_15MS); for (;;) { } } while (0); }

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/23#issuecomment-1176032587, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56H7NHEVQZDPJTTITT3VSVKXDANCNFSM52WF6C4Q. You are receiving this because you commented.

slviajero commented 2 years ago

I suspected i might have missed something like that :D thanks. i wrote few commands to tinker with the terminal modes/resolutions just for the sake of tinkerin

Cool! As to the @X and related: you may have noticed the display buffer array @D() which is a character array of the display. Writing to it displays a character where ever you like. These concepts are not really „BASIC“ because the language design of BASIC is keyword oriented. I still like the way to work with variables. @C is an I/O stream variable (it is r/w for input and output) and @A is the number of characters available in the stream. @S is the I/O status i.e. if there is an end of file … condition.

Just a little example:

10 @.*** 20 IF C="#“ OR @S THEN END 30 @C=C 40 GOTO 10

Enjoy!

slviajero commented 2 years ago

documentation added

pgrobelniak commented 1 year ago

Yeah, I suspected I might have missed something like that ;D I implemented those few commands mostly to tinker around

wt., 5 lip 2022, 22:57 użytkownik Stefan Lenz @.***> napisał:

Just had a look. You added a keyword to position the cursor. This functionality is always there ;-)

Try to do

@X=10: @Y=8: PRINT „Something“;

The special variables @X, @Y are the cursor postions. They are read / write.

Best, Stefan

Am 05.07.2022 um 22:51 schrieb Paweł Grobelniak @.***>:

Ha, good to know there is this documentation :) I've been able to add few (not very useful) commands myself in my fork.

wt., 5 lip 2022, 22:41 użytkownik Stefan Lenz @.***> napisał:

Actually I wrote a little tutorial on how to extend the language:

https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands <

https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands

Maybe this helps. If you want to do something more complicated, please tell me. I can create some template functions.

Best, Stefan

Am 05.07.2022 um 15:16 schrieb Encom Lab @.***>:

This may not be a direction you are interested in, but it would be nice to have a basic outline of how to add additional tokens and functions to the interpreter. I add a WDT based reset command and token, but am having trouble adding commands with arguments (servo and motor speed commands). I stripped out the DWRITE code and dropped in a servo command which worked fine, but I don't understand the numbering attached to the tokens and how how they relate to the BASE token.

If you don't want to get into extensibility I fully understand.

— Reply to this email directly, view it on GitHub < https://github.com/slviajero/tinybasic/issues/23>, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ACSY56FTOPGC2RTPV645PHTVSQYRRANCNFSM52WF6C4Q

. You are receiving this because you are subscribed to this thread.

— Reply to this email directly, view it on GitHub < https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175478463>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA4ZW22ALUVL33YKQWRADFLVSSMYFANCNFSM52WF6C4Q

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub < https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175485805>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACSY56ENKHBC75RX6M37G4LVSSN5RANCNFSM52WF6C4Q . You are receiving this because you commented.

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175490001, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4ZW2YBDAQXHEUFOZCWKCLVSSOUFANCNFSM52WF6C4Q . You are receiving this because you commented.Message ID: @.***>

slviajero commented 1 year ago

By the way, just looked at your code. Impressed! I saw you implemented an INKEY. This was already there. It is called @C :-). Best Regards, Stefan

Am 11.10.2022 um 11:13 schrieb Paweł Grobelniak @.***>:

Yeah, I suspected I might have missed something like that ;D I implemented those few commands mostly to tinker around

wt., 5 lip 2022, 22:57 użytkownik Stefan Lenz @.***> napisał:

Just had a look. You added a keyword to position the cursor. This functionality is always there ;-)

Try to do

@X=10: @Y=8: PRINT „Something“;

The special variables @X, @Y are the cursor postions. They are read / write.

Best, Stefan

Am 05.07.2022 um 22:51 schrieb Paweł Grobelniak @.***>:

Ha, good to know there is this documentation :) I've been able to add few (not very useful) commands myself in my fork.

wt., 5 lip 2022, 22:41 użytkownik Stefan Lenz @.***> napisał:

Actually I wrote a little tutorial on how to extend the language:

https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands <

https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands https://github.com/slviajero/tinybasic/wiki/How-to-compile-Stefan's-BASIC-(and-how-it-works)#how-to-add-your-own-commands

Maybe this helps. If you want to do something more complicated, please tell me. I can create some template functions.

Best, Stefan

Am 05.07.2022 um 15:16 schrieb Encom Lab @.***>:

This may not be a direction you are interested in, but it would be nice to have a basic outline of how to add additional tokens and functions to the interpreter. I add a WDT based reset command and token, but am having trouble adding commands with arguments (servo and motor speed commands). I stripped out the DWRITE code and dropped in a servo command which worked fine, but I don't understand the numbering attached to the tokens and how how they relate to the BASE token.

If you don't want to get into extensibility I fully understand.

— Reply to this email directly, view it on GitHub < https://github.com/slviajero/tinybasic/issues/23 https://github.com/slviajero/tinybasic/issues/23>, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ACSY56FTOPGC2RTPV645PHTVSQYRRANCNFSM52WF6C4Q https://github.com/notifications/unsubscribe-auth/ACSY56FTOPGC2RTPV645PHTVSQYRRANCNFSM52WF6C4Q

. You are receiving this because you are subscribed to this thread.

— Reply to this email directly, view it on GitHub < https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175478463 https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175478463>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA4ZW22ALUVL33YKQWRADFLVSSMYFANCNFSM52WF6C4Q https://github.com/notifications/unsubscribe-auth/AA4ZW22ALUVL33YKQWRADFLVSSMYFANCNFSM52WF6C4Q

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub < https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175485805 https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175485805>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACSY56ENKHBC75RX6M37G4LVSSN5RANCNFSM52WF6C4Q https://github.com/notifications/unsubscribe-auth/ACSY56ENKHBC75RX6M37G4LVSSN5RANCNFSM52WF6C4Q . You are receiving this because you commented.

— Reply to this email directly, view it on GitHub <https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175490001 https://github.com/slviajero/tinybasic/issues/23#issuecomment-1175490001>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AA4ZW2YBDAQXHEUFOZCWKCLVSSOUFANCNFSM52WF6C4Q https://github.com/notifications/unsubscribe-auth/AA4ZW2YBDAQXHEUFOZCWKCLVSSOUFANCNFSM52WF6C4Q> . You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/23#issuecomment-1274373495, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56CUWSY3MVBKUHZRNYTWCUVUVANCNFSM52WF6C4Q. You are receiving this because you modified the open/close state.

pgrobelniak commented 1 year ago

Thanks :) i have also implemented @T to use sdl_ticks because i didn't notice there is already MILLIS ;D

slviajero commented 1 year ago

The people who have invented the super clean Dartmouth BASIC syntax will hate us both.

Am 13.10.2022 um 09:36 schrieb Paweł Grobelniak @.***>:

Thanks :) i have also implemented @t https://github.com/t to use sdl_ticks because i didn't notice there is already MILLIS ;D

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/23#issuecomment-1277164730, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56HJJDYWATHXXPWWE3DWC63Y7ANCNFSM52WF6C4Q. You are receiving this because you modified the open/close state.