Highlighted
Absent Member.
Absent Member.
979 views

Custom Libraries

Jump to solution

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.

Jerry

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Custom Libraries

Jump to solution

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.

View solution in original post

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Custom Libraries

Jump to solution

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.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Custom Libraries

Jump to solution

Just what I needed. Thanks.

Jerry

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.