PDA

View Full Version : What is the difference?


ABC123

Tommy
02-14-2005, 06:23 AM
This code works fine.

IF lookupl("F","1","disable_type_of_service","c:/eyesoft/sysdef.dbf","default_ke")=.T. THEN

:hfca1500:TYPE_OF_SERVICE_1.disable()
:hfca1500:TYPE_OF_SERVICE_2.disable()
:hfca1500:TYPE_OF_SERVICE_3.disable()
:hfca1500:TYPE_OF_SERVICE_4.disable()
:hfca1500:TYPE_OF_SERVICE_5.disable()
:hfca1500:TYPE_OF_SERVICE_6.disable()
END IF

This code returns error ( f.disable() Argument is incorrect data type). If you run trace the value of f looks just like the values in the first example. What have I done wrong?

DIM SHARED f AS c

IF lookupl("F","1","disable_type_of_service","c:/eyesoft/sysdef.dbf","default_ke")=.T. THEN

for i = 1 to 6

f = ":hfca1500:TYPE_OF_SERVICE_"+ltrim(str(i,1,0))

f.disable()
'traceln(f)
next

END IF

Steve Andrews
02-14-2005, 06:40 AM
Tommy,

In your second batch of code, the system takes f as a character string - not as a pointer to a button. I assume that your "TYPE_OF_SERVICE_n" objects are buttons.

If the two lines invlolving f are replaced with the following, it may work out. Give it a try.


eval(":hfca1500:TYPE_OF_SERVICE_"+ltrim(str(i,1,0))+".disable()")

My 2 cents,
Steve

Tommy
02-14-2005, 06:54 AM
Actually the TYPE_OF_SERVICE_n objects are fields on a form. I tried this but still got the same error. (Argument is incorrect data type) This is what I tried. Thanks

IF lookupl("F","1","disable_type_of_service","c:/eyesoft/sysdef.dbf","default_ke")=.T. THEN

for i = 1 to 6

eval(":hfca1500:TYPE_OF_SERVICE_"+ltrim(str(i,1,0))+".disable()")

next

END IF

END

Tom Cone Jr
02-14-2005, 07:31 AM
I think it's a bad practice to use the same pointer for multiple things. Having said that, however ...

With a pointer to the form, can't you get a pointer to any field object with something like this?

fld_ptr = frm_ptr.child("FieldObjectName")


With this approach couldn't you get pointers to
f1
f2
f3
f4
f5
f6

and so on, by passing a string to the .child method that contains the fieldobjectname ?

-- tom

--

Tommy
02-14-2005, 07:37 AM
I give this a try. I'm on another project now. I'll let you know what happens. Thanks