HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: kevin1 on April 09, 2015, 08:05:13 PM

Title: enum in csharp module?
Post by: kevin1 on April 09, 2015, 08:05:13 PM
When I try to add a simple enum like this, it causes errors on lines near enum definition:

Code: [Select]
public enum ArduinoData{
     AD_TEMP,
     AD_HUMID,
     AD_LUMEN,
     AD_SUMP;
 }
...
    string[] data = message.Split(',');
    Program.RaiseEvent(module1, "Sensor.Humidity",    data[AD_HUMID], "Sensor 1");



Is there another way?
Title: Re: enum in csharp module?
Post by: NickP on April 17, 2015, 03:15:55 AM
Happy to be proved wrong, but not as far as I know in a c# script.
Title: Re: enum in csharp module?
Post by: Wibo on May 11, 2015, 12:13:13 AM
Hi,

the AD_SUMP; seems higly suspicious.

It should not end with a semi colon (;)
It should either not be terminated at all, or a comma...

Best regards,
Wibo.
Title: Re: enum in csharp module?
Post by: kevin1 on May 11, 2015, 12:50:24 PM
Darn semi colons!  Unfortunately, after correcting that, it still doesn't work for me.
Title: Re: enum in csharp module?
Post by: Gene on May 11, 2015, 03:37:50 PM
Enums cannot be used in a C# automation program. You have to use constants:

Code: [Select]
const uint AD_TEMP = 0, AD_HUMID = 1, AD_LUMEN = 2, AD_SUMP = 3;

g.