• 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
    Computer Keyes

    Fax Directly from your IBM i

    KeyesFax is a full function automated IBM i fax system. Spooled files are burst by fax number and auto transmitted with overlays.  It combines both a send and receive facsimile processing system with a complete image package.

    The fax software will edit, send, receive, display, print, and track fax documents or images using any standard IBM i without additional expensive hardware, software or subscriptions.

    Computer Keyes has been developing Software Solutions since 1978!

    www.computerkeyes.com

    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

    Control The Flow Of Stored Procedure Result Sets Automatically Answering IBM i Unable To Allocate Record Messages

    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

  • Bob 1.0 Users Bugged By Lack Of One Feature
  • Here Come The AI-Based Code Modernization Offerings
  • Guru: Cohesion First – What A Procedure Should Be Responsible For
  • IBM Offers Trade-Ins On Storage To Grease The Upgrade Skids
  • IBM i PTF Guide, Volume 28, Number 14
  • What IBM i Ideas Are Cooking In IBM’s Ideas Portal?
  • Early Bob Excels In Medhost IBM i Tryout
  • Counting The Cost Of AI Inference – And Projecting It Far Out
  • IBM i PTF Guide, Volume 28, Number 13
  • The Next Generation Of IBM i Talent in GenAI Action

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