|
Forum Index : Microcontroller and PC projects : Easily run favourite programs
| Author | Message | ||||
| Briano Newbie Joined: 20/01/2026 Location: CanadaPosts: 27 |
You may already know this, but I didn't. I can run my favourite program as a commend. For example, I have "Weather.bas". By adding this code to the library Sub Weather CHDIR "/" RUN "Weather" End Sub I can now type Weather at the command prompt and my weather program will run. Way cool! .....Brian |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3429 |
Yes, it's a very useful feature. You can even use it to make a self modifying program. A program that learns new stuff can save itself to a file, append the new data to the end of the file as subroutines and perhaps data statements. The program then RUNs that file which detects the new sub containing extra configuration variables to enable the new features. |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3372 |
I was the one who invented the library concept and it never occured to me that it could be used in that way! It just shows... you can always learn something new. Geoff Geoff Graham - http://geoffg.net |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6252 |
Hi Briano, Nice find. But *Weather Will also run the program. Volhout PicomiteVGA PETSCII ROBOTS |
||||
| Briano Newbie Joined: 20/01/2026 Location: CanadaPosts: 27 |
Ah!... I didn't know that. But first I'll still need to change to the directory where the program is stored. |
||||
| homa Guru Joined: 05/11/2021 Location: GermanyPosts: 753 |
That's a good idea! Setting the working directory beforehand—though the program could handle that on its own... The advantage is that I can also automate the loading process, from anywhere in the directory. But I have two comments on this. A command like that overwrites a program in memory that hasn't been saved yet. And RUN “file” doesn't support the “,c” option So, in my opinion, a better approach would be (untested): Sub Weather CHDIR “/” SAVE “memorybackup.bas” LOAD “Weather”, R 'add ,C here if necessary End Sub Matthias |
||||
| Briano Newbie Joined: 20/01/2026 Location: CanadaPosts: 27 |
Good idea. I didn't think of that because I always edit programs from the SD card them save them before running. I never edit whatever is in memory cause I keep forgetting to save to disk. Something I'd like to see is a PATH= option for PicoMite. When running a program, have it look for the file in the current directory. If not found, check each directory in the PATH statement until a match is found. ....Brian |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 9328 |
On the Pico the memory that holds your current program is effectively flash slot zero. When you switch off your program is actually already saved in flash and when you boot up again it reappears, ready for editing, automatically. There is no need to save to disk unless you are just wanting to play extra safe in case your Pico dies. The CMM2 works differently and needs a SD card present to edit your file. Mick Zilog Inside! nascom.info for Nascom & Gemini |
||||
| PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 2149 |
Library is super You really can extend/customize the language. As an experiment, I put all my code in a library which called "Main()". In the editor, all the programmer sees is: Sub Main() End Sub |
||||
| homa Guru Joined: 05/11/2021 Location: GermanyPosts: 753 |
Mick, That's exactly why it's so critical. You've loaded a program, made a few important changes using "edit," or jotted down "the idea" in a few lines. Then you press F2 to exit the editor and run the program. Wonderful-it works. Oh, what's the weather going to be like? I still want to...? You quickly type "WEATHER," and everything's gone! I'm speaking from experience, which is why I made that comment. Matthias |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 9328 |
Yes, but that's using programs in the library, which AFAIK hasn't been done much until recently as the library wasn't originally designed to be used in that way. :) Go off the rails and you have to accept risks, I suppose. lol Mick Zilog Inside! nascom.info for Nascom & Gemini |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |