Kbase P128512: How to pass parameters from the command line ( -param )
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  26/01/2008 |
|
Status: Unverified
GOAL:
How to pass parameters from the command line ( -param )
FACT(s) (Environment):
All Supported Operating Systems
Progress/OpenEdge Versions
FIX:
This article describes how to pass parameters from the command line to an ABL/4GL program.
This technique can be used to pass parameters to a Progress/OpenEdge application that needs to behave differently based on parameter value(s), or batch programs that require parameters.
The -param client startup parameter can be used to pass a character string to a Progress session. The SESSION:PARAMETER attribute is then used to access this character string. This character string can be converted to another data type or parsed as required by the application.
NOTE: The -param parameter is also used to specify one or more files to load into Procedure Editor buffers when loading Progress. Therefore, if the -param value does not correspond to a file or you do not want the Procedure Editor to load, you can use the QUIT statement so the program will finish without opening the Procedure Editor.
The -param parameter can be used with any Progress client,
examples: - prowin32 -p pp.p -param test
- _progres -p pp.p -param test
- pro -p pp.p -param test
- mpro -p pp.p -param test
- bpro -p pp.p -param test
- mbpro -p pp.p -param test
Example of usages:
1) Passing a single character string:
- prowin32 -p pp.p -param test
/*Test program (pp1.p) */
DISPLAY "The parameter is:" SKIP SESSION:PARAMETER FORMAT "X(70)".
PAUSE.
QUIT.
2) Passing a parameter containing spaces:
- prowin32 -p pp1.p -param "test abc"
/*Test program (pp.p) */
DISPLAY "The parameter is:" SKIP SESSION:PARAMETER FORMAT "X(70)".
PAUSE.
QUIT.
3) Converting the character parameter to another datatype
- prowin32 -p pp1.p -param 1024
/*Test program (pp.p) */
DISPLAY "The result of the parameter + 70 is:"
SKIP INTEGER(SESSION:PARAMETER) + 70.
PAUSE.
QUIT.
4) Using the -param parameter to refer to a list of values
- prowin32 -p pp1.p -param abc,xyz,123,789
/*Test program (pp.p) */
DEF VAR cParamList AS CHARACTER NO-UNDO.
DEF VAR iEntry AS INTEGER NO-UNDO.
cParamList = SESSION:PARAMETER.
DISPLAY "The parameter is:" SKIP cParamList FORMAT "X(70)" SKIP
"The number of entries is:" NUM-ENTRIES(cParamList).
REPEAT iEntry = 1 TO NUM-ENTRIES(cParamList):
DISPLAY "Entry: " iEntry " is " ENTRY(iEntry, cParamList).
END.
PAUSE.
QUIT.
5) Creating a wrapper to pass -param to an existing program with input parameters
- prowin32 -p pp2.p -param "CharVal one,CharVal two,9900"
/* Test program (pp2.p) */
DEFINE VARIABLE cParamList AS CHARACTER NO-UNDO.
cParamList = SESSION:PARAMETER.
DISPLAY "The parameter is:" SKIP
cParamList FORMAT "x(70)".
RUN myProgram.p ( INPUT ENTRY(1,cParamList),
INPUT ENTRY(2,cParamList),
INPUT INTEGER(ENTRY(3,cParamList)) ).
PAUSE.
QUIT.