Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Define a Read-Only Property?
Message
From
22/07/2007 14:53:25
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01242584
Message ID:
01242628
Views:
11
Thank you Sergey for your response.
I truly do appreciate your attention and assistance.

A follow up if I may...

Did you say that SYS(1269) only works on native VFP properties?
How could one test whether a custom property is (fashioned as) read-only?

The SetAll() method seems to respect the hidden and read-only nature of native properties, without causing an error. Is there any way to accomplish this with a defined property fashioned as read-only?

The best that I could come up with is...
HIDDEN PROCEDURE cReadOnly_Assign
LPARAMETERS vNewVal
     LOCAL liAcceptCall AS INTEGER
     liAcceptCall = THIS.AcceptCall()    &&  Accept this Assignment?
*- liAcceptCall < 0    && Error Condition
*- liAcceptCall = 0    && Do Nothing
*- liAcceptCall > 0    && Accept the Assignment

     DO CASE
          CASE liAcceptCall < 0
               ERROR 1743 , THIS.CLASS + ".cReadOnly"
          CASE liAcceptCall = 0
               && Do Nothing
          OTHERWISE
               THIS.cReadOnly = m.vNewVal
     ENDCASE
ENDPROC
HIDDEN PROCEDURE AcceptCall AS INTEGER HELPSTRING "Accept this Assignment?"
     LOCAL liStackDepth AS INTEGER
     LOCAL lcCaller AS STRING
     LOCAL liStackDepth AS INTEGER
     LOCAL ARRAY laStack(1,6)
     LOCAL liRetVal AS INTEGER
*- liRetVal < 0    && Error Condition
*- liRetVal = 0    && Do Nothing
*- liRetVal > 0    && Accept the Assignment

     liStackDepth = ASTACKINFO(laStack)


     IF liStackDepth > 2
          lcCaller = laStack(liStackDepth-2,6)
     ELSE
          lcCaller = ""
     ENDIF

     DO CASE
          CASE ALLTRIM(UPPER(STREXTRACT(lcCaller,".","(",OCCURS(".",lcCaller)))) = "SETALL"
               liRetVal = 0
          CASE liStackDepth = 2 && From the Command window
               liRetVal = -1
          CASE (AT(UPPER(THIS.CLASS) + ".", PROGRAM(liStackDepth-2))=1)
*- Thanks to:    Anatoliy Mogylevets 
*- Thread ID: 	 927230
*- Message ID: 	 927404
               liRetVal = 1
          OTHERWISE
               liRetVal = -1
     ENDCASE
RETURN liRetVal
ENDPROC
How does this look to you?
Thank you,
- Frank
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform