bscottkelley wrote: > I have a number of #define commands in my current code. I now need > to provide for two or more possible definitions, depending upon the > value of a particular eeprom byte. > > For example, > if eeprom byte #0x22 =0, define "Hysteresis" as 15 > if eeprom byte #0x22 =1, define "Hysteresis" as 11 > > It seems to me that I have seen a one line function that would work > for this where the "selection byte" would indicate a location in a > following list of numbers, something kinda like this: > > temp = I2C_EEPROM_read(0x00, 0x22); > #define Hysteresis (temp: 15,11,9) > > Sorry if this is a 'no-brainer', but I'm really rusty & I'm just not > coming up with anything in my C books... > > Thx > Scott Kelley
Looks like you are trying to use #define (a compile-time preprocessor directive) with something that you expect to work during runtime. Use a standard if-else if-else set of statements: if (temp == 0) Hysteresis = 15; else if (temp == 1) Hysteresis = 11; else Hysteresis = 9; -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
