Yesterday I made the change to the code, as was suggested by John Ryan. I also set TRY / CATCH around the entire code. This will allow me to catch an error, if it happens and save it into a hidden log. I installed this code at 6 customers PCs. I will be looking at the hidden log from time to time to see if the problem occurs.
Thank you.
>(stabbing in the dark) Would this make any difference?
>
>IF !EMPTY( this.control_source )
> cAlias = SUBSTR( ALLTRIM(this.control_source), 1, AT('.',ALLTRIM(this.control_source)) - 1)
> * 1. Check to see if cAlias is blank
> IF EMPTY(cAlias)
> = MESSAGEBOX("cAlias is empty", 0, "test")
> ELSE
> * 2. A different approach to checking if workarea is open
> IF NOT USED( cAlias )
> = MESSAGEBOX("Alias "+cAlias+" not open!", 0, "test")
> ELSE
> cControlSource = ALLTRIM( this.control_source )
> IF EVALUATE( cControlSource ) == OLDVAL( cControlSource )
> RETURN .T.
> ENDIF
> ENDIF
> ENDIF
>ENDIF
>
>
>>>>>Hi,
>>>>>
>>>>>Could someone suggest why I am having a problem (actually not me but the customer) in the following segment of code:
>>>>>
>>>>>The container with the text box has a property control_source. This property has a value V_WORK.EMPLOYEE
>>>>>
>>>>>The code then checks is the value of the field EMPLOYEE in the cursor V_WORK has been change. Here is the code:
>>>>>
>>>>>
>>>>> cControlSource = ALLTRIM( this.control_source )
>>>>> IF EVALUATE( cControlSource ) == OLDVAL( cControlSource )
>>>>> RETURN .T.
>>>>> ENDIF
>>>>>
>>>>>
>>>>>The problem occurs on the line above, EVALUATE( cControlSource ) == OLDVAL( cControlSource ), and it does
>>>>>ALIAS IS NOT FOUND. I verified that the entry in .control_source exists as described above.
>>>>>
>>>>>TIA.
>>>>>
>>>>>UPDATE. the following code checks that the alias V_WORK exist and is open. This code, below, is before the code above (just in case someone wonders if the alias is indeed exists and open
>>>>>
>>>>>
>>>>>IF !EMPTY( this.control_source )
>>>>> cAlias = SUBSTR( ALLTRIM(this.control_source), 1, AT('.',ALLTRIM(this.control_source)) - 1)
>>>>> IF SELECT( cAlias ) > 0
>>>>> cControlSource = ALLTRIM( this.control_source )
>>>>> IF EVALUATE( cControlSource ) == OLDVAL( cControlSource )
>>>>> RETURN .T.
>>>>> ENDIF
>>>>> ENDIF
>>>>>ENDIF
>>>>>
>>>>
>>>>I added - for testing - a TRY / CATCH around the above code. Then modified the line:
>>>>
>>>>cControlSource = ALLTRIM( this.control_source )
>>>>
>>>>to a bogus:
>>>>
>>>>cControlSource = "test.test_field"
>>>>
>>>>
>>>>And the error caught by the TRY / CATCH, says "Alias 'test' not found".
>>>>But the error that the customer saw (without a TRY /CATCH) did not have the "bad" alias name. It was simply:
>>>>ALIAS IS NOT FOUND
>>>>
>>>>Any suggestions?
>>>
>>>Could there be a possibility that the control_source property be assigned a value other than what you're expecting it to be (in particular when the code is run at the customer location where the orignial problem is occurring) ?
>>>could there be a possible problem like "pointer aliasing" going on?
>>>
>>>* object "foo" contains object "bar" which in turn contains object "baz". Object "baz" has property named "propname"
>>>foo.bar.baz.propname = "some value"
>>>= SubProc( foo.bar.baz )
>>>* value of "propname" property would have changed.
>>>
>>>FUNCTION SubProc( yuck )
>>> yuck.propname = "other value"
>>>ENDFUNC
>>>
>>
>>I don't think the above scenario is possible. But I will think of it.
>>Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham