ways to set an int to NULL?

Hey, I have 4 web form text fields and they correspond to 4 int in arduino

int red, green, blue, white;

The issue is you don't have to fill out all 4 fields so lets say white is not filled out or is delete. What do I set white to? I've tried setting it to NULL but that's no good. That means it's a NULL to the pointer? And I would get a value of zero '0', if I get white. Zero is a valid value in my case.

Just thought I'd get some input before I hack it. I know value range can't be more than 16 so I can set it to something like 30 to represent an empty field.

If -1 is not a valid colour value, I would use that. Easy to test.



#define UNSET -1

OH! smart!

One way to attach numbers to labels is to use enumerators.

Example from a sketch, those are menu system states. The = is used to set a value and then every one after without an = something takes on the next value. All you're doing is making names for numbers, to make code more readable.

__attribute__ ((__packed__)) enum  eMenus // makes bytes 
  noMenu = -1, mainMenu, timerMenu, lowLimitMenu, highLimitMenu 

The attribute ((packed)) part is to make the compiler use an 8 bit value wherever the number gets coded, otherwise it uses 16 bit. The enum statement itself does not add code.