• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Value An Expression? *YES!

    July 24, 2013 Ted Holt

    I find it ironic that the most commonly used CL command suffers from an annoying (if not aggravating) limitation that does not afflict many less-used commands. Fortunately, the commands you and I write do not have to have this limitation.

    The command to which I refer is CALL. The limitation is that the parameters must be literals or variables, never expressions. To see what I mean, look at this CALL command.

    call   somepgm   parm(%sst(&Data 5 4))
    

    Doesn’t that make sense to you? The first parameter consists of bytes 5 through 8 of a variable named &DATA. The compiler complains, expressing its displeasure by means of diagnostic message CPD0105 (Built-in function not allowed for parameter PARM).

    To make this code work, you must declare another variable, copy the required four bytes into it, and use that variable in the parameter list.

    dcl      &SomeVar    *char    4
                           
    chgvar   &SomeVar     %sst(&Data 5 4)
    
    call     somepgm parm(&SomeVar)
    

    I’m sure there is a good reason for this limitation. I just don’t know what that good reason is.

    Consider two commands, DOTHIS and DOTHAT.

    CMD        PROMPT('Do this')
    PARM       KWD(RATE) TYPE(*CHAR) LEN(4) RSTD(*YES) +
                 VALUES(SLOW FAST) MIN(1) EXPR(*YES) +
                 PROMPT('How fast?')
    PARM       KWD(TIMES) TYPE(*INT2) MIN(1) EXPR(*YES) +
                 PROMPT('How many times?')
    
    
    CMD        PROMPT('Do that')
    PARM       KWD(INTERVAL) TYPE(*DEC) LEN(7 0) MIN(1) +
                 PROMPT('How frequently?')
    PARM       KWD(UNIT) TYPE(*CHAR) LEN(9) RSTD(*YES) +
                 VALUES(HOURS MINUTES SECONDS DAYS MONTHS +
                 YEARS DECADES CENTURIES MILLENNIA EONS) +
                 PROMPT('Unit of time')
    

    They are similar in that both of them accept two parameters: a character parameter and a numeric parameter. But they differ in that the parameters of DOTHIS include the keyword EXPR(*YES). A parameter that is defined to allow expressions may include concatenation operators, as well as built-in functions %SUBSTRING (%SST), %BIN, %TRIM, %TRIML, %TRIMR, %SCAN, and %CHECK.

    Now look at a program that calls these commands.

       dcl   &Settings    *char    48
       dcl   &Interval    *char     3
       dcl   &Units       *char     9
    
       RtvDtaAra   dtaara(DoDahData (1 48)) rtnvar(&Settings)
    
       DoThis      rate(%sst(&Settings 1 4)) times(%sst(&Settings 5 3))
    
       ChgVar      &Units     %sst(&Settings 11 9)
       ChgVar      &Interval  %sst(&Settings 20 3)
    
       DoThat      interval(&Interval) unit(&Units)
    

    Since DOTHAT does not allow expressions, the programmer had to declare and load two variables, &INTERVAL and &UNITS. DOTHIS requires no such variables.

    For this reason, I make it a habit to include EXPR(*YES) when defining command parameters.



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Maxava

    Migrate IBM i with Confidence

    Tired of costly and risky migrations? Maxava Migrate Live minimizes disruption with seamless transitions.

    Upgrading to Power10, Power11, or cloud hosted system, Maxava has you covered!

    Book A Consultation Today

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Profound Logic Software:  Now On-Demand: Take IBM i EVERYWHERE With Mobile Apps!
    System i Developer:  Upgrade your skills at the RPG & DB2 Summit in Minneapolis, Oct 15-17.
    Abacus Solutions:  Qualified IBM i users eligible for free pair of running shoes

    More IT Jungle Resources:

    System i PTF Guide: Weekly PTF Updates
    IBM i Events Calendar: National Conferences, Local Events, and Webinars
    Breaking News: News Hot Off The Press
    TPM @ The Reg: More News From ITJ EIC Timothy Prickett Morgan

    Working Vacations On The Rise For Americans BlueFountain Delivers a Modern Looking WMS for IBM i

    Leave a Reply Cancel reply

Volume 13, Number 14 -- July 24, 2013
THIS ISSUE SPONSORED BY:

WorksRight Software
SEQUEL Software
ASNA

Table of Contents

  • Control The Flow Of Stored Procedure Result Sets
  • Value An Expression? *YES!
  • Automatically Answering IBM i Unable To Allocate Record Messages

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • IBM Pulls The Curtain Back A Smidge On Project Bob
  • IBM Just Killed Merlin. Here’s Why
  • Guru: Playing Sounds From An RPG Program
  • A Bit More Insight Into IBM’s “Spyre” AI Accelerator For Power
  • IBM i PTF Guide, Volume 27, Number 42
  • What You Will Find In IBM i 7.6 TR1 and IBM i 7.5 TR7
  • Three Things For IBM i Shops To Consider About DevSecOps
  • Big Blue Converges IBM i RPG And System Z COBOL Code Assistants Into “Project Bob”
  • As I See It: Retirement Challenges
  • IBM i PTF Guide, Volume 27, Number 41

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle