Home > AS/400 News > ATT962064 -- command
AS/400 News:
EMAIL THIS

ATT962064 -- command

30 Apr 2003 |

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   

 
 /**********************************************************/                    
/*                                                        */                    
/* Program: OBJEXISTS                                     */                    
/* Purpose: Test object existence using path name         */                    
/*   Notes: This is the CPP for the OBJEXISTS command.    */                    
/*          The first parameter is the full path name     */                    
/*          of an object, the second is a logical status  */                    
/*          code - TRUE means object exists.              */                    
/*                                                        */                    
/**********************************************************/                    
             PGM        PARM(&PATHNAME &RETURN)                                 
                                                                                
/* Parameters */                                                                
             DCL        VAR(&PATHNAME) TYPE(*CHAR) LEN(514)                     
             DCL        VAR(&RETURN) TYPE(*LGL)                                 
                                                                                
/* Constants */                                                                 
             DCL        VAR(&TRUE) TYPE(*LGL) VALUE('1')                        
             DCL        VAR(&FALSE) TYPE(*LGL) VALUE('0')                       
             DCL        VAR(&EXISTS) TYPE(*DEC) LEN(1 0) VALUE(0) /* +          
                          0 -> file exists */                                   
                                                                                
/* API parameters and return value */                                           
             DCL        VAR(&PATHLEN) TYPE(*DEC) LEN(3 0)                       
             DCL        VAR(&PATHNULTRM) TYPE(*CHAR) LEN(513) /* +              
                          Extra character needed for null +                     
                          termination */                                        
             DCL        VAR(&MODE) TYPE(*CHAR) LEN(4) /* API define +           
                          F_OK = 0 (integer) */                                 
             DCL        VAR(&RTNVAL) TYPE(*CHAR) LEN(4) /* 0 -> file +          
                          exists; -1 -> file does not exist */                  
                                                                                
/* Append null to end of path name */                                           
             CHGVAR     VAR(&PATHNULTRM) VALUE(%SST(&PATHNAME 3 512))           
             CHGVAR     VAR(&PATHLEN) VALUE(%BIN(&PATHNAME 1 2) + 1)            
             CHGVAR     VAR(%SST(&PATHNULTRM &PATHLEN 1)) VALUE(X'00')          
                                                                                
/* Set access mode to file existence - F_OK */                                  
             CHGVAR     VAR(%BIN(&MODE)) VALUE(0)                               
                                                                                
/* Call API - %BIN() on RTNVAL indicates */                                     
/* integer value shall be returned       */                                     
             CALLPRC    PRC('access') PARM(&PATHNULTRM &MODE) +                 
                          RTNVAL(%BIN(&RTNVAL))                                 
                                                                                
/* Set logical value to result of comparison */                                 
             CHGVAR     VAR(&RETURN) VALUE(%BIN(&RTNVAL) = &EXISTS)             
                                                                                
             ENDPGM           


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


iSeries Application Development: CL, COBOL, RPG, VB, ILE, Java
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2010, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts