Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 00:20 12 Nov 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

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

Author Message
Briano
Newbie

Joined: 20/01/2026
Location: Canada
Posts: 27
Posted: 10:43pm 27 Oct 2026
Copy link to clipboard 
Print this post

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: Australia
Posts: 3429
Posted: 12:10am 28 Oct 2026
Copy link to clipboard 
Print this post

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: Australia
Posts: 3372
Posted: 03:29am 28 Oct 2026
Copy link to clipboard 
Print this post

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: Netherlands
Posts: 6252
Posted: 07:22am 28 Oct 2026
Copy link to clipboard 
Print this post

Hi Briano,

Nice find. But
*Weather

Will also run the program.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Briano
Newbie

Joined: 20/01/2026
Location: Canada
Posts: 27
Posted: 08:08pm 28 Oct 2026
Copy link to clipboard 
Print this post

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

Guru

Joined: 05/11/2021
Location: Germany
Posts: 753
Posted: 09:07pm 28 Oct 2026
Copy link to clipboard 
Print this post

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
 
Briano
Newbie

Joined: 20/01/2026
Location: Canada
Posts: 27
Posted: 02:37am 29 Oct 2026
Copy link to clipboard 
Print this post

  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
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 9328
Posted: 07:38am 29 Oct 2026
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2149
Posted: 07:38am 29 Oct 2026
Copy link to clipboard 
Print this post

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: Germany
Posts: 753
Posted: 08:02am 29 Oct 2026
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 9328
Posted: 10:28am 29 Oct 2026
Copy link to clipboard 
Print this post

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
 
Print this page


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