ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Help on CL programming

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help on CL programming

    Hi all

    Can anybody help me with program logic for adding the sum of a field from a PF file
    I did use RCVF command to read the file , but i wan unable to read the next record and the pointer is moving to last record instead of last record
    I used the Breaker "Goto" in the programming . But still it is moving to last record

    A sanple
    Code:
    0001.00 PGM                                            
    0002.00 DCL VAR(&TBAL) TYPE(*DEC) LEN(12 2)            
    0003.00 DCL VAR(&CBAL) TYPE(*CHAR) LEN(12)             
    0004.00 DCLF  FILE(BANKAC)  RCDFMT()                   
    0005.00 READNEXT:RCVF                                  
    0006.00 MONMSG MSGID(CPF0864) EXEC(GOTO X)             
    0007.00 /* AR(&TBAL) VALUE( &BAL)     */               
    0008.00 /*     MSGID(CPF0864) EXEC(GOTO END)          *
    0009.00 CHGVAR VAR(&TBAL) VALUE( &BAL)                 
    0010.00 CHGVAR VAR(&TBAL) VALUE(&TBAL +&BAL)           
    0011.00 GOTO READNEXT                                  
    0012.00 X:CHGVAR VAR(&CBAL) VALUE(&TBAL)               
    0013.00 SNDPGMMSG MSG(&CBAL)                           
    0014.00 ENDPGM

  • #2
    Re: Help on CL programming

    have you actually tried to review your code?
    Code:
    CHGVAR VAR(&TBAL) VALUE( &BAL)   /* set total balance = to current balance */              
    CHGVAR VAR(&TBAL) VALUE(&TBAL +&BAL) /* add current balance to total balance */
    just a guess but wouldn't you just add to the total balance instead of just setting total balance = current balance + current balance???
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment

    Working...
    X