ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Bar Codes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Re: Bar Codes

    I am confused. Lets say the bar code field has a value of "CAT". Do you need a field with a Hex representation of CAT, an ASCII rep of CAT? So the printer is not attached to the 400 and you are sending a file to mainframe? In that case i'd say screw em, them the mainframe "add" this barcode field to what they need. You are not building a real barcode so I would not fart around with EBCDIC to ASCII.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #17
      Re: Bar Codes

      Here is the simplest RPG program I can think of to receive an EBCDIC character value and return the hex representation of the ASCII equivalent:
      Code:
           h dftactgrp( *NO )
           h     actgrp( *CALLER )
           h     bnddir( 'QC2LE' )
      
      
           D TSTHEXTO        PR                  extpgm( 'TSTHEXTO' )
           D  CharIn                       16a                                        Char in
           D  HexOut                       32a                                        Hex out
      
           D TSTHEXTO        PI
           D  CharIn                       16a                                        Char in
           D  HexOut                       32a                                        Hex out
      
            * Convert Hex-nibbles-to-Character-bytes prototype...
            * Length of receiver is double the length of source...
      
           d CvtHC           pr                  extproc('cvthc')
           d Target                        32
           d Source                              like( CharIn )
           d LenSource                     10i 0 value
      
            * Convert encoding...
      
           D CvtChar         pr                  extpgm( 'QDCXLATE' )
           D  szCvt                         5p 0 const                                Length
           D  cvtDta                             like( CharIn )                       Convert data
           D  cvtTbl                       10    const                                Conversion table
      
           D OldDta          s                   like( CharIn )
      
            /free
                oldDta = CharIn ;
                CvtChar(  %len(%trim( CharIn )) : OldDta : 'QASCII' ) ;
                CvtHC( HexOut : oldDta : (2 * %len(%trim( CharIn ))) ) ;
                return ;
            /end-free
      And this is a simple CL to test it:
      Code:
      pgm
      
         dcl   &CharIn      *char   16
         dcl   &HexOut      *char   32
      
         chgvar      &CharIn          '*123VaLUe456*'
      
         call        TSTHEXTO   ( &CharIn &HexOut )
      
         return
      
      endpgm
      Run the CL under debug to see the value of &HexOut after the CALL completes. I used an arbitrary value of some letters and digits with '*' at each end. You can use any test values you want to see how it works.

      My example input value is defined as 16 bytes. When converted to hex digits, it will be twice as long so &HexOut is defined as 32 bytes. Whatever size you define for your data, the output has to be twice as big. The variables inside the RPG all would need to be changed to match.

      The oldDta variable is used only to avoid changing the value of the input CharIn variable back in the calling CL.

      Using the QDCXLATE API might not be the best choice here. It is the simplest choice, though, and it should be fine for just converting digits. It'll probably be good enough to let you do some testing. More useful right now is the cvthc() API to give the hex digits. When you see how that works, it can be easier to see how better ways to call it might work.

      This is written as a program. If you put the APIs right into your programming, it should work fairly cleanly.
      Attached Files
      Tom

      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

      Comment


      • #18
        Re: Bar Codes

        I just had an input by a mainframe guy who did similar code for their type of documents in Cobol. I was on right track. I don't need to do any conversion. I will need a field of 14 characters. The first one and the last one will contain a *. The next four will identify if the print consits of one page (0001) or many pages (0000) with the last page of the batch being (0001). The next six will contain the page sequential numbering (01-99). The last two will contain only zeros. When writing to the output file each digit will be written in a single line so it can be read by the scanner i presume.

        Thanks for your help and assistance people.

        Comment


        • #19
          Re: Bar Codes

          In that case i'd say screw em...
          I pretty much agree with that sentiment. But I've been in similar positions where "the z90 guys" called the shots in the organization, regardless whether it made sense or not. You just gotta do the stupid job sometimes.
          Tom

          There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

          Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

          Comment


          • #20
            Re: Bar Codes

            I don't need to do any conversion.
            You realize that your specs have changed in just about every post you've made in this thread...? That makes it pretty difficult to give useful help. But I'm glad you're on your way.
            Tom

            There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

            Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

            Comment

            Working...
            X