View previous topic :: View next topic
|
Author |
Message |
REGGIE2028
New User
Joined: 08 Jul 2021 Posts: 3 Location: USA
|
|
|
|
Trying to figure out how to fix this. Thanks!
REXX:
Code: |
/* REXX CLIST */
YESTERDAY = DATE('BASE') - 1
MESSAGE1 = 'YESTERDAY-BASE IS: '||YESTERDAY
SAY MESSAGE1
YESTERDAY-CONVERTED = DATE('USA',YESTERDAY,'BASE')
MESSAGE2 = 'YESTERDAY-CONVERTED IS: '||YESTERDAY-CONVERTED
SAY MESSAGE2
|
Output:
YESTERDAY-BASE IS: 737977
5 +++ YESTERDAY-CONVERTED = DATE('USA',YESTERDAY,'BASE')
IRX0041I Error running VIL02435, line 5: Bad arithmetic conversion |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1134 Location: Bamberg, Germany
|
|
|
|
Code it like a Pro
Code: |
YESTERDAY = DATE('B') - 1
MESSAGE1 = 'YESTERDAY-BASE IS: '!!YESTERDAY
SAY MESSAGE1
YESTERDAY_CONVERTED = DATE('U',YESTERDAY,'B')
MESSAGE2 = 'YESTERDAY_CONVERTED IS: '!!YESTERDAY_CONVERTED
SAY MESSAGE2 |
|
|
Back to top |
|
 |
REGGIE2028
New User
Joined: 08 Jul 2021 Posts: 3 Location: USA
|
|
|
|
Thanks, I'm good. I'll use this solution below I just stumbled upon:
Code: |
YESTERDAY1 = DATE('USA',DATE(B)-1,'B')
SAY 'EX1 = '||YESTERDAY1
|
Output
EX1 = 07/07/21 |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1134 Location: Bamberg, Germany
|
|
|
|
You should chose whether you want to use full names or abbreviations for date specifics. Here you mix Usa and B(ase) together. Other than that, variables shall not have a 'minus' in the name. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 1875 Location: USA
|
|
|
|
When moving some code (or some ideas) from COBOL environment to REXX environment:
1) it is a very bad idea to use the ‘-‘ (minus sign) as part of any entity identification name; the result may be either syntax error, or unpredictable “bad arithmetic”, etc.
2) it is just a bad idea to use uppercase-only notation for either entity names, or REXX keywords themselves; it’s getting very, very hard for others (as well for yourself) to read and to understand the uppercase REXX code, especially when that one is longer than 3 lines of code. A reasonable mixed case notation is highly recommended (but ignored by many environmental migrants)
Surprisingly, in opposite to the minus sign, in REXX new characters like ‘!’, ‘?’, and others are allowed as part of entity names (variables, functions, labels…). Sometimes it looks very convenient:
Code: |
balanceIsValid? = (client.balanceAmount > transaction.requestedValue)
. . . . . . . .
If balanceIsValid? Then Do
. . . . . . . . . .
End
Else Do
. . . . . . . . . .
End |
|
|
Back to top |
|
 |
Pedro
Global Moderator

Joined: 01 Sep 2006 Posts: 2453 Location: Silicon Valley
|
|
|
|
I disagree with your comment:
update: I originally posted this as humor, but it really annoys me for some reason. It is not a CLIST. CLISTs are a different language. |
|
Back to top |
|
 |
REGGIE2028
New User
Joined: 08 Jul 2021 Posts: 3 Location: USA
|
|
|
|
All, I'm good. The solution I posted is working fine. The minus is not a part of my variable. It's a subtraction operation to go back one day. Get Yesterdays date. Ok yes my comments are not perfect yet. Whereas this is only a testbed to get things right prior to the big dive into code. I needed a solution that would account for month end/First of month situations. This code does exactly that and is simple to understand and use. I keep my vars within standards. The right-side of = I have nothing but built-in functions and math operations. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 1875 Location: USA
|
|
|
|
REGGIE2028 wrote: |
The minus is not a part of my variable. It's a subtraction operation to go back one day. Get Yesterdays date. |
Please, take a closer look at your own original post:
Code: |
/* REXX CLIST */
YESTERDAY = DATE('BASE') - 1
MESSAGE1 = 'YESTERDAY-BASE IS: '||YESTERDAY
SAY MESSAGE1
YESTERDAY-CONVERTED = DATE('USA',YESTERDAY,'BASE')
MESSAGE2 = 'YESTERDAY-CONVERTED IS: '||YESTERDAY-CONVERTED
SAY MESSAGE2
|
It is definitely the subtraction operation between variables YESTERDAY, and CONVERTED. This is condemned to fail immediately…
REGGIE2028 wrote: |
This code does exactly that and is simple to understand and use. I keep my vars within standards. |
1) The standards blindly copied from COBOL do not work well in REXX. BTW, did you know that posting any message in uppercase is strictly prohibited at this forum? Try to guess, why? Because it is very difficult to read any text in caps-only!
2) Such code is “simple to understand and use” as long as its size remains within one page. Later this style of coding shall inevitably lead to the problems much worse than current problems with the getting obsolete COBOL code. |
|
Back to top |
|
 |
|