CL 400 Day 1

  • Upload
    samk5a5

  • View
    222

  • Download
    1

Embed Size (px)

Citation preview

  • 8/10/2019 CL 400 Day 1

    1/17

    CL/400(Control Language/400)

  • 8/10/2019 CL 400 Day 1

    2/17

    CL/400

    Control Language (CL) is the primary

    interface to the Operating System.

  • 8/10/2019 CL 400 Day 1

    3/17

    Introduction to CL/400

    CL is a primary interface to the operating

    system.

    CL can be used as a programminglanguage,allowing common tasks to be

    automated.

  • 8/10/2019 CL 400 Day 1

    4/17

    Disadvantages of CL programs

    CL programs cannot UPDATE,

    DELETE or WRITE records into a

    database file as other HLL(high level

    language) programs like

    RPG/400,COBOL/400 etc can do.

  • 8/10/2019 CL 400 Day 1

    5/17

    CL Program Structure

  • 8/10/2019 CL 400 Day 1

    6/17

    Declare a CL Variable(DCL)

    DCL VAR(&NAME) TYPE( ) LEN( ) VALUE( )

    TYPE( ) LEN( ) VALUE( )

    *DEC default (15 5) default(0)

    max (15 9)

    *CHAR default (32) default(b)max (9999)

    *LGL 1 default(0)

  • 8/10/2019 CL 400 Day 1

    7/17

    Examples for declaring a CL

    variable

    (1) DCL &A *LGL VALUE(1)

    (2) DCL &B *CHAR 5 ABCDb

    (3) DCL &C *DEC (6 2) 0543.21

  • 8/10/2019 CL 400 Day 1

    8/17

    CHGVAR-Arithmetic Calculations

    +

    CHGVAR VAR(CL-variable) VALUE(operand - operand)

    *

    /

    CHGVAR VAR(&AMT) VALUE(-37.2)

    CHGVAR VAR(&COUNT) VALUE(&COUNT + 1)

    CHGVAR &AMT ((&PRICE - &DISCOUNT) * &QTY)

  • 8/10/2019 CL 400 Day 1

    9/17

    Relational and Logical Expressions

    Expression: (Operand Operator Operand)

    Result of a relational or logical expression: 1 True

    or 0 False

    Operands: Constant, Variable, Another Expression

    Operators Description

    < *LT Less Than

    = *EQ Equal to

    > *GT Greater than

  • 8/10/2019 CL 400 Day 1

    10/17

    Relational and Logical Expressions

    ..Cont

    Operators Description

    *NG Not Greater than

    >= *GE Greater than or equal to

    != *NE Not Equal to

    & *AND True if both operands are 1

    | *OR True if both or either operand is 1

    ! *NOT

  • 8/10/2019 CL 400 Day 1

    11/17

    IF Examples

    1.IF COND(&RESP *EQ 5) THEN(CALL PGM(CUSINQ))

    IF (&RESP *EQ 5) CALL CUSINQ

    2.IF COND(&AMT *GT 10000) THEN(CALL PGMBIG)

    ELSE CMD(CALL PGMSMALL)

    3.IF (&A *NE &B) RETURN

    IF (&A= &B)

    ELSE RETURN

    4.IF &IN03 RETURN

  • 8/10/2019 CL 400 Day 1

    12/17

    Nested IF Statements

    KEYWORD FORM:

    IF COND(&RESP=1) THEN(IF COND(&A=5) THEN(IF +COND(&B=N) THEN(CALL PGM(PGMA))))

    POSITIONAL FORM:

    IF (&RESP=1) IF(&A=5) IF(&B=N) CALL PGMADO,ENDDO FORM:

    IF COND(&RESP=1) THEN(DO)

    IF COND(&A=5) THEN(DO)

    IF COND(&B=N) THEN(DO)

    CALL PGMA

    ENDDO

    ENDDO

    ENDDO

    d/ d/

  • 8/10/2019 CL 400 Day 1

    13/17

    PGMB and/or PGMC and/or

    PGMD

    IF COND(&A=&B)

    THEN(CALL PGM(PGMB))

    IF COND(&A=&C)THEN(CALL PGM(PGMC))

    IF COND(&A=&D)

    THEN(CALL(PGMD))

    T

    T

    T

    F

    F

    F

  • 8/10/2019 CL 400 Day 1

    14/17

    PGMB or PGMC or PGMD.

    &A=&B

    &A=&C

    &A=&D

    PGMB

    PGMC

    PGMD

    T

    T

    T

    F

    F

    F

    PGMB PGMC PGMD

  • 8/10/2019 CL 400 Day 1

    15/17

    PGMB or PGMC or PGMD

    ..cont

    IF COND(&A=&B) THEN(CALL PGM(PGMB))

    ELSE CMD(IF COND(&A=&C) THEN(CALLPGM(PGMC)))

    ELSE CMD(IF COND(&A=&D) THEN(CALL

    PGM(PGMD)))

  • 8/10/2019 CL 400 Day 1

    16/17

    Do Group

    IF COND(&A *GT 100) THEN(DO)

    CALL PGM1

    CALL PGM2

    ENDDO

    ELSE CMD(DO)

    CALL PGM3

    CALL PGM4

    ENDDO

    CALL PGM5

  • 8/10/2019 CL 400 Day 1

    17/17

    Branching within a program-GOTO

    PGM

    START: SNDRCVF RCDFMT(MENU)

    .

    .

    IF (&OPTION=12) GOTO CMDLBL(END)

    .

    .

    GOTO START

    END : ENDPGM