Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing Arrays from DO FORM
Message
From
25/11/2009 17:02:49
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01436626
Message ID:
01436629
Views:
101
This message has been marked as a message which has helped to the initial question of the thread.
>Hi Gang!
>
>I want to pass an Array BACK to a calling Procedure....
>
>Calling Procedure ->
>
>
>DO FORM frmlookup TO laLookup
>
>
>where laLookup is an array....
>
>and the called form's UNLOAD event is...
>
>
>LOCAL ARRAY laItemNo(2)
>
>*TMT 11/24/09 Modified the code to send the data back as 2 elements of an array
>*laItem(1) is the Item No  and laItem(2) is the TranID of the Transaction
>IF csr_regtrans.rx_no > 0	&& This is a Rx Item
>	laItemNo(1) = ALLTRIM(STR(csr_regtrans.rx_no)) +   PADL(ALLTRIM(STR(csr_regtrans.refill_no)),2,"0")
>ELSE
>	laItemNo(1) = csr_regtrans.upc_code
>ENDIF 
>
>*TMT 11/24/09 laItem(2) which is the Tranid
>laItemNo(2) = Thisform.p_tranid
>
>POP KEY
>USE IN csr_regtrans
>SELECT refund
>RETURN laItemNo
>
>
>When I trace the code, the laLookUp has 2 elements, but they are the same thing!
>
>I know this has to do with pass by value versus pass by reference, but my attemps to fix it have failed.
>
>So what am I doing wrong today?
>
>Thanks!

Your array is declared local. If you have declared the array before do form as private then form would see and update its members.

I would instead pass an object. ie:
local loParam
loParam = createobject('empty')
addproperty(loParam, 'aItem[2]')

do form frmlookup with loParam && loParam is an object and passed by reference

* form init
lparameters toParm
this.Addproperty('oParm', toParm)

* unload or anywhere else
toParm.aItem[1] = ...
* ...
Also check techniques that doesn't need to pass and/or return anything. ie:

http://social.msdn.microsoft.com/Forums/en-US/visualfoxprogeneral/thread/4132ee17-519a-4859-8e79-93f0be610187

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform