Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using COMARRAY()
Message
From
18/01/1999 08:33:47
 
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00177137
Message ID:
00177143
Views:
38
>I seem to be getting an error (Function argument value, type or count is invalid) while using COMARRAY(oMyObject, nNewValue) in VFP 6.0. The object (oMyObject) is created properly, I have tested for that, and nNewValue = 11 (One-based, passed by reference). VFP trips on this line itself. There is no syntax error and the line of code is
> COMARRAY(oMyObject, 11) ;
>
>Is this a bug or am I losing it??

Is oMyObject an OLE Server, or an object created from a VFP class that is not declared OLEPUBLIC and compiled into a .DLL or .EXE, and accessed by invoking CRATEOBJ() or NEWOBJECT() against it' ProgID? COMARRAY() applies to automation object; IOW, it applies to classes registered as in-process or out-of-process servers, not to objects created from a VCX or programmatic declaration of a class in VFP code. IOW, if I create an object for the Shell.Application Automation object like:

ox = CREATEOBJ('Shell.Application')
COMARRAY(ox,11) && this works

If I instantiate the FFC registry class through a VCX:

SET CLASSLIB TO Registry ADDITIVE
oy = CREATEOBJ('registry')
COMARRAY(oy,11) && this generates the error you got

There's no need to convert array refs for classes created from the .VCX, since they can use the normal VFP mechanisms to deal with inbound parameters (IOW, the behavior you want is normal for an object receiving an array by reference;) you'll pass the array by reference simply by:

DECLARE MyArray[1,5]
MyObject.Method(@MyArray) && pass by ref
* If the method is written as below, the array will have been changed here

*Within your class:
FUNCTION MyMethod
LPARAMETER aInBoundArray
EXTERNAL ARRAY aInBoundArray
* The following redimensions the array passed in by reference
* and sets all elements to 42
DIMENSION aInBoundArray[2,5]
aInBoundArray = 42
*etc.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform