× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: memory and pointers and variable length fields
  • From: "Patrick Conner" <pwconner@xxxxxxxxxxx>
  • Date: Thu, 22 Mar 2001 11:10:15 -0500

First, I apologize for the style. I wrote some, I stole some
from "Who Knew..." and Chris Bipes gave me some code, also.
Thanks Chris.
Secondly, remember I had this thing working with variable
length fields first. So, I left some of that code.
Also, I've taken out error handling for this e-mail.
This code works but I'd like to get some opinions.

Anyway, my question is: How does this look?

 *   Socket data                                 
D SocketData      S          32767A   Varying    
D#SocketData      S          32767A   Varying    
D SockDtaLen      S             10I 0            
D SockDtaPtr      S               *              
D#BasePtr         S               *              
D#XMLLen          S             10U 0 Inz(32767) 
D#XML             S          32767A   Varying

 *   Build Socket Data                                                          
  
 *   - Build POST header with destination to Demand
Fulfillment Servlet/CGI Script
 *   - Servlet needed info: content type and content length                     
  
 *   Note: Hex '0D'= New Line , Hex '25'= Carriage Return                       
  
C                   Eval      SocketData = 'POST
/servlet/DfServletProxy H+       
C                             TTP/1.0' + x'0D' + x'25' +                        
  
C                             'Content-type:
application/x-www-form-urlenc+       
C                             oded' + x'0D' + x'25' +                           
  
C                             'Content-length: ' +                              
  
C                             %trim(%editc(%len(#XML):'Z'))
+                     
C                             x'0D' + x'25' + x'0D' + x'25'
+ #XML                
                                                                                
  
 * translate response to ASCII                                                  
  
c                   eval      p_InBuff  = %addr(SocketData)
+ 2                   
c                   eval      p_OutBuff = %addr(SocketData)
+ 2                   
c                   eval      InBytes = %len(SocketData)                        
  
c                   eval      OutBytes = %len(SocketData)                       
  
c                   eval      rc = IConv(ToAscii:                               
  
c                                        %addr(p_InBuff):                       
  
c                                        p_InBytes:                             
   
c                                        %addr(p_OutBuff):      
c                                        p_OutBytes)            
                                                                
 *   Send the XML to the server over the socket                 
C                   Eval      SockDtaLen = %len(SocketData)     
C                   Eval      SockDtaPtr = %Addr(SocketData)
+ 2
C                   Eval      RC = Write(SD: SockDtaPtr         
C                                          : SockDtaLen )       
                                                                
 *   Read the reply data from the server                              
C                   Eval      #XMLLen = 32767                         
C                   Alloc     #XMLLen       SockDtaPtr                
C                   Eval      #BasePtr = SockDtaPtr                   
               
C                   DoU       RC < 1                                  
                                                                      
C                   Eval      SockDtaLen = 32767                      
C                   Eval      RC = Read ( SD : SockDtaPtr :           
C                                              SockDtaLen )           
                                                                      
C                   If        SockDtaPtr - #BasePtr >
#XMLLen - 4096 
C                   Eval      #XMLLen = #XMLLen + 4096               
C                   ReAlloc   #XMLLen       #BasePtr                 
C                   EndIf                                            
C                   Eval      SockDtaPtr = SockDtaPtr + RC           
                                                                    
C                   EndDo                                            

c                   eval      p_InBuff  = #BasePtr            
c                   eval      p_OutBuff = #BasePtr            
c                   eval      InBytes = SockDtaPtr -
#BasePtr 
c                   eval      OutBytes = SockDtaPtr -
#BasePtr
c                   eval      rc = IConv(ToEBCDIC:            
c                                        %addr(p_InBuff):     
c                                        p_InBytes:           
c                                        %addr(p_OutBuff):    
c                                        p_OutBytes)          
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.