How to AddMethod like we AddProperty to an VFP class RRS feed

  • Question

  • Hi: I'm asking if there is a way to generate at runtime some methods in a class like we add properties by using ADDPROPERTY method or function. Thanks
    Monday, January 6, 2020 7:51 PM

All replies

  • I think you mean the WriteMethod method.

    It isn't for runtime usage. It's for programming builders- See http://doughennig.com/Papers/Pub/Mar99.pdf

    Bye, Olaf.

    Monday, January 6, 2020 8:43 PM
  • Hi algc5158,

    some years ago I posted about dynamic buttons and code in my blog. Perhaps this is already roughly the direction you are headed to.

    -> http://tomsvfpblog.blogspot.com/2017/09/buttons-zur-laufzeit-dynamisch.html

    In case, this isn't what you are trying to achieve, you will have to work with your own classes and implement hooks into all those events, where new code might be needed. This can be done with method calls within the class events or, if you don't use your own classes, you can make use of BINDEVENTS() / UNBINDEVENTS() in i.e. your form.init event. The called methods will then read files or records with memo fields that contain the new added code and this code can be used in your app with EXECSCRIPT().

    However, you will have to be really careful with this 'external' code. You should store it crypted and checksummed only to avoid easy access for others.


    Gruss / Best regards
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible,
    you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011

    Tuesday, January 7, 2020 6:41 AM