can anybody please explain what am I actually supposed to do in order to be able to call a function from a menu? I even made a class, but still get an error:
Here is my current testing code:"Error: Parameter #2 of Menu.Prototype.Add requires an object, but received an empty string."
Code: Select all
#SingleInstance Force
myclass := CustomClass()
context := Menu()
context.add "Print Name", myclass.PrintName()
context.add "Print Name Length", myclass.CountName()
Pause::context.Show
F3::myclass.PrintName()
F4::myclass.CountName()
class CustomClass {
ClassName := "Awesome Class"
PrintName() {
MsgBox(This.ClassName)
}
CountName() {
MsgBox("The string length is " . StrLen(This.ClassName))
}
}
I just want to optimize the code because I used to spam different functions for a menu item, although the difference was only in one word. It looked like this:
Code: Select all
context.add my_email, mymail
context.add his_email, hismail
mymail(*)
{
Send my_email
return
}
hismail(*)
{
Send his_email
return
}