How is forth working with files, programs or scripts on the Parallax Propeller P2
Ive been watching a load of videos about forth and kind of getting lost in the subject of most videos being about stacks and math; and few I find about actually doing anything more than flashing some Leds from a single line of code or running single line commands that do other things. I get the idea that it does what you want it to do along the lines of configuring a PLC to automate some tasks; and words are like functions but how about something more normal like an application that is saved as a file on an SD card that gets ran.
This got me wondering how forth uses external programs. Lets say we have a program that is saved as .fth
I know that you can create functions and make them part of the running forth which would be lost at the next power cycle but lets say I want a bunch of applications/functions or words that arnt saved into the tachoz system on flash but instead are files on some media.
How do you go about loading a file and running it. Like one that sends "hello world" to the terminal or one that does a bunch of tasks to be more than one line of code.
Also, is it possible to store such applications on the Flash to be called up by Tachoz
While I am writing, I am thinking about the concept to not tinker with the running Tachoz itself but create external forth scripts that are loaded and ran by the Tachoz, in the usual file system way like we would with Basic
Last one, of course if all the files are stored on lets say SD, and the P2 was power cycled, what would run the first application, basically it needs some user intervention to get rolling, does Tachoz look for some specific file/word on the lines of Autoexec.bat
This subject is likely very useful for others also looking at forth and Tachoz.
Anyone can enlighten this a little bit.
Comments
If you want Taqoz to behave more like an operating system which can load, compile and run a program, then discard it; have a look at 'Run SD card command' on my Forth Stuff Github site. If an unknown word is typed in, forth no longer complains about it, it goes off and finds a file on sdcard of the same name. If that exists, it loads the contents, as if it were typed in. This could be a complete forth program, which is then run until it terminates, at which point it is forgotten again. Just like DOS or CP/M used to do. Here's a trivial program (file on sdcard named whatever you like) that my Batch File code could handle:-
( In reality a forth program would be many definitions, ending in the top level word that is the program )
Storing on Flash, instead of SD-card would be possible, but I haven't explored doing it that way. SD-card has a lot of advantages for a product, not the least being easy firmware update. Worth it for the price of an SD card socket.
You can load such files onto the SD card using a P.C. and Taqoz can read those just fine.
Here's the original thread on this topic.
To autostart a user program from source code (as above) see page 33 of my 'Taqoz Reloaded V2.8 Glossary of Words'
Cheers, Bob
Cheers Bob but a point or understanding is missing,
I realize that you pretty much program the P2/Tachoz just like you would a PLC giving it instructions and then save them in Taqoz to perform that forever or on tap as required but what I saw so far is: if you make something and want to change it later, then it requires to do it all over again. What do you do in that situation.
If you create a function that carries out a process and that process isnt quite right, you should make a new one? or edit an existing one?.
I don't think Taqoz is any different from your PLC example in that respect. Taqoz is an interpreter program, like the interpreter in the PLC. If the application program or script has bugs, well that needs reprogramming into the hardware and the product retested to check the bugs are gone. That would involve either reprogramming the Flash chip or the SD card, it depends where you've got Taqoz and the application stored.
The forth source code is usually re-edited to fix bugs. The application source code is sent to the input terminal of the basic Taqoz system and the fixes tested. If all the bugs are fixed, then:-
Thanks Bob,
I am only writing about development environment, not deployment.