fhg
Volume 7, Number 8 -- February 28, 2007

Determining the Value of Built-in I/O Functions

Published: February 28, 2007

Hey, Ted:

What follows is a question that I have paraphrased from the emails of various readers of this august publication, who all seem to be encountering a similar issue: "Is it possible to view the value returned by built-in functions, such as %EOF and %FOUND, when working in the green-screen, full-screen debugger?"


The short answer is "No." The debugger will not show you the result of any function, built-in or user-defined, unless that function is defined to the debugger. (See Undocumented Debugger Function.) The reason for this behavior is that a function is not a variable. A variable is a section of memory, and as such, is easily queried for its current value. A function is executable code that runs when the function is invoked.

However, that does not mean that there is no way to determine the value that an I/O function returns. You just have to go about it another way.

Let's consider the following trivialized example program snippet.

Fitembl    if   e           k disk
                                                   
D Itnbr           s             15a                
                                                   
 /free                                             
     chain itnbr itemblmc;                         
     if %found(itembl);
        DoWhatever();
     else;
        DoWhateverElse();
     endif;

After the chain operation, %FOUND is either true (*ON) or false (*OFF). The same is true for %ERROR.

Here's another example:

FMyInfo    if   e           k disk            
FQSysPrt   o    f  132        printer
                                              
 /free                                        
     *inlr = *on;                             
     dow '1';                                 
        read myinfo;                          
        if %eof(myinfo);                   
           leave;                             
        endif;                                
        except pline;                         
     enddo;                                   
     return;                                  

After the read, the %EOF and %ERROR functions are updated with true/false values.

I have heard it said that there's no need to be able to view the returned values of the functions, since a person can determine how the functions behaved by watching the path of execution. That's a good point, and that's what I usually do. But there are times that I would not allow a section of code to execute if I knew what the function had returned, or I would have plugged a value in order to force the program to continue in some other direction. (I assume that those who have asked me this question have similar motives for wanting to know the result of a function call.)

I know of two methods you can use to see a function's return value. Here's the more obvious one first.

Method 1: Store the function's return value in a variable, like this.

FMyInfo    if   e           k disk            
FQSysPrt   o    f  132        printer         
                                              
D eof             s               n           
                                              
 /free                                        
     *inlr = *on;                             
     dow '1';                                 
        read myinfo;                          
        eof = %eof(myinfo);                   
        if eof;                               
           leave;                             
        endif;                                
        except pline;                         
     enddo;                                   
     return;                                  
 /end-free                                    
                                              
OQSysPrt   e            pline       1         
O                       name                  
O                       age           4  +0001

This method is by no means rocket science. Store the result of the %EOF function into variable EOF, then view the value of EOF. Besides being able to view the result of the %EOF function, you can alter the course of program execution by changing the value of the EOF variable before it is tested.

 eval eof = '1' 

Method 2: Check the status subfield of the file information data structure.

FMyInfo    if   e           k disk    infds(MyInfoDS)
FQSysPrt   o    f  132        printer                
                                                     
D MyInfoDS        ds                                 
D  MyInfoStatus     *status                          
                                                     
 /free                                               
     *inlr = *on;                                    
     dow '1';                                        
        read myinfo;                                 
        if %eof(myinfo);                             
           leave;                                    
        endif;                                       
        except pline;                                
     enddo;                                          
     return;                                         
 /end-free                                           
                                                     
OQSysPrt   e            pline       1                
O                       name                         
O                       age           4  +0001       

Add an INFDS keyword to the F spec of the file whose I/O status you want to test, and key the name of a data structure as the keyword's value. In this case, the data structure is MyInfoDS. Create the data structure and include a status subfield, defined with the literal *STATUS in the "from" entry field of the D spec.

When the program performs an I/O operation to MyInfo, the file information data structure will be updated. If the I/O is successful, the status subfield gets set to all zeros. If a READx operation hits beginning or end of file, the status becomes 11. A failed CHAIN (random read) returns a status code of 11. Status codes of 1000 or above indicate errors. See the iSeries Information Center for more about status codes.

--Ted


RELATED RESOURCES

Undocumented Debugger Function

iSeries Information Center, Status Code section



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


Sponsored By
PATRICK TOWNSEND & ASSOCIATES

Deploy. Run. Manage. Succeed.

Alliance AES/400
Database Field Encryption

· Encrypt credit card, social security, pin numbers and other sensitive data.
· Easy to use with RPG or COBOL - sample code included.
· Get compliant - SOX, Privacy notification, GLBA, Etc.
· Free 30-day trial. Fully functional software - Not a demo.

DB2 field encryption with Alliance AES: Encrypt and decrypt individual fields in AS/400 DB2 database files. Alliance APIs can be used in RPG and Cobol applications including older OPM applications. Alliance AES encryption for DB2 fields integrates with Alliance key management for the secure storage of AES keys.

DB2 file encryption with Alliance AES: Encrypt any DB2 database file with Alliance AES/400. You can specify that the data be converted to ASCII or retained in the original EBCDIC character set. You can also specify that the pass phrase should be converted to ASCII for decryption on an ASCII system such as Microsoft Windows. Alliance DB2 file encryption integrates with Alliance AES key management.

IFS file encryption with Alliance AES: You can encrypt and decrypt IFS (Integrated File System) files with Alliance AES encryption commands. Once encrypted files can be decrypted on an AS/400 or Windows PC or Server platform. You can also use the free Alliance Windows AES encryption application to encrypt files on a Windows platform for decryption on the AS/400. IFS file encryption integrates with Alliance AES key management for secure key storage.

