Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables out & in programs

Status
Not open for further replies.

blumash

Programmer
Oct 2, 2003
50
0
0
HU
I m trieng to send a data field from one program to another , I don't realy know how to code this in my programs , main program is always open & there is the variable generated , I would like to transfer this variable to 2 other programs that r calle from the main program.

Thank's
 
You need to do two things in order to pass a parameter across to another program:

1. Have an LPARAMETER statement at the start of the program you're calling to define the parameter or parameters expected.

2. Use a WITH clause when you call the program.

In effect you are treating the program just as though it were a procedure.

Geoff Franklin
 
There are a bunch of ways to pass variables between programs.

DO XXX heirarchy:
1) Find procedure or function XXX in the current program or the program specified by SET("PROC"). DO XXX WITH VARS expects a PARAMETER VARS at the top of the function or procedure.
2) Find XXX.PRG in the current folder or SET("PATH") folders and start at the top and run the code before the first FUNCTION or PROCEDURE. DO XXX WITH VARS expects a PARAMETER VARS at the top of XXX.PRG.

DO XXX IN YYY will search for the XXX function or procedure in program YYY.PRG. This allows you to chose any function or procedure in YYY.PRG and not just start at the top.

You might want to return a value from a function in another program. Since a function call has no equivalent for DO ... IN, you will need to SET PROC then call the function.

*PROG1
SET PROC TO PROG2
?"Don't call "+here("ever")
SET PROC TO

*PROG2
return "anywhere"
function here
parameter stuff
return "here "+stuff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top