It's been what, 6 or 7 years since I wrote a key input routine in C. I vaguely remember using the SWITCH statement in that routine. I agree that a good compiler could optimize the IF/THEN statements, but I would get a bit concerned at what point relationship comparisons are allowed. Two elements, as my y and x example, are not too difficult but what if someone wanted u, v, x, y, z all in one CASE relationship? That gets to be a hell of a lot of nesting.
Just for the y, x example, I imagine a C translation would look something like this...
I don't have an editor, and bracket languages drive me a bit buggy, but I would think this is close to what would be needed to work out a template for conversion.
Pete
Just for the y, x example, I imagine a C translation would look something like this...
Code: (Select All)
if(y > 0)
{
if(x > 0)
{
foo(do something);
}
if(x = 0)
{
foo(do something);
}
if(x < 0)
{
foo(do something);
}
}
else if(y = 0)
{
if(x > 0)
{
foo(do something);
}
if(x = 0)
{
foo(do something);
}
if(x < 0)
{
foo(do something);
}
}
else if(y < 0)
{
if(x > 0)
{
foo(do something);
}
if(x = 0)
{
foo(do something);
}
if(x < 0)
{
foo(do something);
}
}
I don't have an editor, and bracket languages drive me a bit buggy, but I would think this is close to what would be needed to work out a template for conversion.
Pete