more G-Labs products

Author Topic: enum in csharp module?  (Read 1349 times)

April 09, 2015, 08:05:13 PM
Read 1349 times

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
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?

April 17, 2015, 03:15:55 AM
Reply #1

NickP

  • *
  • Information
  • Newbie
  • Posts: 24
Happy to be proved wrong, but not as far as I know in a c# script.

May 11, 2015, 12:13:13 AM
Reply #2

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
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.

May 11, 2015, 12:50:24 PM
Reply #3

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
Darn semi colons!  Unfortunately, after correcting that, it still doesn't work for me.

May 11, 2015, 03:37:50 PM
Reply #4

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
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.