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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to return more than 1 value from RETURN command.

Status
Not open for further replies.

ChangLun

Programmer
Oct 4, 2004
2
MD
How can I return more than 1 parameter from other form ?

I am using.......

DO form TO val1
 
As far as I am aware, you can't.

One option is to join multiple values into one variable, separated by a character of some sort and then, in the calling program, extract them from the returned variable.

A different option is to return an object that has properties that are the multiple variables you want to return.

Hope that helps,

Stewart
 
You can use global variables (public ones) thet you can set in your form.

Try something liuke this:

public returned1,returned2,returned3
do form yourform && the form will initialize the variables
.........
*here you should use your returned values
release returned1,returned2,returned3

In your form, you should have:
returned1 = value_1_you_need
returned2 = value_2_you need
......etc.......


Good luck Cristian
 
I would return an Array where you can stuff all the values into you like. The only Problem is how to deal with the Param. My way to solve the problem is shown in the example:

Create a Form with one Button and write the following code in the Click Event:
DIMENSION paramArray(3) && could be of any dimension...
STORE "" TO paramArray && just to initialize, no special purpose
SET UDFPARMS TO REFERENCE && to be sure that it works by reference
DO FORM form2 WITH paramArray
?paramArray(1)
?paramArray(2)
?paramArray(3)
Create a second Form (be sure to set it modal) with one Button and write in the Click Event the following code:
THISFORM.RELEASE
In the Init-Event of the form write:
PARAMETER ParamArray
In the Unload-Event of the form write:
ParamArray(1) = "This is the Number"
ParamArray(2) = 1
ParamArray(3) = "Solution"
return ParamArray
It's important to catch the params in the Init and to return the params in the Unload-Event!

hope this will help
Andreas
 
Why not do as most COM objects do, often when you use an activex compnent it returns an object with some properties that you can read.

Hell, you can even attach different arrays to that same object. You could return hundreds of variables.

Example:

PROCEDURE test
LOCAL loVarObj, lcTest1, lcTest2
lcTest1 = "MyReturnValue"
lcTest2 = "MyOtherReturnValue"

*- I wish to return the 2 values of variables lcTest1 and lcTest2

*- VarObj hodls the variables I wish to return
loVarObj = CREATEOBJECT('Custom')

WITH loVarObj
.AddProperty("cTestVal1", SPACE(0))
.AddProperty("cTestVal2", SPACE(0))
.cTestVal1 = lcTest1
.cTestVal2 = lcTest2
ENDWITH

RETURN loVarObj
ENDPROC


Now, if you get the object as return value something like:

loObject = test()

Than your values to read are:

loObject.cTestVal1 and loObject.cTestVal2

As you can see, in this way you can return an endless number of values.

HTH,

Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top