Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SCATTER in a COM Object
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00834954
Message ID:
00840160
Views:
25
>Hi Larry,
>
>I have coded this example, and I get an UNKNOWN MEMBER error when I run it as a COM obect on the line:
>
> "luvalue = evaluate(lcproperty)"
>
>Thanks

Kevin,
I don't know why you are getting an error. I tested this using the class as a VFP object and as a COM object. The only change I needed to make was the following:
if !(pemstatus(THIS,tcfieldname,5)) and ;
	THIS.AddProperty(tcfieldname, tufieldvalue) then
The table I tested with had a NAME field. When the AddProperty() executed, the object threw an error.

Here is my test code. Let me know if it doesn't work on your end and if it does, how it differs from your test case:
Proptest.Prg
define class sesProperty as Session olepublic
procedure GetFields
use foxuser.dbf
local lxx, lnfldcnt, loretval
local array laflds[1]
loretval = createobject('cusReturn')
for lxx = 1 to afields(laflds)
	loretval.AddFieldProps(field(lxx),evaluate(field(lxx)))
endfor
use in foxuser
return loretval
endproc
enddefine


define class cusReturn as custom
dimension apropnames[1]
apropnames[1] = (space(0))
npropnum = 0

procedure AddFieldProps
lparameter tcfieldname, tufieldvalue

if !(pemstatus(THIS,tcfieldname,5)) and ;
	THIS.AddProperty(tcfieldname, tufieldvalue) then
   if empty(THIS.apropnames[1]) then
      THIS.apropnames[1] = tcfieldname
   else
      local narrlen
      narrlen = THIS.npropnum+1
      dimension THIS.apropnames[narrlen]
      THIS.apropnames[narrlen] = tcfieldname
   endif
endif

endproc

procedure npropnum_access
return alen(THIS.apropnames,1)
endproc
enddefine
This was compiled into a DLL using the following commands:
build project proptest from proptest
build dll proptest from proptest
And here is my test program:
clear
local lox, loy, lcproperty, lxx
lox = createobject('proptest.sesproperty')
loy = lox.getfields()
for lxx = 1 to loy.nPropnum
	lcproperty = 'loy.'+loy.apropnames[lxx]
	? evaluate(lcproperty)
endfor
Regards.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform