Last week I was coding a dateselection progam. (between 2 dates)
The database used a 8 numeric field in the form of YYYYMMDD.
The Disply had 3 numeric fields with EDTCDE(4)
C1day 2,0
C1month 2,0
C1year 4,0
The user could make the fields "looks" blank because I used EDTCDE(4). ( I don't want to show them zero !! )
That was ok, but what if he did: __ __ 2008 ? The setll and a READP ! on the db works ! 20080000
But the user may expect the result from the year 2008 to !
So, to attend them, I code the zero's so would see _1 _1 2008 instead !
But now I have coded something like this:
If C1day = *zero
Eval C1day = 1
Endif
If C1month = *zero
Eval C1month = 1
Endif
and because I have 2 selectiondates
If C2day = *zero
Eval C2day = 1
Endif
If C2month = *zero
Eval C2month = 1
Endif
I don't like that kind of code, so I was thinking,
could I program the "IF/../Endif" on 1 line ?
Then my idea hit me, I rememberd that: cos(0) = 1 !
so, instead if using the 3 line IF/../Endifthen I could code:
eval C1day = cos(C1day)
(W)That was I thinking last weekend ? !
But than I remembered the wise words of my teacher !
DON'T BE SMART !
But the cos(x) works ! Read: High-Level Match Functions for RPG
How would you have done it ?
The database used a 8 numeric field in the form of YYYYMMDD.
The Disply had 3 numeric fields with EDTCDE(4)
C1day 2,0
C1month 2,0
C1year 4,0
The user could make the fields "looks" blank because I used EDTCDE(4). ( I don't want to show them zero !! )
That was ok, but what if he did: __ __ 2008 ? The setll and a READP ! on the db works ! 20080000
But the user may expect the result from the year 2008 to !
So, to attend them, I code the zero's so would see _1 _1 2008 instead !
But now I have coded something like this:
If C1day = *zero
Eval C1day = 1
Endif
If C1month = *zero
Eval C1month = 1
Endif
and because I have 2 selectiondates
If C2day = *zero
Eval C2day = 1
Endif
If C2month = *zero
Eval C2month = 1
Endif
I don't like that kind of code, so I was thinking,
could I program the "IF/../Endif" on 1 line ?
Then my idea hit me, I rememberd that: cos(0) = 1 !
so, instead if using the 3 line IF/../Endifthen I could code:
eval C1day = cos(C1day)
(W)That was I thinking last weekend ? !
But than I remembered the wise words of my teacher !
DON'T BE SMART !
But the cos(x) works ! Read: High-Level Match Functions for RPG
How would you have done it ?



The user is no more KING !
Comment