× 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.



Hi Martin

Does the printer you are using expect ASCII codes or EBCDIC, and if ASCII
does it convert the EBCDIC for you?

The AS400/iSeries/i5/System i/whatever uses the EBCDIC character set, so it
is unlikely that the id character will have the same character code as that
identified by your parcel service.

There is an EBCDIC to ASCII conversion table, QASCII, and an ASCII to EBCDIC
conversion table, QEBCDIC, which the system uses when converting between the
two character sets.  If you look at the QEBCDIC table (use WRKTBL QEBCDIC
and option 5) you will find that ASCII x'25' (37=x'25') converts to EBCDIC
x'6C'.

To set hex values on the 400 you can specify them as x'25' or whatever
within your program.  If you want to find out what the EBCDIC value of an
ASCII code is you need to try and reference the conversion table.  You can
use the QDCXLATE API to do the conversion data for you, or roll your own to
convert an ASCII hex code to an EBCDIC one.  For example:

     D GetEBCDIC       pr             1a                                
     D  iDecAscii                     3p 0 Const                        
     D  oDecEbcdic                    3p 0 Options(*NoPass)             
     D  oHexEbcdic                    2a   Options(*NoPass)             
                                                                        
     D oDec            s              3p 0                              
     D oHexStr         s              2a                                
     D oHex            s              1a                                
                                                                        
     C                   Eval      oHex = GetEBCDIC(37 : oDec : oHexStr)
     C     oHex          Dsply                                          
     C     oDec          Dsply                                          
     C     oHexStr       Dsply                                          
                                                                        
     C                   Eval      *InLR = *On                          
     C                   Return                                         
                                                                        
     P GetEBCDIC       b                                                
                                                                        
     D* Parameters...

     D GetEBCDIC       pi             1a

     D  iDecAscii                     3p 0 Const

     D  oDecEbcdic                    3p 0 Options(*NoPass)

     D  oHexEbcdic                    2a   Options(*NoPass)

 

     D* ASCII to EBCDIC Conversion table

     D* Table details retrieved using RTVTBLSRC QEBCDIC...

     D CnvTable        ds

     D  txtTable                    512a
Inz('00010203372D2E2F1605250B0C0D0E- 
     D
0F101112133C3D322618193F271C1D1E1F-  
     D
404F7F7B5B6C507D4D5D5C4E6B604B61F0F1-
     D                                     F2F3F4F5F6F7F8F97A5E4C7E6E6F-

     D
7CC1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7D8-
     D                                     D9E2E3E4E5E6E7E8E94AE05A5F6D-

     D
798182838485868788899192939495969798-
     D                                     99A2A3A4A5A6A7A8A9C06AD0A107-

     D
202122232415061728292A2B2C090A1B3031-
     D                                     1A333435360838393A3B04143EE1-

     D
414243444546474849515253545556575859-
     D                                     6263646566676869707172737475-

     D
767778808A8B8C8D8E8F909A9B9C9D9E9FA0-
     D                                     AAABACADAEAFB0B1B2B3B4B5B6B7-

     D
B8B9BABBBCBDBEBFCACBCCCDCECFDADBDCDD-
     D                                     DEDFEAEBECEDEEEFFAFBFCFDFEFF')

     D  EBCDIC                        2a   Dim(256) Overlay(txtTable)

 

     D* Work fields...

     D wHexChar                       2a

     D wDec                           3p 0

     D cHex                          16a   Inz('0123456789ABCDEF')

     D ix                             3p 0

     D wRtnVal                        1a

 

     C* If the input parameter is not in the range 000-255 then return
x'00'... 
     C                   If        iDecAscii < 0 or iDecAscii > 255

     C                   Return    x'00'

     C                   EndIf

 

     C* Pick up the 'hex' value from the conversion table...

     C                   Eval      wHexChar = EBCDIC(iDecAscii + 1)

 

     C* If the hex character string is to be returned then move it to the
parameter...
     C                   If        %Parms = 3

     C                   Eval      oHexEbcdic = wHexChar

     C                   EndIf

 

     C* Convert the hex character string to decimal...

     C                   Eval      wDec = *Zeros

     C                   Eval      ix = %Scan(%Subst(wHexChar:1:1) : cHex)

     C                   Eval      wDec = wDec + ((ix - 1) * 16)

 

     C                   Eval      ix = %Scan(%Subst(wHexChar:2:1) : cHex)

     C                   Eval      wDec = wDec + (ix - 1)

 

     C* If the decimal value is to be returned then move it to the
parameter...       
     C                   If        %Parms >= 2

     C                   Eval      oDecEbcdic = wDec

     C                   EndIf

 

     C* Now build the hex character to be returned...   
     C                   Eval      wRtnVal = x'00'      
     C                   DoU       wDec = *Zeros        
     C                   Select                         
     C                   When      wDec >= 128          
     C                   Biton     '0'           wRtnVal
     C                   Eval      wDec = wDec - 128    
     C                   When      wDec >= 64           
     C                   Biton     '1'           wRtnVal
     C                   Eval      wDec = wDec - 64     
     C                   When      wDec >= 32           
     C                   Biton     '2'           wRtnVal
     C                   Eval      wDec = wDec - 32     
     C                   When      wDec >= 16           
     C                   Biton     '3'           wRtnVal
     C                   Eval      wDec = wDec - 16     
     C                   When      wDec >= 8            
     C                   Biton     '4'           wRtnVal
     C                   Eval      wDec = wDec - 8      
     C                   When      wDec >= 4            
     C                   Biton     '5'           wRtnVal
     C                   Eval      wDec = wDec - 4      
     C                   When      wDec >= 2            
     C                   Biton     '6'           wRtnVal
     C                   Eval      wDec = wDec - 2      
     C                   When      wDec >= 1            
     C                   Biton     '7'           wRtnVal
     C                   Eval      wDec = wDec - 1      
     C                   EndSl                          
     C                   EndDo                          
                                                        
     C* Return to the calling module...                 
     C                   Return    wRtnVal              
                                                        
     P GetEBCDIC       e                                


All the best

Jonathan



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of M.Effenberg@xxxxxxxxxxxx
Sent: 19 October 2006 10:24
To: rpg400-l@xxxxxxxxxxxx
Subject: How to print decimal ascii characters?

Hello there,
I have an interesting problem here and i have no idea how to accomplish
this.

I am printing parcel labels to EPL thermal printers.
These labels have a barcode with an id char at the beginning.

I got a file from our parcel service with routing information and the ascii
decimal value (!) for that id character.

So the file looks like this:
#Fields: 
DestinationCountry|BeginPostCode|EndPostCode|ServiceCodes|RoutingPlaces|Send
ingDate|O-Sort|D-Depot|GroupingPriority|D-Sort|BarcodeID|
ES|46101|46109|S299,S302303|GEFDX,GEBED,GENLD,GEALC,GEITD,GEFCO|*|*|0746
ES|46101|46109||9|*|37|

I imported this to my as400 via cpyfrmimpf.
The line above says, that parcels to areas in spain with the zipcodes
46101 to 46109 should be routed to destination depot 0746 and the barcode on
that label should have the char ascii 37 at the beginning (thats '%').

Now i have that '37' in my file on the as400 in an 2a field (drbarc).
And i want to build my barcode like this: 

eval barcode=drbarc+%trim(barcode)

This obviously doesn't work since i just put an '37' in front of my barcode.


And my problem is now: how to find out, that decimal ascii 37 is '%', so 
that i can print this in front of my barcode.


Something like:

asciichar=alfa2ascii('37')
// asciichar is now '%'
barcode=asciichar+%trim(barcode)


any hints are greatly appreciated :)


- Martin

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.