midrange.com code scratchpad
Name:
Subroutines in procedures
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
10/09/2007 05:27:33 pm
IP:
Logged
Description:
Example of using subroutines in a procedure
Code:
  1.      /*                                                                       */                     
  2.      /* Out:  8/05/04  9:20 Ver:  0.  0 Level40 CHRISTEN, DUANE J. - IT&S     */                     
  3.      /* Ref: ANIN090402 ANI Inventory/ANI API Redesign (Code)                 */                     
  4.      /* DJC: Initial program creation                                         */                     
  5.      /*                                                                       */                     
  6.                                                                                                      
  7.      /*   Copyright McLeod, Inc., as an unpublished work created in                                  
  8.      /*   2004.  This program is CONFIDENTIAL, unpublished work of                                   
  9.      /*   authorship.  IT IS A TRADE SECRET which is the property of                                 
  10.      /*   McLeod, Inc.  All use, disclosure, and/or reproduction not                                 
  11.      /*   specifically authorized by McLeod, Inc., is prohibited.                                    
  12.      /*   This program may also be protected under the copyright                                     
  13.      /*   and/or trade secret laws of non-U.S. countries.  All rights                                
  14.      /*   reserved.                                                                                  
  15.                                                                                                      
  16.      /*============================================================================================= 
  17.      /*   Notes                                                                                      
  18.      /*============================================================================================= 
  19.                                                                                                      
  20.      /*   Compile with ACTGRP(*CALLER)                                                               
  21.                                                                                                      
  22.      /*============================================================================================= 
  23.      /*   Control Specifications                                                                     
  24.      /*============================================================================================= 
  25.                                                                                                      
  26.      H NoMain                                                                                        
  27.                                                                                                      
  28.      /*============================================================================================= 
  29.      /*   File Specifications                                                                        
  30.      /*============================================================================================= 
  31.                                                                                                      
  32.                                                                                                      
  33.      /*============================================================================================= 
  34.      /*   Prototype Specifications                                                                   
  35.      /*============================================================================================= 
  36.                                                                                                      
  37.       /Include QRPGCBSRC,XMRM9800                                                                    
  38.       /Include QRPGCBSRC,QXMLPARSER                                                                  
  39.                                                                                                      
  40.      /*============================================================================================= 
  41.      /*   Data Specifications                                                                        
  42.      /*============================================================================================= 
  43.                                                                                                      
  44.                                                                                                      
  45.      /*--------------------------------------------------------------------------------------------- 
  46.      /*   Data Structure Specifications                                                              
  47.      /*--------------------------------------------------------------------------------------------- 
  48.                                                                                                      
  49.                                                                                                      
  50.      /*--------------------------------------------------------------------------------------------- 
  51.      /*   Array Specifications                                                                       
  52.      /*--------------------------------------------------------------------------------------------- 
  53.                                                                                                      
  54.                                                                                                      
  55.      /*--------------------------------------------------------------------------------------------- 
  56.      /*   Indicator Specifications                                                                   
  57.      /*--------------------------------------------------------------------------------------------- 
  58.                                                                                                      
  59.                                                                                                      
  60.      /*--------------------------------------------------------------------------------------------- 
  61.      /*   Standalone Data Specifications                                                             
  62.      /*--------------------------------------------------------------------------------------------- 
  63.                                                                                                      
  64.                                                                                                      
  65.      /*--------------------------------------------------------------------------------------------- 
  66.      /*   Constant Specifications                                                                    
  67.      /*--------------------------------------------------------------------------------------------- 
  68.                                                                                                      
  69.                                                                                                      
  70.      /*############################################################################################# 
  71.      /*   Procedure Deleclaration - Convert DOM Element To String                                    
  72.      /*############################################################################################# 
  73.                                                                                                      
  74.      P convertDOMElementToString...                                             Convert DOM          
  75.      P                 B                   Export                                Element to String   
  76.                                                                                                      
  77.      /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  78.      /*   Procedure Interface                                                                        
  79.      /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  80.                                                                                                      
  81.      D convertDOMElementToString...                                             Convert DOM          
  82.      D                 PI            10U 0                                       Element to String   
  83.      D  element                        *   Value                                Element Node         
  84.      D  string                         *   Value                                Resulting String     
  85.      D  stringLength                 10U 0 Value                                Resulting String Len 
  86.      D  stringCCSID                  10I 0 Value                                Resulting CCSID      
  87.                                                                                                      
  88.      /*============================================================================================= 
  89.      /*   Procedure Data Specifications                                                              
  90.      /*============================================================================================= 
  91.                                                                                                      
  92.                                                                                                      
  93.      /*--------------------------------------------------------------------------------------------- 
  94.      /*   Procedure Data Structure Specifications                                                    
  95.      /*--------------------------------------------------------------------------------------------- 
  96.                                                                                                      
  97.                                                                                                      
  98.      /*--------------------------------------------------------------------------------------------- 
  99.      /*   Procedure Array Specifications                                                             
  100.      /*--------------------------------------------------------------------------------------------- 
  101.                                                                                                      
  102.                                                                                                      
  103.      /*--------------------------------------------------------------------------------------------- 
  104.      /*   Procedure Indicator Specifications                                                         
  105.      /*--------------------------------------------------------------------------------------------- 
  106.                                                                                                      
  107.                                                                                                      
  108.      /*--------------------------------------------------------------------------------------------- 
  109.      /*   Procedure Standalone Data Specifications                                                   
  110.      /*--------------------------------------------------------------------------------------------- 
  111.                                                                                                      
  112.      D bytesAvailable...                                                                             
  113.      D                 S             10U 0                                                           
  114.      D bytesProvided...                                                                              
  115.      D                 S             10U 0                                                           
  116.                                                                                                      
  117.      D x               S             10U 0                                                           
  118.                                                                                                      
  119.      D elementLength...                                                                              
  120.      D                 S             10U 0                                                           
  121.      D elementChild...                                                                               
  122.      D                 S               *                                                             
  123.      D elementSibling...                                                                             
  124.      D                 S               *                                                             
  125.                                                                                                      
  126.      D attributeList...                                                                              
  127.      D                 S               *                                                             
  128.      D attribute...                                                                                  
  129.      D                 S               *                                                             
  130.      D attributeCount...                                                                             
  131.      D                 S             10U 0                                                           
  132.                                                                                                      
  133.      /*--------------------------------------------------------------------------------------------- 
  134.      /*   Procedure Constant Specifications                                                          
  135.      /*--------------------------------------------------------------------------------------------- 
  136.                                                                                                      
  137.                                                                                                      
  138.      /*--------------------------------------------------------------------------------------------- 
  139.      /*   Procedure Key Lists                                                                        
  140.      /*--------------------------------------------------------------------------------------------- 
  141.                                                                                                      
  142.                                                                                                      
  143.      /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  144.      /*   Procedure Code                                                                             
  145.      /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  146.                                                                                                      
  147.       /Free                                                                                          
  148.                                                                                                      
  149.        elementLength = concatenateConstant(string : '<');                 // Element Start           
  150.        bytesProvided = stringLength - elementLength;                                                 
  151.                                                                                                      
  152.        QxmlTransCode(QxmlDOMNode_getNodeName(element) :                   // Element Name            
  153.                      Qxml_UniCode :                                                                  
  154.                      string  + elementLength :                                                       
  155.                      %Addr(bytesProvided) :                                                          
  156.                      %Addr(bytesAvailable) :                                                         
  157.                      stringCCSID);                                                                   
  158.                                                                                                      
  159.        elementLength = strlen(string);                                                               
  160.                                                                                                      
  161.        ExSr elementAttributes;                                                                       
  162.                                                                                                      
  163.        elementLength += concatenateConstant(string : '>');                // Close Element Start     
  164.                                                                                                      
  165.        ExSr elementBody;                                                  // Element Body            
  166.                                                                                                      
  167.        elementLength += concatenateConstant(string : '</');               // Element End             
  168.        bytesProvided = stringLength - elementLength;                                                 
  169.                                                                                                      
  170.        QxmlTransCode(QxmlDOMNode_getNodeName(element) :                   // Element Name            
  171.                      Qxml_UniCode :                                                                  
  172.                      string + elementLength :                                                        
  173.                      %Addr(bytesProvided) :                                                          
  174.                      %Addr(bytesAvailable) :                                                         
  175.                      stringCCSID);                                                                   
  176.                                                                                                      
  177.        elementLength = strlen(string);                                                               
  178.                                                                                                      
  179.        elementLength += concatenateConstant(string : '>');                // Close Element End       
  180.                                                                                                      
  181.        Return elementLength;                                                                         
  182.                                                                                                      
  183.        //=========================================================================================== 
  184.        //   Element Attributes                                                                       
  185.        //=========================================================================================== 
  186.                                                                                                      
  187.        BegSr elementAttributes;                                                                      
  188.                                                                                                      
  189.           attributeList = QxmlDOMNode_getAttributes(element);             // List of Attributes      
  190.           attributeCount = QxmlDOMNamedNodeMap_getLength(attributeList);  // Number of Attributes    
  191.                                                                                                      
  192.           For x = attributeCount DownTo 1;                                                           
  193.              attribute = QxmlDOMNamedNodeMap_Item(attributeList : x - 1);                            
  194.                                                                                                      
  195.                                                                                                      
  196.              elementLength +=                                             // Attribute Start         
  197.                concatenateConstant(string + elementLength : ' ');                                    
  198.              bytesProvided = stringLength - elementLength;                                           
  199.                                                                                                      
  200.              QxmlTransCode(QxmlDOMNode_GetNodeName(attribute) :           // Attribute Name          
  201.                            Qxml_UniCode :                                                            
  202.                            string + elementLength :                                                  
  203.                            %Addr(bytesProvided) :                                                    
  204.                            %Addr(bytesAvailable) :                                                   
  205.                            stringCCSID);                                                             
  206.                                                                                                      
  207.              elementLength = strlen(string);                                                         
  208.                                                                                                      
  209.              elementLength +=                                                                        
  210.                concatenateConstant(string + elementLength : '="');        // Attribute Value Start   
  211.              bytesProvided = stringLength - elementLength;                                           
  212.                                                                                                      
  213.              QxmlTransCode(QxmlDOMNode_GetNodeValue(attribute) :          // Attribute Value         
  214.                            Qxml_UniCode :                                                            
  215.                            string + elementLength :                                                  
  216.                            %Addr(bytesProvided) :                                                    
  217.                            %Addr(bytesAvailable) :                                                   
  218.                            stringCCSID);                                                             
  219.                                                                                                      
  220.              elementLength = strlen(string);                                                         
  221.                                                                                                      
  222.              QxmlDOMNode_delete(attribute);                                                          
  223.                                                                                                      
  224.              elementLength +=                                                                        
  225.                concatenateConstant(string + elementLength : '"');         // Attribute End           
  226.           EndFor;                                                                                    
  227.                                                                                                      
  228.           QxmlDOMNamedNodeMap_delete(attributeList);                                                 
  229.                                                                                                      
  230.                                                                                                      
  231.        EndSr;                                                                                        
  232.                                                                                                      
  233.        //=========================================================================================== 
  234.        //   Element Body                                                                             
  235.        //=========================================================================================== 
  236.                                                                                                      
  237.        BegSr elementBody;                                                                            
  238.                                                                                                      
  239.           elementChild = QxmlDOMNode_GetFirstChild(element);              // Element Child Node(s)   
  240.                                                                                                      
  241.           DoW QxmlDOMNode_IsNULL(elementChild) = Qxml_NodNotNul;                                     
  242.                                                                                                      
  243.              elementLength +=                                                                        
  244.                convertDOMNodeToString(elementChild :                                                 
  245.                                       string + elementLength :                                       
  246.                                       stringLength -                                                 
  247.                                         elementLength :                                              
  248.                                       stringCCSID);                                                  
  249.                                                                                                      
  250.              elementSibling = QxmlDOMNode_GetNextSibling(elementChild);                              
  251.                                                                                                      
  252.           QxmlDOMNode_delete(elementChild);                                                          
  253.                                                                                                      
  254.           elementChild = elementSibling;                                                             
  255.           EndDo;                                                                                     
  256.                                                                                                      
  257.           QxmlDOMNode_delete(elementChild);                                                          
  258.                                                                                                      
  259.        EndSr;                                                                                        
  260.                                                                                                      
  261.       /End-Free                                                                                      
  262.                                                                                                      
  263.      P convertDOMElementToString...                                                                  
  264.      P                 E                                                                             
  265.                                                                                                      
  266.        //=========================================================================================== 
© 2004-2019 by midrange.com generated in 0.01s valid xhtml & css