PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Cedric on July 11, 2024, 10:39:41 AM

Title: check if sub program and entry line exist
Post by: Cedric on July 11, 2024, 10:39:41 AM
Good morning everyone,

I`m curious to know... Is there a way to just check if a subprogram and entry line exist, but not execute or load that program.

Just to explain my context, I want to check if the subprogram and entry line exist.  If it does, execute something and then call that subprogram and entry line.

I'm working on improving our grid loading routine to load faster though proplist and propvalue.  But in some case, I want to make sure the grid is loaded before exexuting a specific subroutine, but only if that subroutine exists since that subroutine may try to alter the grid.  That subroutine is in another program.

I could've use the LNO function, but it only works with the current loaded program.
Title: Re: check if sub program and entry line exist
Post by: John Spencer on August 17, 2024, 11:35:01 AM
Hello Cedric:
This works for me - I hope this helps.

begin
let prog$="fillit.pvx",look$="DO_THE_FILL:",flag$=""
call "look4lbl.pvx",prog$,look$,flag$
print "Found: ",flag$

!look4lbl.pvx
enter prog$,label$,found$
!look for a label in another program
found$=""
call "*pg.cnv",err=exit,prog$,work$
let work=hfn; open (work)work$
next_rec:
read (work,end=THE_END)dat$
if pos(label$=dat$) then let found$="y"; goto THE_END
goto next_rec
THE_END:
close (work)
erase work$
!print "Found: ",found$
exit: exit
Title: Re: check if sub program and entry line exist
Post by: Matthew J. C. Clarke on August 17, 2024, 08:57:24 PM
Here's a code fragment showing the technique we use to check if a line label exists in another program. Earlier code (not shown) checks that the file named in _program$ exists and is a ProvideX/PxPlus program file.


->\`2100,2160
2100       if _label$>""
:           then call pgn+";aim_llcheck_label",_program$,_label$,_lno;
:                if _lno=0
:                 then let aim_syobjresult=3,aim_syobjreturn$="no line label "+_label$+" in program "+_program$
2110 AIM_LLCHECK_PGM_DONE:
2120       return
2130 AIM_LLCHECK_LABEL:
2140       enter (_program$),(_label$),_lno,err=*end
2150       let _lno=0
2160       execute "load "+quo+_program$+quo+"; _lno = lno("+_label$+"); exit",err=*end
->


Matt.