-
1
- #1
This seems to just be a bug. (VFP9 SP2) Can anyone confirm that this is strange behavior and that I'm not crazy, or is this something that can be explained away somehow?
This may be related to the thread 626553
I laid out all 3 permutation that are worth investigating in the Case comments in the code.
I have also run into instances after this happens where calling to code in cusBase cannot see the hidden member, but the code in cusChild could. This code sample does not include that behavior, but I believe it's related to the same bug.
Has anyone else run into this?
Thanks,
Ryan
This may be related to the thread 626553
I laid out all 3 permutation that are worth investigating in the Case comments in the code.
Code:
LOCAL lcErrorHandler AS String
lcErrorHandler = ON('ERROR')
ON ERROR ? CHR(9) + "Error: " + MESSAGE()
*
* Main program
*
CLEAR
LOCAL loChild AS Object
loChild = CREATEOBJECT("cusChild", 8)
? "[Child] Refer to hidden property from outside"
? loChild.inValue
? "[Child] Call accessor method on class"
loChild.PrintValue()
* Restore Error Handling
ON ERROR &lcErrorHandler.
RETURN
******************************
DEFINE CLASS cusBase as Custom
******************************
HIDDEN inValue
inValue = -1
**************
PROCEDURE Init
**************
LPARAMETERS tnValue
? PROGRAM() + IIF(VARTYPE(tnValue) == 'N', TEXTMERGE(' - set to <<tnValue>>:'), '')
IF VARTYPE(tnValue) == 'N'
*
* Executing this line via a DoDefault causes an issue
*
this.inValue = tnValue
ENDIF
ENDPROC
*******
********************
PROCEDURE PrintValue
********************
? PROGRAM()
? this.inValue
ENDPROC
*******
ENDDEFINE
*********
********************************
DEFINE CLASS cusChild as cusBase
********************************
**************
PROCEDURE Init
**************
LPARAMETERS tnValue
*
* Case 1: DoDefault() - This causes the desired behavior
* Case 2: DoDefault(tnValue) - This UNHIDES the hidden property
* Case 3: Comment this Init - This causes the desired behavior
*
DODEFAULT()
? PROGRAM() + ' - set to 5:'
this.inValue = 5
ENDPROC
*******
********************
PROCEDURE PrintValue
********************
DODEFAULT()
? PROGRAM()
? this.inValue
ENDPROC
*******
ENDDEFINE
*********
I have also run into instances after this happens where calling to code in cusBase cannot see the hidden member, but the code in cusChild could. This code sample does not include that behavior, but I believe it's related to the same bug.
Has anyone else run into this?
Thanks,
Ryan