openedgeprogress-4gl4gl

How to create Pascal?


I am very difficult to display all the output results.

this code.

DEF VAR INPUTAN AS INTEGER. DEF VAR i AS INTEGER. DEF VAR j AS INTEGER. DEF VAR a AS INTEGER. DEF VAR rows AS INT. DEF VAR pascal AS CHAR FORMAT "x(25)".

SET INPUTAN. a = 1.

REPEAT i = 0 TO INPUTAN: rows = i. DISPLAY rows. REPEAT j = 0 TO i :

IF j = 0 OR j = i THEN DO: a = 1. END. ELSE

a = a * (i + 1 - j) / j.

pascal = STRING(a).

display a.

END. END.


Solution

  • DEF VAR INPUTAN AS INTEGER. 
    DEF VAR i AS INTEGER. 
    DEF VAR j AS INTEGER. 
    DEF VAR a AS INTEGER. 
    DEF VAR rows AS INT. 
    DEF VAR pascal AS CHAR.
    
    SET INPUTAN. 
    a = 1.
    
    REPEAT i = 0 TO INPUTAN:
        
     rows = i. 
     /*DISPLAY rows. */
     
     REPEAT j = 0 TO i :
    
       IF j = 0 OR j = i THEN DO: 
          a = 1. 
       END. 
       ELSE
          a = a * (i + 1 - j) / j.
    
       IF j = 0 THEN
          pascal = pascal + FILL("   ", INPUTAN - i).
       pascal = pascal + STRING(a) + "   ".
    
       IF j = i THEN
          pascal = pascal + CHR(13).
    
     /*  display a.*/
    
     END. 
    
    END.
    
    MESSAGE pascal
       VIEW-AS ALERT-BOX INFO BUTTONS OK.