adding 'value' to your prot...2

Upload: nairarung

Post on 01-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Adding 'Value' to Your Prot...2

    1/6

  • 8/9/2019 Adding 'Value' to Your Prot...2

    2/6

  • 8/9/2019 Adding 'Value' to Your Prot...2

    3/6

    Business StrategyCompetitive AdvantageConsolidationExecutive PerspectiveGreen ITMigrationOpen SourceROI

    InfrastructureBlades

    StorageSystems Management

    Case StudiesDistributionHealthcareManufacturingServices

    Web 2.0CloudSocial Media

    TrendsCollaboration

    IBM AnnouncementsIBM ResearchOpen SourceSocial MediaWhat's New

    Product News

    AIXMAINFRAMEPOWER

    NewslettersAbout Us

    SubscribeCurrent IssueArchive

    IBM i ALL EDITIONS

    ADMINISTRATOR DEVELOPER TRENDSTIPS & TECHNIQUESCASE STUDIES

    g 'Value' to Your Prototypes | IBM i | IBM Systems Magazine http://www.ibmsystemsmag.com/ibmi/december04/spotlight/8303p3.aspx

    9/27/2010 10

  • 8/9/2019 Adding 'Value' to Your Prot...2

    4/6

    STORAGEPRODUCT NEWSENDPGMBUYER'S GUIDE

    Product News

    Presented by:

    ASG

    Adding 'Value' to Your PrototypesDecember 2004 | by Jon Paris and Susan Gantner

    Print Email

    Note that the prototype specifies CmdString as being a pointer, passed by VALUE. By using Options(*String), we have allowed ourselves to pass the variableCommand, and the compiler does the w ork for us. The result is that we can pass a character field (not a pointer) to the function on the call. If you use a regular RPGvariable, rather than the variable-length field, remember to use %Trim when passing the parameter. If you're running V5R3 or later, you can avoid this by codingOptions(*Trim) on the parameter.

    We've covered the basic prototyping information to make use o f the C-function library, including the use of EXTPROC, VALUE and OPTIONS(*STRING). Somemore advanced C functions require the use of call-back procedures in your RPG program. Click here for an example of using this with the qsort function.

    In the meantime, a few more details are necessary to make all of this work. First, you must specify the Binding Directory name QC2LE, preferably on your RPGprograms H spec. This is the binding directory that references all of the service programs in the C-function library. The system binder needs this to locate thefunctions w hen creating your program.

    If you prefer to use the Create Bound RPG (CRTBNDRPG) command (or option 14 in PDM) to compile your code, you must also specify DFTACTGRP(*NO) toallow for bound calls. This can also be specified on the H spec. Here's how your H spec might appear:

    H BndDir('QC2LE') DftActGrp(*No)

    More Information

    If you find a C function that you would like to use and need some help in translating the C data types into RPG data types, you can find that information as well assome other examples on calling C functions from RPG in the IBM Redbook, "Who Knew You Could Do That with RPG IV?"

    Try your hand at using C functions to open up your code to the C-function librarys power.

    Page 1 2 3

    Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

    More Articles From Jon Paris

    Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.

    More Articles From Susan Gantner

    Advertisement

    g 'Value' to Your Prototypes | IBM i | IBM Systems Magazine http://www.ibmsystemsmag.com/ibmi/december04/spotlight/8303p3.aspx

    9/27/2010 10

  • 8/9/2019 Adding 'Value' to Your Prot...2

    5/6

    How Frontline Homeowners Insurance SOA - Enables their IBM i Policy and Claims ApplicationsWednesday, October 13, 2010 - 2pm EST

    Advertisement

    Maximize your IT investment with monthly information from THE source... IBM Systems Magazine EXTRA & Marketplace eNewsletters.SUBSCRIBE NOW.

    View past IBM i EXTRAs here

    g 'Value' to Your Prototypes | IBM i | IBM Systems Magazine http://www.ibmsystemsmag.com/ibmi/december04/spotlight/8303p3.aspx

    9/27/2010 10

  • 8/9/2019 Adding 'Value' to Your Prot...2

    6/6

    Related Articles

    The Mystery of the Command Line Parameters

    Developer

    Data Orchestration

    Administrator

    iSeries EXTRA: Jon and Susan Answer Your Questions on Procedures

    E-Newsletter Exclusive

    Overcoming the Challenges of Embedding SQL into RPG Programs

    Developer

    Passing Parameters in Scheduled Jobs

    Administrator

    IBM iAIXMAINFRAMEPOWER

    HomepageAbout UsContact UsSubscriptionsEditorial Calendar Advertise With UsReprintsPrivacy PolicyTerms of ServiceSitemap

    IBM Systems Magazine is a trademark of International Business Machines Corporation. The editorial content of IBM Systems Magazine is placed onthis website by MSP TechMedia under license from International Business Machines Corporation.

    2010 MSP Communications, Inc. All rights reserved

    g 'Value' to Your Prototypes | IBM i | IBM Systems Magazine http://www.ibmsystemsmag.com/ibmi/december04/spotlight/8303p3.aspx