Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine if controlsource is a field or a variable/prop
Message
De
15/07/2009 18:45:20
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00592686
Message ID:
01412615
Vues:
41
>>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?

Right... I think
lcAlias=juststem(.controlsource)
if lcalias#.controlsource and used(lcAlias)
   * we have a table
else
   * not a table - check whether it's a property, variable etc
endif

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform