How can I get the name of program I'm running from within the
program?
In article <5cca837cdbbob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
How can I get the name of program I'm running from within the
program?
I would have thought that a program would know what it is called?!
So not sure what you are wanting.
You can get the command used to start the program, if that is any
help, by using SWI OS_GetEnv. The name of the program file run will
be in that command, but the command will need parsing to get it.
OS_Args could be used to help that, or do it 'manually' in the
program.
In article <5cca87776fNews04@avisoft.f9.co.uk>,
Martin <News04@avisoft.f9.co.uk> wrote:
In article <5cca837cdbbob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
How can I get the name of program I'm running from within the
program?
I would have thought that a program would know what it is called?!
So not sure what you are wanting.
I want to hide the name of the source file in assemble code. I
would like to be able to look at my code and be able to find out
which source file it came from.
You can get the command used to start the program, if that is any
help, by using SWI OS_GetEnv. The name of the program file run
will be in that command, but the command will need parsing to get
it. OS_Args could be used to help that, or do it 'manually' in
the program.
I'm obviously missing something because I've looked at this before
and had no joy.
If in a Basic assembler file I run SWI OS_GetEnv it just says
BASIC, which I suppose that is what it is running but it's of no
use to me.
I want the name of Basic assembler file.
In article <5cca87776fNews04@avisoft.f9.co.uk>,
Martin <News04@avisoft.f9.co.uk> wrote:
In article <5cca837cdbbob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
How can I get the name of program I'm running from within the
program?
I would have thought that a program would know what it is called?!
So not sure what you are wanting.
I want to hide the name of the source file in assemble code. I would
like to be able to look at my code and be able to find out which
source file it came from.
On 16 Apr 2026 as I do recall,
Bob Latham wrote:
In article <5cca87776fNews04@avisoft.f9.co.uk>,
Martin <News04@avisoft.f9.co.uk> wrote:
In article <5cca837cdbbob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
How can I get the name of program I'm running from within the
program?
I would have thought that a program would know what it is called?!
So not sure what you are wanting.
I want to hide the name of the source file in assemble code. I would
like to be able to look at my code and be able to find out which
source file it came from.
Do you mean 'embed' the name of the source file in assembly code? I
don't think it's inherently in the assembled machine code, which doesn't
know whether it was assembled on the fly by running a parent BASIC file
or loaded from disc and executed by calling the address of the area it
was stored into, i.e. there is nothing to hide.
Or is this for the purposes of error trapping?
Probably the best way to label your machine code is simply to manually
embed a string near the top of it (like the string that is the name of a relocatable module) with EQUS, so that you can visually inspect it - or
check for its presence at a known offset from the start of the code.
Do you mean 'embed' the name of the source file in assembly code?
I don't think it's inherently in the assembled machine code,
which doesn't know whether it was assembled on the fly by running a
parent BASIC file or loaded from disc and executed by calling the
address of the area it was stored into, i.e. there is nothing to
hide.
Or is this for the purposes of error trapping?
Probably the best way to label your machine code is simply to
manually embed a string near the top of it (like the string that is
the name of a relocatable module) with EQUS, so that you can
visually inspect it - or check for its presence at a known offset
from the start of the code.
or if somebody renamed the file but failed to edit the comment).
I don't think it's inherently in the assembled machine code,
I'm sure it isn't.
which doesn't know whether it was assembled on the fly by running a
parent BASIC file or loaded from disc and executed by calling the
address of the area it was stored into, i.e. there is nothing to
hide.
I accept that but I *imagined* that when you run a basic program the
OS would somewhere store the path to the running file.
On 17 Apr 2026 as I do recall,For assembler, add this macro to your header file:
Bob Latham wrote:
I don't think it's inherently in the assembled machine code,
The nearest I've got is to intercept vector 5 and if you double
click a Basic file it will set the variable and you're good to go.
But, if you drop into Basic and then load the basic program then
no-go.
I'm concluding this can't be done.
In message <21d8f4ca5c.harriet@bazleyfamily.co.uk>
Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
On 17 Apr 2026 as I do recall,
Bob Latham wrote:
For assembler, add this macro to your header file:I don't think it's inherently in the assembled machine code,
MACRO
$label SIGNATURE
ALIGN 4
= "$label",0
ALIGN 4
DCD &FF000000+(:LEN:"$label"+4):AND::NOT:3
$label
MEND
and then call it with:
Routine_Name SIGNATURE
code....
it will add the routine name into the compiled code..
In article <5ccaee3398bob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
The nearest I've got is to intercept vector 5 and if you double
click a Basic file it will set the variable and you're good to go.
Have you have done an OS_Claim,5 in another program,
I'm concluding this can't be done.
Yes it can, if what you want is the filename of the running program...
If the program that is actually running issues an OS_GetEnv SWI you
get returned the address of the OS command which started that
program. It will include the full <pathname><filename>, and is
exactly the same as passed to OS_CLI and passes through the vector.
Does that help?
In message <21d8f4ca5c.harriet@bazleyfamily.co.uk>
Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
On 17 Apr 2026 as I do recall,
Bob Latham wrote:
For assembler, add this macro to your header file:I don't think it's inherently in the assembled machine code,
MACRO
$label SIGNATURE
ALIGN 4
= "$label",0
ALIGN 4
DCD &FF000000+(:LEN:"$label"+4):AND::NOT:3
$label
MEND
and then call it with:
Routine_Name SIGNATURE
code....
it will add the routine name into the compiled code..
webmaster@tankstage.co.uk Titanium
In article <5ccb038169News04@avisoft.f9.co.uk>,
Martin <News04@avisoft.f9.co.uk> wrote:
In article <5ccaee3398bob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
Have you have done an OS_Claim,5 in another program,Yes, I have had a module running for at least 20 years to which sets
the variable Basic$Dir which I use a great deal.
If the program that is actually running issues an OS_GetEnv SWI
you get returned the address of the OS command which started that
program. It will include the full <pathname><filename>, and is
exactly the same as passed to OS_CLI and passes through the
vector.
Yes, but my new found knowledge makes me doubt it can do what I want
it to do.
I write my assembler programs in BBC basic inside StrongED. I save
the file. I don't usually run the program by double clicking because
if it goes wrong there is nothing you can do to investigate why. My
new code usually goes wrong several time and has to be debugged
before it runs properly.
So I have another program of mine which sits on the icon bar and I
drop the Basic prog on to that. This opens the Basic environment and
loads my new code into it. I now work old style in Basic to get the
bugs out. at some point i hit F12 which saves the resultant machine
code.
So as my Basic assemble code has not been 'run' from the filer but
within Basic the path will not have been set and indeed that's what
I'm seeing.
In article <1408faca5c.tank@tankstage.co.uk>,...
Tank <webmaster@tankstage.co.uk> wrote:
For assembler, add this macro to your header file:
MACRO
MEND
Thanks Tank but you're in another galaxy to me, I'd need a two week
lecture to understand the above as i don't think it's the Basic
assembler.
In article <5ccb161bb5bob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
In article <5ccb038169News04@avisoft.f9.co.uk>,
Martin <News04@avisoft.f9.co.uk> wrote:
In article <5ccaee3398bob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
That applies to code I write as well ... and some using BASIC, and
some BASIC Assembler. And there are things you can do to
investigate what has gone wrong. If you want some help with this,
please email me directly.
Is your debugging simply using the facilities of the BASIC
Interpreter to display variable values?
How do you display register values from the assembler?
How do you display blocks of storage?
So I have another program of mine which sits on the icon bar and
I drop the Basic prog on to that. This opens the Basic
environment and loads my new code into it. I now work old style
in Basic to get the bugs out. at some point i hit F12 which saves
the resultant machine code.
So this other program knows the full file name of what it is about
to load into BASIC?
So can it set a variable name or something with the program name?
I am still unsure what you need the program name for, and how you
want to use it!
Yes, but my new found knowledge makes me doubt it can do what I want
it to do.
I write my assembler programs in BBC basic inside StrongED. I save
the file. I don't usually run the program by double clicking because
if it goes wrong there is nothing you can do to investigate why. My
new code usually goes wrong several time and has to be debugged
before it runs properly.
So I have another program of mine which sits on the icon bar and I
drop the Basic prog on to that. This opens the Basic environment and
loads my new code into it. I now work old style in Basic to get the
bugs out. at some point i hit F12 which saves the resultant machine
code.
I then quit Basic and return to the desktop.
So as my Basic assemble code has not been 'run' from the filer but
within Basic the path will not have been set and indeed that's what
I'm seeing.
I can think of a couple of routes to doing what you want:
1. Have your desktop program run the command of
'*Basic -load $.MyProg'
Then it starts Basic with the file loaded but not run.
Use OS_GetEnv to get the command and parse out the filename.
2. Have your desktop program set a system variable
MyLoader$Filename to be the name of the Basic prog, then SAVE "<MyLoader$Filename>" (or read the sysvar to a Basic string first)
If in a Basic assembler file I run SWI OS_GetEnv it just says BASIC, which
I suppose that is what it is running but it's of no use to me.
I want the name of Basic assembler file.
In article <D4l*rvnEA@news.chiark.greenend.org.uk>,
Theo <theom+news@chiark.greenend.org.uk> wrote:
I can think of a couple of routes to doing what you want:
1. Have your desktop program run the command of
'*Basic -load $.MyProg'
Then it starts Basic with the file loaded but not run.
2. Have your desktop program set a system variable
11 DEF FNid :REM insert program name at P%
12 SYS "XOS_ReadVarVal","Basic$Prog",P%,255,0,3 TO ,,L%
13 P% += L% :REM move ptr after name
14 = 0
On 16 Apr, Bob Latham wrote in message
<5cca8d05ebbob@sick-of-spam.invalid>:
If in a Basic assembler file I run SWI OS_GetEnv it just says BASIC, which I suppose that is what it is running but it's of no use to me.
I want the name of Basic assembler file.
Isn't it on the tail of the command; something like
BASIC -quit ADFS::0.$.The.Path.To.My.Program
This is how RISC OS runs BASIC programs that you double-click on,
or call via *Filer_Run, or whatever.
From this, you can get the path into a path$ variable as follows:
buffer_size% = 1024 DIM buffer% buffer_size%
REM Read the command line used to call the program.
SYS "OS_GetEnv" TO environment% SYS "OS_ReadArgs",
",load=quit/K", environment%, buffer%, buffer_size%
SYS "XOS_GenerateError", buffer%!0 TO basic$ SYS
"XOS_GenerateError", buffer%!4 TO path$
REM We're assuming that we're being run by a double-click, and so
the REM command line will start "BASIC -quit ...". If not, we
don't go REM any further.
IF basic$ <> "BASIC" OR path$ = "" THEN END
PRINT "My file is ";path$
4 ; some other bits of your code
5 FNid ; Insert program name
6 ALIGN ; to next word boundary
In article <5ccb684e90News04@avisoft.f9.co.uk>,
Martin <News04@avisoft.f9.co.uk> wrote:
4 ; some other bits of your code
5 FNid ; Insert program name
6 ALIGN ; to next word boundary
Can't get past syntax error or no such mnemonic with this.
It doesn't like FNid at all.
In article <5ccb7fc02dbob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
In article <5ccb684e90News04@avisoft.f9.co.uk>,
Martin <News04@avisoft.f9.co.uk> wrote:
4 ; some other bits of your code
5 FNid ; Insert program name
6 ALIGN ; to next word boundary
Can't get past syntax error or no such mnemonic with this.
It doesn't like FNid at all.
Did you include the DEF FNid from lines 11-14 ?
Martin <News04@avisoft.f9.co.uk> wrote:
In article <5ccb7fc02dbob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
In article <5ccb684e90News04@avisoft.f9.co.uk>,
Martin <News04@avisoft.f9.co.uk> wrote:
4 ; some other bits of your code
5 FNid ; Insert program name
6 ALIGN ; to next word boundary
Can't get past syntax error or no such mnemonic with this.
It doesn't like FNid at all.
Did you include the DEF FNid from lines 11-14 ?
Do you not have to do 'OPT FNid' in the assembly? I'm somewhat
rusty...
Though I do realise that it used DIM LOCAL, which requires a BASIC
later than the Select ones.
In article <5ccb7fc02dbob@sick-of-spam.invalid>,
Bob Latham <bob@sick-of-spam.invalid> wrote:
In article <5ccb684e90News04@avisoft.f9.co.uk>,
Martin <News04@avisoft.f9.co.uk> wrote:
4 ; some other bits of your code
5 FNid ; Insert program name
6 ALIGN ; to next word boundary
Can't get past syntax error or no such mnemonic with this.
It doesn't like FNid at all.
Did you include the DEF FNid from lines 11-14 ?
I then noticed that L% was already in use so I've changed your
supplement code to V%.
I also added O%.
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 5 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 493843:34:29 |
| Calls: | 146 |
| Files: | 547 |
| D/L today: |
6 files (97K bytes) |
| Messages: | 76,650 |