Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine if controlsource is a field or a variable/prop
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00592686
Message ID:
01412605
Views:
57
>I have found a solution.
>BTW, the value was for a checkbox, can be numeric or logical only.
>I will include the .NULL. part later.
>Here is the code:
>
>
>IF !empty(this.controlsource)
>   WITH this
>      IF .Value<>EVAL(.controlsource)
>         lIsField=.F.
>         nDots=OCCURS(".",.controlsource)
>         DO CASE
>            CASE nDots > 1  && object property
>               lIsField=.F.
>            CASE nDots = 1  && property or field
>               uObjTest=SUBSTR(.controlsource,1,AT(".",.controlsource)-1)
>               uPropTest=ALLTRIM(SUBSTR(.controlsource,AT(".",.controlsource)+1))
>               IF TYPE(uObjTest)="O"
>                  IF PEMSTATUS(EVAL(uObjTest),uProptest,5)  && property exist
>                     lIsField=.F.
>                  ELSE
>                     && assume controlsource is a field
>                     lIsField=.T.
>                  ENDIF
>               ELSE
>                  && assume controlsource is a field
>                  lIsField=.T.
>               ENDIF
>            OTHERWISE  && nDots=0
>               * simple test, if fsize=0 it's not a field
>               IF FSIZE(.controlsource) = 0
>                  lIsField=.F.
>               ELSE
>                  lIsField=.T.
>               ENDIF
>         ENDCASE	
>         IF lIsField  && field
>            cReplace="REPLACE "+.controlsource+" WITH "+;
>               IIF(TYPE(".value")="N",ALLTRIM(STR(.value)),;
>               IIF(.value=.t.,".T.",".F."))
>            &cReplace
>         ELSE &&property or variable
>            cReplace=.controlsource+" = "+;
>            IIF(TYPE(".value")="N",ALLTRIM(STR(.value)),;
>               IIF(.value=.t.,".T.",".F."))
>            &cReplace
>         ENDIF
>      ENDIF
>   ENDWITH	
>ENDIF
>
>
What if the ControlSource is a complex expression? How would we determine if it's an expression or a real field?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform