• Name of a program

    From Bob Latham@3:633/10 to All on Thursday, April 16, 2026 17:34:20
    How can I get the name of program I'm running from within the program?

    Thanks.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Thursday, April 16, 2026 18:17:48
    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.

    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Thursday, April 16, 2026 19:18:29
    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.

    Thanks.

    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Thursday, April 16, 2026 22:29:04
    In article <5cca8d05ebbob@sick-of-spam.invalid>,
    Bob Latham <bob@sick-of-spam.invalid> 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.

    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.

    How are you running the program?

    It sounds as if you are using the BASIC command to open an interactive
    editor, then running the program within that using LOAD/RUN. The only
    RISC OS command used to start it was BASIC.

    I want the name of Basic assembler file.

    If you simply double-click on the BASIC file name in a Filer display,
    then what does OS_GetEnv return?

    Alternatively, run the assembler code and save the output.
    Double-click that aand GetEnv will show the saved file name.

    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Harriet Bazley@3:633/10 to All on Friday, April 17, 2026 10:45:48
    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.


    --
    Harriet Bazley == Loyaulte me lie ==

    The nice thing about standards is that there are so many to choose from

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Theo@3:633/10 to All on Friday, April 17, 2026 11:43:19
    Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
    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.

    This sounds a bit like:

    REM >Filename
    file$ = FNgetmyfilename()
    [
    .myfunction_file
    EQUS file$:EQUB 0:ALIGN
    .myfunction_name
    EQUS "myfunction":EQUB 0:ALIGN
    .myfunction
    <stuff>
    ADR r0, myfunction_file
    SWI "OS_Write0"
    SWI &100+ASC":" ; print a colon
    ADR r0, myfunction_name
    SWI "OS_Write0"
    <stuff>
    MOV pc,r14
    ]


    Except I don't think the <get my filename> function exists for BASIC,
    because BASIC doesn't have a concept of executing a file. You might have LOADed it into memory, but the name of the file given to LOAD isn't recorded anywhere. The command line from OS_GetEnv just tells you the *Command that
    was run, which isn't quite the same.

    What you could do is start at PAGE and then walk the tokenised code until
    you spot a REM > statement, which is sort-of a convention for how to label BASIC files with their filenames. This wouldn't work if the file is part of
    a LIBRARY, which is something you often do when assembling from multiple
    source files. It is also fairly nasty (eg would break if BASIC changed
    its tokenisation, or if somebody renamed the file but failed to edit the comment).

    In C, it's easier because you have a macro __FILE__ which can be used to
    embed the name of the source file into any string. There are also 'debug symbols' which can be enabled to annotate functions with their names to aid
    in debugging. BASIC doesn't have this (although if you were generating an
    AIF binary in BASIC assembly you could hand-generate the debug symbols if
    you wanted).

    Theo

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Friday, April 17, 2026 12:08:53
    In article <01ece1ca5c.harriet@bazleyfamily.co.uk>,
    Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:


    Do you mean 'embed' the name of the source file in assembly code?

    Essentially yes.

    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.

    There is I do know, a start string which can be intercepted through
    vector 5 and that does contain the full path to the file name. I
    already harvest that to get my system variable Basic$Dir useful for
    saving data or code in the same directory.

    Getting the file name seems a bit harder but not sure why yet.

    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.

    All the above is fab except the word "manually*.

    Cheers,

    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Friday, April 17, 2026 12:59:56
    In article <F4l*XoiEA@news.chiark.greenend.org.uk>,
    Theo <theom+news@chiark.greenend.org.uk> wrote:

    or if somebody renamed the file but failed to edit the comment).

    Which I know I would do - endlessly.

    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.

    Unfortunately I do a lot of work in Basic because when something goes
    wrong you get more info like a line number and you can do tests, just
    running the code is okay if it all works.

    I'm concluding this can't be done.

    Thanks everyone for trying to help me.

    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Harriet Bazley@3:633/10 to All on Friday, April 17, 2026 14:12:29
    On 17 Apr 2026 as I do recall,
    Bob Latham wrote:

    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.

    Well, again the BASIC in memory doesn't necessarily know whether it was
    pulled in via a LIBRARY statement or is actually located in the last
    file double-clicked -- or was typed in 'live' via the command-line in a taskwindow or otherwise. So BASIC as a language may simply not have
    the concept of 'this is the parent file of the tokenised program being executed". :-(


    --
    Harriet Bazley == Loyaulte me lie ==

    If your feet smell and your nose runs - you're built upside down.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tank@3:633/10 to All on Friday, April 17, 2026 15:09:09
    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:

    I don't think it's inherently in the assembled machine code,

    For assembler, add this macro to your header file:
    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

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Friday, April 17, 2026 16:52:38
    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, before
    double-clicking the program you are wanting to find the name of?
    Beware that adds an overhead on EVERY command that is issued until the OS_Release,5. And there can be many hundreds of them!

    But, if you drop into Basic and then load the basic program then
    no-go.

    That is to be expected...

    Double-clicking a any file (BASIC, Absolute, Utility, Command, Jpeg,
    etc) will result in an command:
    Run <pathname><filename>
    This issues another command depending on the hex file type. For a
    BASIC program this is:
    @RunType_FFB <pathname><filename>
    The Alias$@RunType_FFB for a BASIC program then issues command
    Basic -quit "<pathname><filename>"

    All these three are OS commands, and will pass through the OS_CLI
    vector 5, and will be seen by anything intercepting that vector at
    that time.

    However, when in interactive BASIC, a
    LOAD filename
    is a BASIC command, and NOT an OS command, so it is not seen by the
    OS_CLI vector. The last OS command issued is just BASIC.
    Issuing a *command or OSCLI("command") would be an OS command.

    Note that all the OS commands issued can be seen easily if my Reporter
    is running - see www.avisoft.f9.co.uk

    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.

    Therefore...
    If you have double-clicked a BASIC program <filename> it will show
    Basic -quit <pathname><filename>
    If in interactive BASIC it will still just show BASIC after a LOAD.

    No Claim for OSCLI vector 5 is required.

    Does that help?

    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Harriet Bazley@3:633/10 to All on Friday, April 17, 2026 19:35:45
    On 17 Apr 2026 as I do recall,
    Tank wrote:

    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:

    I don't think it's inherently in the assembled machine code,

    For assembler, add this macro to your header file:

    I think he's using the BASIC assembler.


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

    But as I read it, that's basically what I was suggesting with EQUS in
    BASIC; his problem is that he wants to be able to change the *filename*
    without needing to remember to update a hardwired text label.


    --
    Harriet Bazley == Loyaulte me lie ==

    The attacker must vanquish; the defender need only survive.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Friday, April 17, 2026 20:15:49
    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:
    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,

    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.

    [Snip]

    I'm concluding this can't be done.

    The module method I have can also get the filename if you run the
    basic program with a double click etc.

    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.

    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.

    Yes, your idea is better from an overheads point of view but I don't
    think it will fix my issue.

    Does that help?

    Better than my module - probably. Does what I want - I don't think so.

    Thanks for trying to help me.

    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Friday, April 17, 2026 20:17:53
    In article <1408faca5c.tank@tankstage.co.uk>,
    Tank <webmaster@tankstage.co.uk> wrote:
    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:

    I don't think it's inherently in the assembled machine code,

    For assembler, add this macro to your header file:
    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

    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.

    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Friday, April 17, 2026 23:24:36
    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:

    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.

    That explains that.

    [Snip]

    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.

    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!

    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.

    Correct. The OS command processor has not seen it.

    Martin

    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Friday, April 17, 2026 23:30:29
    In article <5ccb164bf2bob@sick-of-spam.invalid>,
    Bob Latham <bob@sick-of-spam.invalid> wrote:
    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.

    It is not the BASIC Assembler. There is an equivalent BASIC Function,
    but I think that is overkill for what you want.

    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Saturday, April 18, 2026 10:08:59
    In article <5ccb276441News04@avisoft.f9.co.uk>,
    Martin <News04@avisoft.f9.co.uk> wrote:
    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:

    [Snip]

    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?

    Mostly.

    How do you display register values from the assembler?

    For the most part I don't. I do store a register in a particular
    temporary address sometimes. A list of important variables and their
    values are squirted to a file when the assembler has finished. I also
    tend to use conditional swi 256+7 to find out where code is getting
    to.

    How do you display blocks of storage?

    !SpyGlass or !StrongED.

    I'm sure I know what you're going to say. I should be using Reporter.

    I don't want to come across as a moaner but my honest problem is I'm
    not the sharpest knife in the box and many, many things seem to be
    beyond my understanding. An example is Rool Development suite, got
    it, can't get anywhere with it.

    Likewise Reporter, way beyond me. Unfortunately, I'm limited in what
    I can learn and understand not helped by my dislike of reading which
    I find hard work.

    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?

    It may well do. I wrote it decades ago and it's in Basic.

    So can it set a variable name or something with the program name?

    It would seem likely I agree, I'll have a look...

    I am still unsure what you need the program name for, and how you
    want to use it!

    Okay.

    My source files follow this pattern...

    major changes and consolidated code..
    SF14, SF15, SF16, SF17,
    Then small changes and testing...
    SF18_d02_01, SF18_d02_02, SF18_d04_01
    When these changes do what I want it will become SF18.

    Sometimes I get confused, I've got 3 or 4 Assembled !RunImages and I
    notice a fault I'd not spotted earlier. I find some RunImages don't
    have the issue but I've only got the date stamp to identify the
    source file that last produced code without a fault.

    If I could look at a fixed location in my code and it contained the
    name of the source file......

    Cheers,

    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Theo@3:633/10 to All on Saturday, April 18, 2026 10:56:21
    Bob Latham <bob@sick-of-spam.invalid> wrote:

    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)

    I'm not sure how your 'hit F12' save works, but perhaps you could
    *Key 12 SAVE "<MyLoader$Filename>"

    Theo

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Saturday, April 18, 2026 11:13:39
    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.
    Use OS_GetEnv to get the command and parse out the filename.

    That is a brilliant idea!

    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 Basic$Prog was set to the required name, then adding a simple FNid
    would add the name value to the code:

    1 DIM code% 100
    2 P% = code%
    3 [
    4 ; some other bits of your code
    5 FNid ; Insert program name
    6 ALIGN ; to next word boundary
    7 ; some other bits of your code
    8 ]
    9 END
    10
    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

    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steve Fryatt@3:633/10 to All on Saturday, April 18, 2026 11:39:26
    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$



    --
    Steve Fryatt - Leeds, England

    http://www.stevefryatt.org.uk/

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Saturday, April 18, 2026 13:50:38
    In article <5ccb684e90News04@avisoft.f9.co.uk>,
    Martin <News04@avisoft.f9.co.uk> wrote:
    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.

    Actually, it already does that.

    2. Have your desktop program set a system variable

    Yes, I added my code for that this morning.

    It now sets both Basic$Dir and now Basic$File.

    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

    That's helpful thanks.

    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Saturday, April 18, 2026 13:55:53
    In article <mpro.tdoqxk00q5yfx0cd6.news@stevefryatt.org.uk>,
    Steve Fryatt <news@stevefryatt.org.uk> wrote:
    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$



    Thanks Steve, I'll look into that and give it a try.


    Cheers,

    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Saturday, April 18, 2026 15:29:43
    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.


    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Saturday, April 18, 2026 16:30:31
    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 Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Theo@3:633/10 to All on Saturday, April 18, 2026 17:54:47
    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...

    Theo

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Saturday, April 18, 2026 18:06:20
    In article <F4l*v3oEA@news.chiark.greenend.org.uk>,
    Theo <theom+news@chiark.greenend.org.uk> wrote:
    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...

    Nope. I originally posted a working, tested program!
    Though I do realise that it used DIM LOCAL, which requires a BASIC
    later than the Select ones.

    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Saturday, April 18, 2026 18:51:31
    In article <5ccb8e16fdNews04@avisoft.f9.co.uk>,
    Martin <News04@avisoft.f9.co.uk> wrote:
    Though I do realise that it used DIM LOCAL, which requires a BASIC
    later than the Select ones.

    Gah! No it does not. That was an earlier version! DIM not now used.

    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bob Latham@3:633/10 to All on Saturday, April 18, 2026 19:08:13
    In article <5ccb85512cNews04@avisoft.f9.co.uk>,
    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 ?

    Yes I did at the end of the source file after END

    I then noticed that L% was already in use so I've changed your
    supplement code to V%. I also added O%.

    That stopped the errors and space was created in the machine code but
    the text was wrong. Penny dropped. Insertion needed at O% not P%.

    DEF FNid
    SYS "XOS_ReadVarVal","Basic$File",O%,255,0,3 TO ,,V%
    P% += V% : O% += V%
    =0

    Looks good at the moment, need to test it more.

    Thanks.

    Bob.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Martin@3:633/10 to All on Saturday, April 18, 2026 19:36:26
    In article <5ccb93c129bob@sick-of-spam.invalid>,
    Bob Latham <bob@sick-of-spam.invalid> wrote:
    I then noticed that L% was already in use so I've changed your
    supplement code to V%.

    There should have been a LOCAL L% in the DEF FN. Sorry about that.

    I also added O%.

    I did wonder if you had used that.

    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)