Hi,
I have a set of about 30 paired commands like this:
const char* ON = "+";
const char* OFF = "-";
const char* RESTART = "RESTART";
const char* RESTARTED = "RESTARTED";
and require a way to lookup the corresponding varied value.
For example:
if the command received is "+", need to respond with '-'
if the command received is "RESTART", need to respond with "RESTARTED"
There isn't a dictionary type object for me to use key values, and I can't figure out map
Im thinking of two options:
Option 1: create a one dimensional array of
const char* const STATE[2] = {"+", "-"};
const char* const RESTART[2] = {"RESTART", "RESTARTED"};
Lookup function would iterate the array and check if each items[0] element == whats received and return item[1]
Option 2: use a 2 dimensional array - but I don't know how to do this.
Would appreciate any help on how to define the array and the lookup function.
Thank you