Is it possible to add methods to an existing class with an external library? I am trying to develop a library to extend an existing library that has some classes, for which I would like to add extra methods. For example, suppose there is a pre-existing Testlibrary with a class Test:
Code: Select all
class Test {
FirstFunc(var) {
MsgBox, This is function 1 called with variable %var%
}
}
Now I want to add a new function SecondFunc to be used with the Test class.
[code]SecondFunc(var) {
MsgBox, Some other function called with variable %var%
}
Code: Select all
#include <Testlibrary>
#include <Testlibrary_extended>
nt := new Test
nt.FirstFunc("first function call")
nt.SecondFunc("second function call")
One other way I have considered is adding a for loop to the top of Testlibrary_extended, which would add all methods inside a Test_extended class to the Test class. The trouble with this way is that it relies on the code being executed in the main part of the script, which means the #include must be at the top of the code to properly work.
Is there some better way to solve this? Ideally something like this:
Code: Select all
class Test extends Test {
SecondFunc(var) {
MsgBox, Some other function called with variable %var%
}
}