read .p code

subscripciones

New Member
Hello, I looking for a way to .p or .w file return another .p file code.

example:
file1.p code:
define variable a as character no-undo.
for each <table>:
assign a = a + <value> + ','.
end.
assign a = trim(a,',').



i need file2.p receive '/home/test/file1.p' parameter and returns a string with the code from file1.



p. file: file2.p
input parameter: '/home/test/file1.p'
string result:
"define variable a as character no-undo.
for each <table>:
assign a = a + <value> + ','.
end.
assign a = trim(a,',')."


thanks
 

tamhas

ProgressTalk.com Sponsor
I think I am missing something here. There are several thing this makes me think of, but it isn't at all clear which, if any of them relate to your need since I am not clear on your need.

You can pass runtime parameters to uncompiled .p code and have that included in the compilation. That was the way we did dynamic queries before we had dynamic queries.

Then there are dynamic queries.

There is also code floating around for doing calculations based on being handed a formula, but I don't see any sign of that in what you are asking for.

Perhaps you should describe a bit more what you are trying to accomplish, rather than on how you think you need to accomplish it.
 

subscripciones

New Member
DEFINE INPUT PARAMETER pFile AS CHARACTER NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER code AS CHARACTER NO-UNDO.

ASSIGN
pFile = "pFile2.p"

RUN DoSomething.p (INPUT pFile, INPUT-OUTPUT code).


I need DoSomething.p fill "code" variable with pFile2.p code (reading the text file pFile2.p?)

thanks
 

TomBascom

Curmudgeon
Then you need to familiarize yourself with the IMPORT statement or examine the READ-FILE() method of the EDITOR widget.

Keep in mind that a character field has a somewhat small size limit for reading files. You might want to consider LONGCHAR.

Just curious but what do you hope to accomplish by reading a .p?
 

tamhas

ProgressTalk.com Sponsor
I think it is important to clue us in on what you are actually trying to accomplish here since there is nothing in this example that even requires two programs, other than possibly encapsulating some utility in the DoSomething.p. What is the DoSomething going to do?
 

subscripciones

New Member
I need to extract the .p code to show in a text field of an .net application installed in another server.

The .net application would call a .w installed in a webspeed sending the name of the file which content wants to extract. The .w runs a .p, would use the IMPORT statement and would return the content (.p code) to the application .net.
 

tamhas

ProgressTalk.com Sponsor
As Tom says, why? Thus far, you have told us nothing that suggests that the .p is anything other than a text file, any old text file. IMPORT will allow you to read a text file. You probably want to do it into a LONGCHAR to make sure you have room.

If the receiving end is doing something with it for which the fact that it is a .p is significant, we might be able to help with that. But, so far it just seems that IMPORT of text does what you want.
 

subscripciones

New Member
The purpose is create a html help file (.chm) in .net, listing and describing the existing progress programs: attributes, parameters name and a brief description.

I will look for some code example of the IMPORT sentence to read the content of a text file, into a LONGCHAR parameter.

Thanks to both.
 

subscripciones

New Member
interesting links, but I need the business logic in a .net application.

The progress program must limit to receive a filename ("/home/file1.p") and return the content, nothing more.
 

tamhas

ProgressTalk.com Sponsor
I'm afraid I am still missing something.

Why can .NET not read the .p directly?

What business logic is in the .NET application and why does it need to be there if there are pre-existing tools that do the same and more? Why re-invent the wheel?

What role is the ABL playing here? Just reading a file doesn't seem like a very meaningful use of ABL.

Are you missing anything to achieve your goal? IMPORT is sufficient for reading any text file, whether .p or not.
 

subscripciones

New Member
Why can .NET not read the .p directly? What business logic is in the .NET application and why does it need to be there if there are pre-existing tools that do the same and more? Why re-invent the wheel?

> It is not possible to store files in the progress server, and is not possible to accede to other servers. Only can execute and wait for a string response. security and corporates policies.

Are you missing anything to achieve your goal? IMPORT is sufficient for reading any text file, whether .p or not.

> Not, Only an example to fill an imput parameter with the text file content using IMPORT sentence.
 

tamhas

ProgressTalk.com Sponsor
It is an interesting notion of security that one is not allowed to directly read source code files on the server, but it is OK for a process on the server to send the contents of those files to another system.

Among other questions, one wonders why one doesn't simply take a copy of all of the source code and put it on the system with the .NET application.

In any case, did you look up IMPORT UNFORMATTED. There is a code example there showing reading of a file. If you need the whole program in a single string, then you would have to modify this to append each input line to a LONGCHAR and would have to add in your preferred delimiter between each line.

Still, this whole thing seems to me like the hard way to do something which could be done far more powerfully if you would use existing tools. Have you looked at the work being done with Proparse and ProRefactor recently. Just think how much more powerful a display you could make with an actual syntax tree versus raw code that you don't even know compiles. And, frankly, the ability of Analyst to display and link your code, including resolution of dynamic calls ... which you are never going to get in .NET ... well, the job is already done. Did you look at the demo? And there are a zillion possible extensions from that work which John could easily add if there were something more that you wanted.
 
Top