Jump to content
IGNORED

RUN COMMAND where "program name" is a string in XB -- EG: RUN A$


fablug

Recommended Posts

Hello,
I need to have a RUN statement inside an XB program without knowing the name of the XB BASIC program in advance.
Since it's not possibile to RUN a program from a string as parameter is there anybody who knows a workaround to achieve it ?

Is there any L/M routine, someone wrote which can be used, for instance: CALL LINK("RUNPROG",A$) where A$="DSKx.PROGNAME"

Thank you.
 

  • Like 1
Link to comment
Share on other sites

This is an example taken from a loader from APESOFT where the RUN command is modified during runtime.

 

830 CALL INIT :: CALL PEEK(-31952,A,B) :: CALL PEEK(A*256+B-65534,A,B)
840 C=A*256+B-65534 :: A$=D$&PROG$ :: CALL LOAD(C,LEN(A$))
850 FOR I=1 TO LEN(A$) :: CALL LOAD(C+I,ASC(SEG$(A$,I,1))) :: NEXT I :: CALL LOAD(C+I,0)
860 RUN "DDDD.XXXXXXXXXX"

 

The drive name with ending period ("DSK1.") is passed in D$, the program name is in PROG$. I assume (without too much background knowledge) that the RUN command must be the last command in the program.

 

I'm not sure why they subtract FFFE (65534) to convert the 16 bit unsigned value to a signed value; it must be 65536. Maybe there is an implied +2 (advancing the pointer).

 

-31952 = >8330

 

The general idea is obviously to modify the string in the last BASIC line. In 840, the length of the pathname is written by CALL LOAD, then the characters of the pathname are writen byte after byte into the subsequent locations. Finally, a 0 is added. Since there is no searching for the line, my assumption is, as mentioned, that we have to put the RUN statement into the last line of the BASIC program.

  • Like 4
Link to comment
Share on other sites

20 minutes ago, mizapf said:

This is an example taken from a loader from APESOFT where the RUN command is modified during runtime.

 

830 CALL INIT :: CALL PEEK(-31952,A,B) :: CALL PEEK(A*256+B-65534,A,B)
840 C=A*256+B-65534 :: A$=D$&PROG$ :: CALL LOAD(C,LEN(A$))
850 FOR I=1 TO LEN(A$) :: CALL LOAD(C+I,ASC(SEG$(A$,I,1))) :: NEXT I :: CALL LOAD(C+I,0)
860 RUN "DDDD.XXXXXXXXXX"

 

The drive name with ending period ("DSK1.") is passed in D$, the program name is in PROG$. I assume (without too much background knowledge) that the RUN command must be the last command in the program.

Fantastic! Thank you very much @mizapf
It works! Probabily the program seeks the last line of the program and replaces the generic "DDDD.XXXXXXXXX" string.
Solved! 😊 thanks again

Edited by fablug
  • Like 1
Link to comment
Share on other sites

RXB has N$="DSK4.PROGRAM" :: CALL XB(N$)

The old subprogram name used to be CALL XBPGM(string) but I shortened it to just XB.

If you do not use a string, then CALL XB will just default back to XB start up looking for LOAD program.

 

Also is the option of number of files to set up before running the XB program like CALL XB("DSK4.PROGRAM',1)

would do a CALL FILES(1) :: NEW :: RUN "DSK4.PROGRAM" all built into a single command.

 

Oh you could also do a 0 for no files open first thus use all of the VDP memory for your XB program.

  • Like 2
  • Thanks 2
Link to comment
Share on other sites

21 hours ago, mizapf said:

The general idea is obviously to modify the string in the last BASIC line. In 840, the length of the pathname is written by CALL LOAD, then the characters of the pathname are writen byte after byte into the subsequent locations. Finally, a 0 is added. Since there is no searching for the line, my assumption is, as mentioned, that we have to put the RUN statement into the last line of the BASIC program.

This would preclude using SUBs then since they have to be at the end of a program as well...

Link to comment
Share on other sites

5 hours ago, Vorticon said:

This would preclude using SUBs then since they have to be at the end of a program as well...

XB GEM and RXB routines do not have this issue.

 

 

Also XB GEM and RXB is only one line not several lines to function.

  • Like 4
Link to comment
Share on other sites

  • 2 weeks later...
On 3/27/2023 at 7:58 AM, Vorticon said:

This would preclude using SUBs then since they have to be at the end of a program as well...

This should do the trick:


1 INPUT A$ :: CALL RUN(A$)
32764 SUB RUN(A$):: CALL PEEK(-31952,A,B):: CALL PEEK(A*256+B-65530,A,B):: C=A*256+B-65534 :: CALL LOAD(C,LEN(A$))
32765 FOR I=1 TO LEN(A$):: CALL LOAD(C+I,ASC(SEG$(A$,I,1))):: NEXT I :: CALL LOAD(C+I,0)
32766 RUN "DDDD.XXXXXXXXXX"
32767 SUBEND

 

>8330 is the pointer to the start of the line number table, which is actually the last line in the XB program. I have just adjusted the program to find the second to last line, which leaves room for the SUBEND.

This should be the last SUB in the program.

You can enter DSSS.TEST and of course XB issues an error. Then if you look at line 32766 you will see RUN "DSSS.TEST"

The user SUBs have priority, so if you do this with XB 2.9 G.E.M. it will do the XB CALL RUN listed above and not the CALL RUN built into the cartridge.

Edited by senior_falcon
  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...