Custom Libraries

I have several methods that I use in all of my forms and projects. I would like to place them in a library and access them from wherever I need them. Can you help me with the setup and syntax? I have done this in other languages I hope I can do it here as well.

Parents
  • Verified Answer

    If these are methods that simply act upon data that you pass to them then you can define then as static methods in a class in a separate project.

    Then add this project as a reference to your other projects that require these methods.

    Static methods are associated with the class itself so you do not create an instance of the class in order to access its static methods.

    Example.

    calling program:

           method-id button1_Click final private.
           procedure division using by value sender as object e as type System.EventArgs.
               set textBox1::Text to type mylibrary.sharedclass::sharedMethod
               goback.
           end method.
    

    static method in referenced class

           class-id mylibrary.sharedclass.
           working-storage section.
    
           method-id sharedMethod static.
           procedure division returning mystring as string.
    
               set mystring to "return from sharedMethod"
               goback.
           end method.
    
           end class.
    
Reply
  • Verified Answer

    If these are methods that simply act upon data that you pass to them then you can define then as static methods in a class in a separate project.

    Then add this project as a reference to your other projects that require these methods.

    Static methods are associated with the class itself so you do not create an instance of the class in order to access its static methods.

    Example.

    calling program:

           method-id button1_Click final private.
           procedure division using by value sender as object e as type System.EventArgs.
               set textBox1::Text to type mylibrary.sharedclass::sharedMethod
               goback.
           end method.
    

    static method in referenced class

           class-id mylibrary.sharedclass.
           working-storage section.
    
           method-id sharedMethod static.
           procedure division returning mystring as string.
    
               set mystring to "return from sharedMethod"
               goback.
           end method.
    
           end class.
    
Children
No Data