hexagon logo

External Subroutine question

Hello all,

I will explain what I want to do before asking the question / your help.

I have programs that need to call a subroutine that will have a rev number. Example "Sub_Rev_A.prg"

I have a text file that those programs read and extract the final letter of the name and assign it in a variable with the readline command. So if I have a second sub named "Sub_Rev_B.prg" and the txt file writes B, the B sub will be read instead.

Now the issue I am having is... Those programs will be read only in a read only folder. I noticed that when I start those programs, they search for the sub they had executed in the first run while NOT in read only mode and after that while executing they search for the real version to execute (and execute it correctly).

In the example I gave be4, Main Program is tested with REV A sub, saved and set to read only. It works with Rev A for some time perfectly. Later on, we revise the sub to rev B, change the Txt to B. The program starts, gives an error message that the sub A is not found (we remove the old revisions), procedes to execution, reads the txt, executes sub B. From that point if I reexecute the Main program without closing it runs without error. If I close and reopen it I am getting the same error for Rev A.

No impact on the result of the measurement but each time I am getting an annoying message that I would love to eliminate if possible. Please know that in reality I am talking about hundreds of programs and subs and it is not possible to remove readonly mode each time we revise a sub without performing validation documents etc,

any help is much appreciated! |

PC-Dmis 2017 R2
Parents
  • Can't you just have a dummy routine which doesn't actually do anything as the initial routine?


    ASSIGN/HEADERSUBFILE="C:\TEMP\DUMMY.PRG

    Then rather than just have A or B in the text file, have the full path of the subroutine in there.


    It's never going to get executed, it just has to exist!


    The warnings can't be switched off btw.



    I disagree!


    Sadly it does not work:




    I created a dummy routine APS-PDEA-501106682.prg having a Header sub in it. I assigned the path variable to it. I search for the rev and change the path to include the rev and use the path variable in my callsub command. I am getting an error.

    The path of the subroutine is hardcoded in the program on last execution, otherwise is 0 like in this example. The second time I am running this program is ok, I have no error. If I change the rev in the txt file and delete the subroutine with the rev number but maintain the dummi routine without the rev number, I will get the error. Try it yourself with the code I provided please.
  • The issue with what you've done there is that the second instance of your Assignment PATH is using SUBREV - which initially holds no value (or 0).

    Change it so the text file contains the full path or the subroutine and not just the REV.

    Change the file READLINE to =FILE/READLINE,FPTR,{MYPATH}

    Delete the ASSIGNG/PATH line just before the CALLSUB

    Change the last line to =CALLSUB/HEADER,MYPATH:,
Reply
  • The issue with what you've done there is that the second instance of your Assignment PATH is using SUBREV - which initially holds no value (or 0).

    Change it so the text file contains the full path or the subroutine and not just the REV.

    Change the file READLINE to =FILE/READLINE,FPTR,{MYPATH}

    Delete the ASSIGNG/PATH line just before the CALLSUB

    Change the last line to =CALLSUB/HEADER,MYPATH:,
Children
No Data