AES self-decrypting archives: Alliance AES/400 can encrypt files into a self-decrypting archive. A self-decrypting archive is a Windows executable program. You can run the self-decrypting archive, enter a pass phrase, and decrypt and extract the file. If run from a command line you can pass the program parameters for the decryption. This is helpful if you are automating the decryption process. If you run the self-decrypting archive program without parameters it presents a Windows GUI dialog for pass phrase and other decryption information.

Report distribution with AES encryption: When Alliance AES encryption is used with the Alliance FTP Manager application you can automatically distribute reports in encrypted or self-decrypting archive format. Reports can be sent from one or more output queues, and reports can be selectively routed from the output queue.

AES key management: Alliance AES/400 provides a complete key management facility to help you securely store keys and pass phrases. All application program interfaces and commands allow the use of a named AES key. The Alliance AES key manager automatically backs up the key store when keys are added or changed.

Windows encryption application: Alliance AES encryption includes a Windows application that you can freely distribute to provide encryption and decryption services. Files encrypted on a Windows platform with the Alliance application can be decrypted on the AS/400. Files encrypted on the AS/400 can be decrypted on the Windows platform.

Sample code: The Alliance AES/400 product includes sample RPG and ILE-RPG source code that demonstrate how to use the encryption APIs. There are also sample CL programs that show how to use the Alliance commands to encrypt and decrypt files, and create self-decrypting archives.

More information:
Patrick Townsend & Associates, Inc.
7700 Earling Street NE
Olympia, WA 98506
Voice: (360) 357-8971
Fax: (360) 357-9047
Email: Info@patownsend.com
Web: www.patownsend.com

Click here for 30 day trial


Senior Technical Editor: Ted Holt
Technical Editors: Howard Arner, Joe Hertvik, Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Brian Kelly, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

COMMON:  Join us at the 2007 conference, April 29 – May 3, in Anaheim, California
Computer Keyes:  Rapidly convert *SCS printer files into black and white of full color PDF documents
Patrick Townsend & Associates:  Alliance AES/400 - database field encryption


Books on Sale at the IT Jungle Store: 30 Percent Off for 30 Days

The System i Pocket RPG & RPG IV Guide: List Price, $69.95; Sale Price, $49.00
The iSeries Pocket Database Guide: List Price, $59.00; Sale Price, $41.00
The iSeries Pocket Developers' Guide: List Price, $59.00; Sale Price, $41.00
The iSeries Pocket SQL Guide: List Price, $59.00; Sale Price, $41.00
The iSeries Pocket Query Guide: List Price, $49.00; Sale Price, $34.00
The iSeries Pocket WebFacing Primer: List Price, $39.00; Sale Price, $27.00
Migrating to WebSphere Express for iSeries: List Price, $49.00; Sale Price, $34.00
iSeries Express Web Implementer's Guide: List Price, $59.00; Sale Price, $41.00
Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95; Sale Price, $56.00
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00; Sale Price, $62.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00; Sale Price, $34.00
WebFacing Application Design and Development Guide: List Price, $55.00; Sale Price, $38.00
Can the AS/400 Survive IBM?: List Price, $49.00; Sale Price, $34.00
The All-Everything Machine: List Price, $29.95; Sale Price, $21.00
Chip Wars: List Price, $29.95; Sale Price, $21.00

 

The Four Hundred
IBM Seeks More CODE/400 Converts with WDSc 7.0

Midrange LUGs Are Changing the Way They Operate

Server Sales Up a Bit in 2006, But Q4 Looks a Bit Weak

As I See It: Disorderly Conduct

The Linux Beacon
Server Sales Up a Bit in 2006, But Q4 Looks a Bit Weak

Many Top Open Source Projects Still Lack Enterprise Support

Ballmer Dismisses Linux Threat, Talks Up Intellectual Property

Mad Dog 21/21: Paved With Good Intentions

Four Hundred Stuff
Approva Automates Compliance Efforts with BizRights

PowerTech Unveils New Password Utility

New BOSaNOVA Appliance Encrypts Tape Backups

S4i Gives DASD-Plus a New GUI

Big Iron
IBM Previews Future z/OS, z/VM Mainframe Operating Systems

Top Mainframe Stories From Around the Web

Chats, Webinars, Seminars, Shows, and Other Happenings

System i PTF Guide
February 24, 2007: Volume 9, Number 8

February 17, 2007: Volume 9, Number 7

February 10, 2007: Volume 9, Number 6

February 3, 2007: Volume 9, Number 5

January 27, 2007: Volume 9, Number 4

January 20, 2007: Volume 9, Number 3

The Windows Observer
Ballmer Casts a Pall on Vista Sales Expectations

Microsoft Posts Free Vista Deployment Tools

Alaska Air Takes Off to SCM with AccuRev

Accruent Fills a Gap in Real Estate Management

The Unix Guardian
HP Adds Entry Itanium Servers, Finally Delivers HP-UX 11i v3

Unix Is Dead? It Isn't Even Sick. . .

Chip Makers Strut Their Stuff at ISSCC

As I See It: Measuring What Counts

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

THIS ISSUE SPONSORED BY:

Patrick Townsend & Associates
Profound Logic Software
WorksRight Software



TABLE OF CONTENTS
Determining the Value of Built-in I/O Functions

Customize the Tab Key in WDSc

Admin Alert: Better Subsystem Throughput Via Multiple Job Queues, Part One

Four Hundred Guru

BACK ISSUES

From the IT Jungle Forums
MCH5003 creating objects in library

'Piping' output from OS400 commands

Referencing the key of current record

RSTOBJ to a specific library

Java Developer Position In New York City





 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement