PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Jeffrey Ferreira on June 01, 2020, 10:30:14 AM

Title: Getting Text of a Program Line Number
Post by: Jeffrey Ferreira on June 01, 2020, 10:30:14 AM
Hi List,

we always put description info on a certain line numbers in our programs...
The method i've been using to get that info has failed at times.
Can anyone provide with a way to get text at a certain line # in a program
thanks

jeff
Title: Re: Getting Text of a Program Line Number
Post by: Jeffrey Ferreira on June 01, 2020, 11:52:18 AM
Or is there a way to convert and entire pxplus program to a text file and then i can parse it?
Title: Re: Getting Text of a Program Line Number
Post by: RobL on June 01, 2020, 12:37:04 PM
Hi Jeffrey,

Take a look at the utility program "*pg.cnv". It can be used to convert a program file to a text file (and vice versa).

Regards,

Rob Leighton
Title: Re: Getting Text of a Program Line Number
Post by: Jeffrey Ferreira on June 01, 2020, 01:11:19 PM
Hi Rob, that worked great but then it failed at one account...it seems to come back still encrypted...
all i'm doing is the following

call "*pg.cnv","PROG1","s:\jeff\jeff.txt"

and at one account it comes back encrypted ..if you have any ideas that would be great...
I dont think it is pxplus version because i have it working on an old  version and a new version...
Title: Re: Getting Text of a Program Line Number
Post by: jasonc on June 01, 2020, 02:52:46 PM
Jeff,
I think you are saying that the the new program is created, but it is compiled PxPlus code rather than a text file.
If that is the case, you just need to make sure that there is an existing text file there before you call *pg.cnv.  If there isn't, it will create a PxPlus program.

You will need to add error trapping, but try this:

erase "s:\jeff\jeff.txt"
serial "s:\jeff\jeff.txt"
call "*pg.cnv","PROG1","s:\jeff\jeff.txt"
Title: Re: Getting Text of a Program Line Number
Post by: Jeffrey Ferreira on June 01, 2020, 02:55:33 PM
that was it.
thank you so much.
i'm getting 100% hits now
Title: Re: Getting Text of a Program Line Number
Post by: ksproul on June 02, 2020, 04:01:14 PM
Were you having trouble with lst(pgm(x,tcb(12))) where x is the line number?  This has always worked for me unless the program is password protected.
Title: Re: Getting Text of a Program Line Number
Post by: Jeffrey Ferreira on June 03, 2020, 07:46:28 AM
Hi Ken,

this does indeed work: lst(pgm(x,tcb(12)))

i should have clarified that I was trying to access the line # from another running program

so PR0G01 is running - it is a utility that searches Program Descriptions in other programs.
PROG01 reads thru a directory that contains: PR0G02, PROG03 etc
and i want to get say line 10 from PR0G02 AND PROG03....
that is what i was trying to accomplish

and so far that *pg.cnv is the best i have...
it converts program to text and i read thru until i encounter line #

thanks

jeff
Title: Re: Getting Text of a Program Line Number
Post by: jasonc on June 03, 2020, 10:18:22 AM
Jeff,
There may be a better way, but just save the program below and run it.  It should return the contents of line 10.
The called routine is simply a modified version of *pg.cnv, but serves your purpose of simply grabbing a specific line instead of converting the program.

0050 call pgn+";get_line","PROG1","",10,line$
0060 print line$
0090 end
0500 ! ^500
0510 GET_LINE:
0520 enter prog$,passwd$,line,line$,err=*next
0530 line$="",p$=pgn
0540 x$=lst(pgm(tcb(4)+1)); execute x$(5),err=*end
0550 load prog$; password passwd$; line$=lst(pgm(line)); load p$; goto GET_LINE_EXIT
0560 GET_LINE_EXIT:
0570 exit