So close, but not yet there... Hi - I've been trying to use Retrieve () from Quotations in C# using the description found here:
http://groups.google.com/group/microsoft.public.dotnet.framework.inter op/msg/010238fcb89f94ee Below is the code. The ole call goes fine - but it only returns the initialized values in the parameters going in - not the actual quotes. Anybody knows how to use Retrieve() from c#? I've seen a number of posts with the same question - but not yet found an answer. Thought I got it made below - but so far no cigar... Any help (really, really) appreciated! Best regards Jens Tiedemann public void GetQuotations( string ticker, object stocks) { // Set up the parameter array for the InvokeMethod call. // Initialize each element (to avoid nonInitialized compiler error). object[] ParamArray = new object[8]; ParamArray[0] = (long) 1; ParamArray[1] = DateTime.Now; ParamArray[2] = (float) 0; ParamArray[3] = (float) 0; ParamArray[4] = (float) 0; ParamArray[5] = (float) 0; ParamArray[6] = (float) 0; ParamArray[7] = (float) 0; // Set up the ParameterModifier array. // There are 8 parameters. Note that // the ParameterModifier constructor is given the number of // parameters // in the method. The indexer is used to specify which // parameters are out parameters. ParameterModifier[] ParamMods = new ParameterModifier [1]; ParamMods[0] = new ParameterModifier (8); // inititialize with number of method parameters ParamMods[0][0] = false; // Set the 1st param to be an out param ParamMods[0][1] = true; // set the 2nd param to be an out param ParamMods[0][2] = true; // set the 3rd param to be an out param ParamMods[0][3] = true; // set the 4th param to be an out param ParamMods[0][4] = true; // set the 5th param to be an out param ParamMods[0][5] = true; // set the 6th param to be an out param ParamMods[0][6] = true; // set the 7th param to be an out param ParamMods[0][7] = true; // set the 8th param to be an out param // Set the call up - amiMethod/getAmiProperty do what they indicate // and are well tested object stock = amiMethod(stocks, "Item", ticker); object quotations = getAmiProperty(stock, "Quotations"); string methodName = "Retrieve"; // Call the version of InvokeMember that // accepts a ParameterModifier array. long ReturnValue = 0; try { ReturnValue = (long)quotations.GetType().InvokeMember( methodName, // method name BindingFlags.Default | BindingFlags.InvokeMethod, null, quotations, // obj being called ParamArray, // argument list ParamMods, // ParameterModifier array null, null); } catch (Exception ex) { setError("amiMethod: " + methodName + " failed!", ex); } // "Unpack" the byRef received values float Date = Convert.ToDateTime(ParamArray[1]); float Open = Convert.ToSingle(ParamArray[2]); float High = Convert.ToSingle(ParamArray[3]); float Low = Convert.ToSingle(ParamArray[4]); float Close = Convert.ToSingle(ParamArray[5]); float Volume = Convert.ToSingle(ParamArray[6]); float OpenInt = Convert.ToSingle(ParamArray[7]); }
