HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started by: enterprised on March 18, 2015, 01:41:29 AM
-
Need some help.
I can't get the subroutine code to work in HG C# code app's, see code example below.
Is this by design or should I use something different to create a subroutine?
public void SomeThing()
{
// some code to make something happen which can be called from another bit of code
}
-
This is by design. HG c# programs are just straight c# coding with no class definition.
To define a subrouting you can do like this:
var SomeThing = new Action(()=>{
Program.Notify("Test", "Hello World!");
});
SomeThing();
or in case you need a return value
var GetHalf = new Func<double, double>((number)=>{
return number / 2d;
});
Program.Notify("Test", "Half of 5 is " + GetHalf(5));
Cheers,
g.