|
Go
![]() |
New
![]() |
Search
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
| <Vipul>
|
Give me a piece of advice? How do you write a moderately complex piece of focus code without GOTOs and Labels.
Vipul |
||
|
| <WFUser>
|
Do you have anything against -REPEAT?
-DEFAULT &LEVEL = 3; -SET &MAX_LEVEL = 2; -REPEAT STARTIT &MAX_LEVEL TIMES -DEFAULT &TEST.&LEVEL = ' ' -STARTIT -SET &TEST1 = 'APPLE'; -SET &TEST2 = 'ORANGE'; -SET &FRUIT = IF &LEVEL GT &MAX_LEVEL THEN '' ELSE &TEST.&LEVEL; -TYPE &FRUIT |
||
|
|
Platinum Member |
Easier. Set a default value to &TEST.&LEVEL independently of &LEVEL value.
-DEFAULT &LEVEL = 3; -SET &MAX_LEVEL = 2; -SET &TEST1 = 'APPLE'; -SET &TEST2 = 'ORANGE'; -DEFAULT &TEST.&LEVEL = ' ' ; -SET &FRUIT = IF &LEVEL GT &MAX_LEVEL THEN ' ' ELSE &TEST.&LEVEL; -TYPE Fruit - &FRUIT[/code]Regards, Mikel This message has been edited. Last edited by: <Mabel>, |
|||
|
| <Pietro De Santis>
|
Nothing against -REPEAT, in fact I love it.
Nothing against -DEFAULT either. Just assumed DM would stop parsing the line after the first condition becoming true, silly me. |
||
|
|
Platinum Member |
Thinking a little more, why do we need -IF?
-DEFAULT &LEVEL = 2 ; -SET &MAX_LEVEL = 2; -SET &TEST1 = 'APPLE'; -SET &TEST2 = 'ORANGE'; -DEFAULT &TEST.&LEVEL = ' ' ; -SET &FRUIT = &TEST.&LEVEL ; -TYPE Fruit - &FRUIT And finally, I think that a simple DECODE is the best solution... -DEFAULT &LEVEL = 3 ; -SET &FRUIT = DECODE &LEVEL (1 'APPLE' 2 'ORANGE' ELSE ' ') ; -TYPE Fruit - &FRUIT Regards, Mikel This message has been edited. Last edited by: <Mabel>, |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

