Menu
JAQForum Ver 26.09

Forum Index : Microcontroller and PC projects : Easily run favourite programs

Posted: 10:43pm
27 Oct 2026
Copy link to clipboard
Briano
Newbie

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
 
Posted: 12:10am
28 Oct 2026
Copy link to clipboard
phil99
Guru


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.
 
Posted: 03:29am
28 Oct 2026
Copy link to clipboard
Geoffg
Guru


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
 
Posted: 07:22am
28 Oct 2026
Copy link to clipboard
Volhout
Guru


Hi Briano,

Nice find. But
*Weather

Will also run the program.

Volhout
 
Posted: 08:08pm
28 Oct 2026
Copy link to clipboard
Briano
Newbie

  Volhout said  Hi Briano,

Nice find. But
*Weather

Will also run the program.

Volhout

Ah!... I didn't know that. But first I'll still need to change to the directory where the program is stored.
 
Posted: 09:07pm
28 Oct 2026
Copy link to clipboard
homa
Guru


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
  Quote  - LOAD fname$ [, C] [, R]
Load a BASIC program. The optional suffix “,R” causes the program to run after it has been loaded
(in this case, fname$ must be a string constant). The optional suffix “,C” compresses the program (removing
comments, blank lines, and unnecessary spaces) as it is loaded.
- RUN fname$
Load a BASIC program and run it. fname$ can be a variable.

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
 
Posted: 02:37am
29 Oct 2026
Copy link to clipboard
Briano
Newbie

  homa said  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


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
 
Posted: 07:38am
29 Oct 2026
Copy link to clipboard
Mixtel90
Guru


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.
 
Posted: 07:38am
29 Oct 2026
Copy link to clipboard
PhenixRising
Guru

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
 
Posted: 08:02am
29 Oct 2026
Copy link to clipboard
homa
Guru


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
 


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026