Register | Login
Forum Index > Requests and Feedback > switch statement
Author Message
Pages: 1
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[141] switch statement - posted: 2011-10-26 18:50:54

does Ziron support switch statement ? , if not can it be supported with coming release.

thanks.

Emil.


http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[145] - posted: 2011-10-26 19:29:36
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.

smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[194] - posted: 2011-10-29 17:20:00
i've just finished implementing the basic case/switch statement.

Code:
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

Code:
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 smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[195] - posted: 2011-10-29 17:59:51

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
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[196] - posted: 2011-10-29 18:12:01
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 smile

right now I'm working on some other features smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[197] - posted: 2011-10-29 18:20:27

ok , some features without full support are better than no features at all.



http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[207] - posted: 2011-10-29 23:06:12

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
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[208] - posted: 2011-10-29 23:07:42
as is a too generic keyword for the way my case routine works

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 1 user(s) online. 0 member(s) and 1 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd