fablug Posted March 26, 2023 Share Posted March 26, 2023 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. 1 Quote Link to comment Share on other sites More sharing options...
+mizapf Posted March 26, 2023 Share Posted March 26, 2023 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. 4 Quote Link to comment Share on other sites More sharing options...
fablug Posted March 26, 2023 Author Share Posted March 26, 2023 (edited) 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 March 26, 2023 by fablug 1 Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted March 26, 2023 Share Posted March 26, 2023 For what it's worth, you can do that directly from XB 2.9 G.E.M. with CALL RUN(A$) 3 1 Quote Link to comment Share on other sites More sharing options...
fablug Posted March 26, 2023 Author Share Posted March 26, 2023 20 minutes ago, senior_falcon said: For what it's worth, you can do that directly from XB 2.9 G.E.M. with CALL RUN(A$) Thank you very much @senior_falcon I didn't remember XB 2.9 G.E.M. had this feature. Very good 👌 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted March 26, 2023 Share Posted March 26, 2023 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. 2 2 Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted March 27, 2023 Share Posted March 27, 2023 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... Quote Link to comment Share on other sites More sharing options...
apersson850 Posted March 27, 2023 Share Posted March 27, 2023 It doesn't have to be the last line. That's just to make it easy to find. 2 Quote Link to comment Share on other sites More sharing options...
RXB Posted March 27, 2023 Share Posted March 27, 2023 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. 4 Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted April 5, 2023 Share Posted April 5, 2023 (edited) 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 April 5, 2023 by senior_falcon 4 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.