switch statement
does Ziron support switch statement ? , if not can it be supported with coming release.
thanks.
Emil.
http://www.freewebs.com/ogremagic/index.htm
A community discussion post from the original code:zIRON forum.
does Ziron support switch statement ? , if not can it be supported with coming release.
thanks.
Emil.
http://www.freewebs.com/ogremagic/index.htm
for now, Ziron does not support a switch statement, however it is already on my long to-do list, so since you have requested it, i will move it to my priority list and will see when i can get it done.
:)
i've just finished implementing the basic case/switch statement.
eax = 15;
case (eax) {
state 1:
print('test 1\r\n');
break;
state 5:
print('test 5 and ');
state 10:
print('test 10\r\n');
break;
default:
print('Value not found: ', eax:int, '; decrementing value\r\n');
eax--;
}
notice that if default does not contain a break it will run in a loop checking for the value: this is not a bug, it is intented for such usage as above.
so when the default should exit the case, it should contain also a break
eax = 15;
case (eax) {
state 1:
print('test 1\r\n');
break;
state 5:
print('test 5 and ');
state 10:
print('test 10\r\n');
break;
default:
print('Value not found: ', eax:int, '\r\n');
break;
}
for now, case is very minimal it supports only register parameter and numbers states, this will be extended as i further develop Ziron :)
great and well done, Mr. OverHerz.
i have something , if we do not put default statement what will be the behavior of case block?
second as you have mentioned , it must support not registers and numbers only , so we can use
a variable or expirations etc....
http://www.freewebs.com/ogremagic/index.htm
without a default, the case statement will just be exited if there is no available state, and yes i will need to add further support for variables and such. But all in good time :)
right now I'm working on some other features :)
ok , some features without full support are better than no features at all.
http://www.freewebs.com/ogremagic/index.htm
Hi OverHertz.
what do you think if you replace 'state' keyword to 'As' in case block , i think it will
be more readable ?
http://www.freewebs.com/ogremagic/index.htm
as is a too generic keyword for the way my case routine works