Hi there, I've an question, but couldn't find it anywhere on the web.
I have to convert error codes from an device towards an number.
without using a lot of ifs and else's
byte lookupTable[] =
{0x4481, 0x4541, 0x4542, 0x4543, 0x4544, 0x4545, 0x4546, 0x4547, 0x4548, 0x4549, 0x4582, 0x4583, 0x4584, 0x4585, 0x4586, 0x4587, 0x4588,
0x45C1, 0x45C2, 0x45C3, 0x45C4, 0x45C5, 0x45C6, 0x45C7, 0x45C8, 0x45C9, 0x45CA, 0x4601, 0x4602, 0x4603, 0x4604, 0x4681, 0x4682, 0x4683,
0x46C1, 0x46C2, 0x4781, 0x4782, 0x4783, 0x47C1, 0x4881, 0x4882, 0x4883, 0x4884, 0x4885, 0x4886, 0x4887, 0x4888, 0x4889, 0x488A, 0x488B,
0x488C, 0x488D, 0x488E, 0x4941, 0x4942, 0x4981, 0x49C1, 0x49C2, 0x4A01, 0x4A81, 0x4B01, 0x4B81, 0x4C41, 0x4D01, 0x4D02, 0x4D03, 0x4D04,
0x4D41, 0x4D42, 0x4D43, 0x4DC3, 0x4E81, 0x4F01, 0x4F02, 0x4F41, 0x4F42, 0x4F43, 0x4F44, 0x4F45, 0x4F46, 0x4F47, 0x4F48, 0x4F49, 0x4F4A,
0x4F4B, 0x4F4C, 0x4F4D, 0x4F4E, 0x4F4F, 0x4F50, 0x4F51, 0x4F52, 0x4F53, 0x4F54, 0x4F55, 0x4F56, 0x4F57, 0x4F81, 0x5041, 0x5042, 0x5043,
0x5044, 0x5045, 0x5046, 0x5081, 0x5101, 0x5102, 0x5141, 0x5181, 0x5182, 0x5183, 0x5184, 0x5185, 0x5186, 0x5187, 0x5188, 0x51C1, 0x51C2,
0x5201, 0x52C1, 0x52C3, 0x52C4, 0x52C5, 0x5301, 0x5302, 0x5303, 0x5304, 0x5305, 0x5306, 0x5307, 0x5308, 0x5309, 0x530A, 0x530B, 0x530C,
0x530D, 0x530E, 0x530F, 0x5310, 0x5311, 0x5312, 0x5313, 0x5314, 0x5315, 0x5316, 0x5317, 0x5318, 0x5319, 0x5341, 0x5342, 0x5343, 0x5344,
0x5381, 0x5441, 0x5442, 0x54C1, 0x54C2, 0x54C3, 0x54C4, 0x54C5, 0x54C6, 0x54C7, 0x54C8, 0x54C9, 0x54CA, 0x54CA, 0x54CB, 0x54CC, 0x54CD,
0x54CE, 0x54CF, 0x5741, 0x5781, 0xD01A, 0xD02A, 0xD03A, 0xD01B, 0xD02B, 0xD03B, 0xD04B, 0xD01C, 0xD02C, 0xD03C};
int number = lookupTable.indexOf(DATA);
where DATA are the error codes from an device's
sadly enough this code wont work. as far as I know indexOf works only with an String.
this script returns an error on the compiler ( which is of non-class type "byte" )