-
• #2
There are a bunch of predefined functions added with
addToDictionary
. To add one to toggle the LED you can do:addToDictionary("led", function (context) { LED.write(context.stack.pop()); });
So
1 led
will then turn the LED on. -
• #3
This is actually a different JS forth implementation based on https://github.com/eatonphil/jsforth - it looks like it's far more efficient, although I'm not convinced it handles strings.
Turns out there are loads of them out there :)
1 Attachment
-
• #4
Thank you very much Gordon. I like Forth for many years and I like boards. EasuyForth was actually an option to run Forth on the web without implementing anything. And for anybody who does not know what this language is, see on the Forth Inc website the older version https://www.forth.com/starting-forth/ or an updated PDF at http://www.exemark.com/FORTH/StartingFORTHfromForthWebsitev9_2013_12_24.pdf . I came to this website as there are boards that run Javascript and a small Forth written in Javascript - EasyForth that runs on the Internet. I will look at more of the offers here especially the board options. Thanks again Gordon. Anybody interested in Forth can have a look as well at the documentation from the eBook at https://wiki.forth-ev.de/doku.php/en:projects:a-start-with-forth:start0 all part of the Forth Bookshelf at https://www.amazon.co.uk/Juergen-Pintaske/e/B00N8HVEZM.
-
• #5
If Forth like honk then!
-
• #6
No problem. It looks like there are loads of Forth implementations for microcontrollers (that one was just for Arduino).
However a JS Forth engine should be very readable for anyone that's interested in the internals, and basing on top of Espruino you could take advantage of WiFi, Bluetooth LE, Filesystems, and all sorts of other stuff
-
• #7
Having an easy to understand basic Forth implementation on top of a good controller is the target. And then to explain how it all works. I did a couple of eBooks to show examples for beginners.
- Imagine You Invent A Language, chapter 4 in https://wiki.forth-ev.de/doku.php/en:projects:a-start-with-forth:start0 - 12 Instructions / Words to flash a virtual LED - here this could be a real LED.
- Chapter 6 to take this from 12 Words to 35 - an example application. Runs as well using virtual LEDs to be adapted to real ones.
- The Forth LITE Tutorial at https://www.amazon.co.uk/FORTH-LITE-TUTORIAL-compatible-SwiftForth-ebook/dp/B00L0F32Q8/ref=asap_bc?ie=UTF8
And there are many more options.
The same is planned for Python with a Forth written in Python.
- Imagine You Invent A Language, chapter 4 in https://wiki.forth-ev.de/doku.php/en:projects:a-start-with-forth:start0 - 12 Instructions / Words to flash a virtual LED - here this could be a real LED.
-
• #8
Gordon, these many Forth implementations are more of a problem than a help. Which one should people try , evaluate, which ones will be supported in the future?
As such the foc commercial MSP VFX LITE versions for MSP430G2553 and for some ARM based Boards are well supported - not only for the maker scene - but as well for later commercial projects.
And Duncan uses this version for the MicroMouse Projects with his Warriors. http://www.micromouseonline.com/2018/04/10/minos-2018-2/
I got an email today asking whether the JavaScript 'Easy Forth' (https://skilldrick.github.io/easyforth/) would work on Espruino... It turns out it will!
You'll need a 'cutting edge' firmware (or release 1v100 or later when that's released) as it happened to show up a few things that Espruino didn't implement or where it wasn't doing quite the right thing.
The modifications to the code itself are:
Having said that if you did 'save on send' you'd probably have enough memory for it.
Once uploaded, you can just run
cmd("1 2 +")
to execute a bit of code.The interpreter could be so much more efficient than it is, but still - it's fun to be able to run something meant for a browser pretty much as-is.
1 Attachment