• 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
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.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

  • 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
  • IBM Taps Nvidia GPUs For AI-Turbocharged Data Mart
  • Izzi Partners With Capricorn For IBM i Services And Bluehouse For Software Peddling
  • IBM i PTF Guide, Volume 28, Number 12
  • What Is Your Plan For Offsite Data Protection?
  • What Is Threatening IBM i Security Now

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