Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing arrays to .NET and getting arrays back
Message
From
02/05/2011 15:52:58
 
 
To
02/05/2011 14:47:58
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01509041
Message ID:
01509093
Views:
60
Thanks Tracy. I'll study on that.

See my other post. Got it working by passing in @foo(n,2) from vfp to an object[,] param in c# and then passing the same array back as a return from the C# and catching in with another variable in VFP

foohoo = lows.FindIdsByEmails(@foo)

where foo(1,1) is the email and foo(1,2) goes in as 0

Also discovered C# public methods that return nullable types ( long? ) are not seen by vfp

Glad I don't have to do a lot of this interop stuff, but I think next time it will be a lot easier.

Thanks for the stuff below - I will definitely take it apart.



>SNIP
>
>(Sorry for the sloppy code, but I think you get the picture. Try referencing your array like so to see if it is really there or not...)
>
>Can you just return an object? This works for me:
>See section: "Passing Complex types between Visual FoxPro and .NET:"
>http://www.west-wind.com/presentations/dotnetfromVfp/DotNetFromVfp_ComplexObjects.asp
>
>Another option, when I get a collection hanging on an object from .net (passed to VFP via an event firing), I have to reference it like so or else I cannot "see" it:
>
>*--Event that is hooked up and fires:
>PROCEDURE INETAPIEvents_QuestAnsEvent(arg AS VARIANT) AS VOID
>*arg object is passed to vfp via com interop event firing  - it has collections as properties (remember it is zero-based in .net)
>*VFP Code in event to see questions and answers collection passed from .net:
>*arg object is passed to vfp via com interop event firing  - it has collections as properties (remember it is zero-based in .net)
>*VFP Code in event to see questions and answers collection passed from .net:
>IF TYPE("arg") = "O"  AND ...  && etc skip the stupid stuff you know
>   IF TYPE("arg.myObject") = "O" AND TYPE("arg.myObject.myCollection") = "O" AND TYPE("arg.myObject.myCollection.count") = "N" AND arg.myObject.myCollection.COUNT > 0
>	FOR I = 0 TO arg.myObject.myCollection.COUNT-1
>		IF TYPE("arg.myObject.myCollection.ITEM[m.i].Questions") = "O" AND arg.myObject.myCollection.ITEM[m.i].Questions.COUNT > 0  && Are there questions and answers?
>			FOR iq = 0 TO arg.myObject.myCollection.ITEM[m.i].Questions.COUNT - 1
>				RELEASE loTemp
>				loTemp = arg.myObject.myCollection.ITEM[m.i].Questions.ITEM[m.iq]
>				IF TYPE('ALEN(loTemp.Answers,1)') = "N"
>					FOR ia = 1 TO ALEN(loTemp.Answers,1)
>						IF .F.
>							DIMENSION laAnswers[1]
>						ENDIF
>						RELEASE laAnswers
>						laAnswers = loTemp.Answers
>					ENDFOR
>				ENDIF
>
>


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform