How to accept input parameters in Progress procedure ?

Mark123

New Member
Hi,

I relatively new to Progress. I wrote a Progress 4GL procedure which is actually a script saved in OS (not in database). Now I need to change it to accept input parameters.

Can someone point to an example or paste code snippet here ?

Thanks.
 

rrojo7229

Member
Hi.

RUN GetRecbyCategory (OUTPUT TABLE tt-category,
INPUT dWeekComm,
INPUT dWeekEnd,
OUTPUT l-error).

/**
pcGetRecbyCategory Procedure **/

DEFINE OUTPUT PARAMETER TABLE FOR tt-category.
DEFINE INPUT PARAMETER dWeekComm AS DATE NO-UNDO.
DEFINE INPUT PARAMETER dWeekEnd AS DATE NO-UNDO.
DEFINE OUTPUT PARAMETER l-error AS LOGICAL NO-UNDO.


Rrojo7229









Hi,

I relatively new to Progress. I wrote a Progress 4GL procedure which is actually a script saved in OS (not in database). Now I need to change it to accept input parameters.

Can someone point to an example or paste code snippet here ?

Thanks.
 

Mark123

New Member
Thanks Rrojo, but RUN command is to call it from Progress or Unix ? I tried to RUN it from Unix (ksh shell), but received a message ksh: run: not found.

My procedure is not stored in Progress database, it is saved in Unix, actually it is a script not a procedure, and I have to call it from Unix as well. Is it possible ? Can I still use RUN ?

Thanks
 

rrojo7229

Member
Mark,

Put over here, how you wrote this script to call this Progress 4GL Procedure (program).

As long as I understood are you call this program using a Batch conection?
I mean that way:

$DLC/bin/mbpro -db /pro/database/sports2000
-p /pro/scripts/chkareas_fix.p -d dmy -E
-yy 1950 -v6colon >> /tmp/chkareas_fix_db.log

Those parameters are to connect into a database, if you want implement parameter to call a program you can put that way:

/pro1/101b/full/bin/promon /pro/database/sports2000 < /etc/rc
.d/rc2.d/inputpromon.txt >> /pro1/unixpro/Ricardo/promon_allin1.txt

This program promon is to Monitoring a Progress Database but need inputs to navigate through the screens, so if you want give parameter you can create a text file with parameter and use "<" after the program, the last parameter ">> /pro1/unixpro/Ricardo/promon_allin1.txt" is a log file.

So, you can make the same with your procedure ("program").

more /etc/rc.d/rc2.d/inputpromon.txt
5
Q
Q

Regards,
Rrojo7229


Hi,

I relatively new to Progress. I wrote a Progress 4GL procedure which is actually a script saved in OS (not in database). Now I need to change it to accept input parameters.

Can someone point to an example or paste code snippet here ?

Thanks.
 

Casper

ProgressTalk.com Moderator
Staff member
I wrote a Progress 4GL procedure which is actually a script saved in OS (not in database)

A progres 4GL procedure you can execute with run within a progress session and is normally not saved in the database.

If you haven't got a Progress session then you can run it from the command prompt with the statement rrojo7229 gave.

another way to pass parameters to a Progress 4GL procedure is passing the parameters with the -param option.

e.g.:
Code:
$DLC/bin_progres -b -db [I]path-todatabase/databasename[/I] -p [I]yourprogram.p[/I] -T [I]tempdir [/I]-param[I] some delimited paramlist[/I]


If you use for instance -param abc,23,12-02-1997,3456 you can use this parameters in yourprogram.p as follows:
Code:
define variable cParamList as character no-undo.
define variable param1 as character no-undo.
define variable param2 as integer no-undo.
define variable param3 as date no-undo.
define variable param4 as integer no-undo.
 
assign cParamList = session:parameter
         param1 = entry(1,cParamList)
         param2 = INTEGER(entry(2,cParamList))
         param3 = DATE(entry(3,cParamList))
         param4 = INTEGER(entry(4,cParamList)).

BTW what is this ' script' you are talking about look like? Is this a 4GL procedure or is it a OS script?
 

sphipp

Member
Yes, I think the original question is asking about passing parameters into a start-up command line.

The -param option is the best way to do this, or you could set up environment variable and access them from your program.

def var this_program as char no-undo.
def var this_inputfile as char no-undo.
def var this_outputfile as char no-undo.
run p_get_param.

message this_program skip this_inputfile skip this_outputfile skip
view-as alert-box.

procedure p_get_param:
def var paramlist as char no-undo.
def var paramloop as int no-undo.
def var paramdelim as char no-undo.
def var this_param as char no-undo.
def var this_result as char no-undo.
paramlist = session:parameter.
paramdelim = ",".

do paramloop = 1 to num-entries (paramlist,paramdelim):
this_param = entry (paramloop, paramlist,paramdelim).
if num-entries (this_param,"=") = 2 then do:
this_result = entry (2,this_param,"=").
case entry (1,this_param,"="):
when "prog" then this_program = this_result.
when "input" then this_inputfile = this_result.
when "output" then this_outputfile = this_result.
end case.
end.
end.
end procedure.

You would start this with
mpro -db mydb -p start.p -param "prog=program.p,input=input.txt,output=output.txt"

Alternatively, in your batch script, you could set environment variables.

[In Unix]
INPUTFILE=input.txt
OUTPUTFILE=output.txt
PROGRAM=program.p
export INPUTFILE OUTPUTFILE PROGRAM

[In DOS]
set INPUTFILE=input.txt
set OUTPUTFILE=output.txt
set PROGRAM=program.p

[In Progress]
inputfile = os-getenv ("INPUTFILE").
outputfile = os-getenv ("OUTPUTFILE").
program = os-getenv ("PROGRAM").
 
Top