IB - Developer Center    Forums  Hop To Forum Categories  FOCUS/WebFOCUS    Basic DM question
Go
New
Search
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
<Pietro De Santis>
Posted
Hi,

Here's a vry basic DM problem I can't seem to get around.

This is a simplified piece of code that fails with the following error:

(FOC295) A VALUE IS MISSING FOR: TEST3



-DEFAULT &LEVEL = 3;

-SET &MAX_LEVEL = 2;

-SET &TEST1 = 'APPLE';
-SET &TEST2 = 'ORANGE';

-SET &FRUIT = IF &LEVEL GT &MAX_LEVEL THEN '' ELSE &TEST.&LEVEL;

-TYPE &FRUIT

Don't tell me I have to use clumsy GOTO's and labels to avoid this problem.

Any ideas?

Thanks,

Pietro.

This message has been edited. Last edited by: <Mabel>,
 
Reply With QuoteEdit or Delete MessageReport This Post
<Vipul>
Posted
Give me a piece of advice? How do you write a moderately complex piece of focus code without GOTOs and Labels.

Vipul
 
Reply With QuoteEdit or Delete MessageReport This Post
<WFUser>
Posted
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
 
Reply With QuoteEdit or Delete MessageReport This Post
Platinum Member
Posted Hide Post
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>,
 
Posts: 164 | Location: Madrid, Spain | Registered: May 09, 2003Reply With QuoteEdit or Delete MessageReport This Post
<Pietro De Santis>
Posted
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.
 
Reply With QuoteEdit or Delete MessageReport This Post
Platinum Member
Posted Hide Post
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>,
 
Posts: 164 | Location: Madrid, Spain | Registered: May 09, 2003Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

IB - Developer Center    Forums  Hop To Forum Categories  FOCUS/WebFOCUS    Basic DM question

Copyright © 1996-2008 Information Builders, leaders in enterprise business intelligence.