On 2020-04-25, at 08:38:08, Joel C. Ewing wrote:
> 
> Always curious about compatibility issues, copied program and pasted
> into gedit on Fedora Linux, put a leading
> "#!/usr/bin/rexx"  and tried to run with oorexx on linux. Only code
> issues found:
> (1)Not really a code issue, but had to to run through dos2unix to
> convert Windows CR LF end-of-line to unix LF end of line or don't even
> get past the unix shebang 1st line -- can't find program "rexx" with CR
> appended to name.
> (2)Only special characters allowed in variable names in oorexx are !, ?,
> and _, so "#DAYS" is not a valid variable name and produced an error
> message about unexpected "#".  Find-replace-all "#DAYS" to "NR_DAYS"
> 
> That's all it took to get it to run.
>  
I did not copy-and-paste; I downloaded the attachment,
which appears to be UTF-8.

For Regina, Regina.pdf says: 3.1.1.1 Negators
    ... Regina supports the following characters as negators:
    ...
    ¬ Logical Not
Copy-and-paste from the pdf gives me:
    931 $ printf ¬ | od -tx1
    0000000    c2  ac        
... the UTF-8 "¬".  But when I paste it into an EXEC, Regina says:
     say 2+2 ¬= 4
Error 13 running "/Users/paulgilm/bin/rxx", line 2: Invalid character in program
Error 13.1: Invalid character in program "('c2'X)"

I much prefer when the examples in the Ref. actually work.  Does
ooRexx accept UTF-8 "¬"?

I went on and did something fancy.  Attached.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
/*********************************************************************/
/* Calculate Biorhythm Program                                       */
/*                                                                   */
/* Based on theory that physical, emotional and intellectual cycles  */
/* vary from 1.00 to -1.00 every 23, 28 and 33 days from the date of */
/* birth onwards - where positive scores are "up days" and negative  */
/* scores indicate "down days"                                       */
/*                                                                   */
/* Cycles:                                                           */
/* - Physical     : 23 days                                          */
/* - Emotional    : 28 days                                          */
/* - Intellectual : 33 days                                          */
/*                                                                   */
/* Paramters:                                                        */
/* - DATE1          : date of birth                                  */
/* - DATE2          : current date                                   */
/* - DEBUG          : to debug this thing, if required               */
/*                                                                   */
/*                                                                   */
/* 2020/04/04 Chris Poncelet                                         */
/* 2020/04/25 Paul Gilmartin                                         */
/* - Use ASCII operators                                             */
/* - Use Rexx DATE function                                          */
/* - Streamline modulo arithmetic                                    */
/* - Use specialized discrete sin() calculation.                     */
/*********************************************************************/
SIGNAL ON NOVALUE
ARG DATE1 DATE2 DEBUG

IF ABBREV(DEBUG,'D') = 1 THEN ,
  TRACE I

NUMERIC DIGITS 8  /* yyyymmdd  */

/* CHECK THAT START DATE1 IS EARLIER THAN END DATE DATE2 */
IF DATE2 < DATE1 THEN ,
  DO
  SAY 'Start date 'DATE1' must be no later than end date 'DATE2'.'
  SAY ' '
  SAY 'Please try again.'
  SAY ' '
  CALL EXIT
  END /* IF */

/* CHECK THAT DATE1 DATA IS VALID AND WHETHER LEAP YEAR ETC. */
Q = DATE1
CALL CHECK_DATE

/* CONVERT DATE1 YEARS, MONTHS, DAYS TO FACTOR */
FACTOR1 = DATE( 'Base', YEAR || MONTH || DAY, 'Standard' )

/* CALCULATE DAY OF THE WEEK FOR DATE1 */
DAYS = '(Monday) (Tuesday) (Wednesday) (Thursday) (Friday) (Saturday) (Sunday)'
DW1 = WORD( DAYS, FACTOR1 // 7 + 1 )
SAY 'We have year = 'YEAR', month = 'MONTH', day = 'DAY' 'DW1
SAY ' '

/* CHECK THAT DATE2 DATA IS VALID AND WHETHER LEAP YEAR ETC. */
Q = DATE2
CALL CHECK_DATE

/* CONVERT DATE2 YEARS, MONTHS, DAYS TO FACTOR */
FACTOR2 = DATE( 'Base', YEAR || MONTH || DAY, 'Standard' )

/* CALCULATE DAY OF THE WEEK FOR DATE2 */
DW2 = WORD( DAYS, FACTOR2 // 7 + 1 )
SAY 'We have year = 'YEAR', month = 'MONTH', day = 'DAY' 'DW2
SAY ' '


#DAYS = FACTOR2 - FACTOR1
SAY 'Elapsed number of days is '#DAYS
SAY ' '


/* NOW GET PHYSICAL, EMOTIONAL AND INTELLECTUAL CYCLE SCORES */
P =  SINES( 23 #DAYS )
SAY 'Physical      :'FORMAT(P,3,2,0)
SAY

E =  SINES( 28 #DAYS )
SAY 'Emotional     :'FORMAT(E,3,2,0)
SAY

I =  SINES( 33 #DAYS )
SAY 'Intellectual  :'FORMAT(I,3,2,0)
SAY

AV = (P+E+I)/3
SAY 'Average       :'FORMAT(AV,3,2,0)
SAY

CALL EXIT


/*********************************************************************/
/* SUBROUTINES                                                       */
/*********************************************************************/


CHECK_DATE:
/* CHECK THAT DATE IS NUMERIC AND IN THE CORRECT FORMAT */
/* CHECK THAT DATE IS WITHIN VALID RANGES */
  YEAR  = SUBSTR(Q,1,4)
  MONTH = SUBSTR(Q,6,2)
  DAY   = SUBSTR(Q,8,2)
IF 0 ,
|  LENGTH(Q) <> 9 ,
|  DATATYPE( YEAR || MONTH || DAY, 'W' ) <> 1 ,
|  SUBSTR(Q,5,1) <> '.' ,
  THEN DO
  SAY '"'Q'"' 'must be numeric in the form "yyyy.mmdd"'
  SAY ' '
  SAY 'Please try again'
  SAY ' '
  CALL EXIT
  END /* IF */
RETURN

/* Use finite difference equation to generate table of sines.  */
SINES: PROCEDURE
    PARSE ARG A1 DD
    SECTS = 4 * A1
    DELTA = 6.3 / SECTS  /* Guess.  */
    X = 1
    DO TRY = 1 TO 3
        Y = 0
        DO SEG = 0 TO SECTS -1
            STAB.SEG = Y
            X = X - Y * DELTA
            Y = Y + X * DELTA
            END SEG
        X = X / STAB.A1   /* Normalize sin( π / 2 )  */
        DELTA = DELTA - Y / SECTS  /* Refine Guess.  */
        END TRY
    DD = DD // A1 * 4
    RETURN( STAB.DD )

EXIT:
  EXIT 0

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

-- gil


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to