PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Getting Text of a Program Line Number  (Read 393 times)

Jeffrey Ferreira

  • Gold Member
  • ****
  • Posts: 82
    • View Profile
Getting Text of a Program Line Number
« 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

Jeffrey Ferreira

  • Gold Member
  • ****
  • Posts: 82
    • View Profile
Re: Getting Text of a Program Line Number
« Reply #1 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?

RobL

  • Member
  • **
  • Posts: 10
    • View Profile
Re: Getting Text of a Program Line Number
« Reply #2 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

Jeffrey Ferreira

  • Gold Member
  • ****
  • Posts: 82
    • View Profile
Re: Getting Text of a Program Line Number
« Reply #3 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...

jasonc

  • Member
  • **
  • Posts: 10
    • View Profile
Re: Getting Text of a Program Line Number
« Reply #4 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"

Jeffrey Ferreira

  • Gold Member
  • ****
  • Posts: 82
    • View Profile
Re: Getting Text of a Program Line Number
« Reply #5 on: June 01, 2020, 02:55:33 PM »
that was it.
thank you so much.
i'm getting 100% hits now

ksproul

  • Silver Member
  • ***
  • Posts: 27
    • View Profile
Re: Getting Text of a Program Line Number
« Reply #6 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.
Ken Sproul
DPI Information Services, Inc.

Jeffrey Ferreira

  • Gold Member
  • ****
  • Posts: 82
    • View Profile
Re: Getting Text of a Program Line Number
« Reply #7 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
« Last Edit: June 03, 2020, 07:58:06 AM by Jeffrey Ferreira »

jasonc

  • Member
  • **
  • Posts: 10
    • View Profile
Re: Getting Text of a Program Line Number
« Reply #8 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