Reputation: 1645
I have a .p file and I run it in unix console. and i love it . because it just a simple utility to run. It is simple and helps me learn.
Now I started to get more fancy. I am wondering if I can do an input parameter to a .p file?
this is how I usually run my .p file.
Now if test.p needs 2 parameter .. how do I do it in the .p? and how do I run it in the console?
This is what I have in the test.p and dOrd and dLocation is the input parameter I want.
output to /usr2/appsrv/test/test.txt.
def var dOrd like Ord.Ord.
def var dLocation like Ord.Ord.
find OrdCSRef no-lock where OrdCSRef.Ord = dOrd and OrdCSRef.Loc = dLocation no-error.
if available OrdCSRef then do:
put unformatted OrdCSRef.CSOrdRef skip.
end.
else
put unformatted "Create CSOrdRef" skip.
end.
output close.
I have tried the following syntax in the unix console. but obviously it will not work.
Upvotes: 1
Views: 508
Reputation: 1255
INPUT parameters is what you are looking for. Change test.p as follows and then run it as "RUN /usr2/appsrv/test/test.p ("ARG1", "ARG2")"
output to /usr2/appsrv/test/test.txt.
def input parameter dOrd like Ord.Ord.
def input parameter dLocation like Ord.Ord.
find OrdCSRef no-lock where OrdCSRef.Ord = dOrd and OrdCSRef.Loc = dLocation no-error.
if available OrdCSRef then do:
put unformatted OrdCSRef.CSOrdRef skip.
end.
else
put unformatted "Create CSOrdRef" skip.
end.
output close.
Upvotes: 1