Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing arrays to .NET and getting arrays back
Message
De
02/05/2011 12:02:48
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Passing arrays to .NET and getting arrays back
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01509041
Message ID:
01509041
Vues:
141
update: have found this
http://www.west-wind.com/weblog/posts/2006/Jul/27/Passing-Arrays-between-FoxPro-and-NET-with-COM-Interop
and am working through it now. Will return with further confusion <g>


I have built a webservice wrapper in C# for VFP to eat. Works great. All my exposed methods are receiving and returning to and from VFP as expected - except arrays

I think I need a refresher on the nuances of passing arrays in and out. Because of lack of strong typing, I assume the .NET incoming param must be object[] or object[,]

I am currently trying to pass in a vfp @arrparam where arrparam is dime arrayparam[4] of strings. I would like to get back ids[4,2] with strings and integers.

I could also pass in a 2 dime array by reference if I could figure out how to pass it back.

If my object is lows, besides

comarray(lows,0) to get the array to pass in 0 based what are the other tricks I should know about this?

The method works fine in my .NET test harness
    public object[,] FindIdsByEmails(object[] emailarray)
        {
            int emailslen = emailarray.Length;
            object[,] returnarray = new object[emailslen, 2];
            for (int i = 0; i < emailslen; i++)
            {
                string email = (string)emailarray[i];
                long? id = this.FindIdByEmail(email);
                returnarray[i, 0] = email;
                if (id != null)
                {
                    returnarray[i, 1] = id;
                }
                else
                {
                    returnarray[i, 1] = 00000;
                }
            }
            return returnarray;
        }
But this VFP test prg gets me an error that "Function argument value, type or count is invalid."
CD "c:\users\pagan\documents\visual studio 2010\projects\glwebservice\glwebservice\bin\debug"
ACTIVATE WINDOW watch
lows = CREATEOBJECT("glwebservice.glclient")
lows.login("xxxxxx@xxxxx.org", "password", "<security key")

DIMENSION foo(4)

foo(1)="dan@primarydatasolutions.com"
foo(2)="charleshankey@f1tech.com"
foo(3) = "raferris@hsonline.net"
foo(4) = "foo@foo.net"
DIMENSION ids(4,2)

comarray(lows,0)

* here's where I get the error

ids = lows.FindIdsByEmails(@foo)  

lows.logout
lows = null

RETURN
Suggestions, hints, pointing to docs all appreciated.


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.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform