ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Changing Hex Codes

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

  • Changing Hex Codes

    Hi,

    I have a 320 char text input field on a display file for sending messages.
    But when it sends it displays any totally blank line in reverse image (hex code 00) but any blank space on a line with text displays normally (hex code 40)

    How can I easily convert the 00 to 40 (either RPGLE or CLLE) before displaying with SNDBRKMSG ?

    Code:
    [SIZE=1][FONT=courier new]*CHAR  320     '[COLOR=#0000cd]fish[/COLOR][/FONT][/SIZE]</SPAN>[SIZE=1][FONT=courier new]                     '  [B][COLOR=#0000cd]8689A288[/COLOR][/B][/FONT][/SIZE]</SPAN>[COLOR=#ff0000][B][SIZE=1][FONT=courier new]4040404040404040404040404040404040404040
    [/FONT][/SIZE][/B][/COLOR]</SPAN></SPAN></SPAN>[SIZE=1][FONT=courier new]       +26     '                         '  [B][COLOR=#ff0000]404040404040404[/COLOR]0[/B][/FONT][/SIZE]</SPAN>[SIZE=1][FONT=courier new]00000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +51     '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +76     '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +101    '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +126    '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +151    '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +176    '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +201    '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +226    '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +251    '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +276    '                         '  000000000000000000000000000000000000000000000000[/FONT][/SIZE]</SPAN></SPAN>[SIZE=1][FONT=courier new]
           +301    '                    '       0000000000000000000000000000000000000000        [/FONT][/SIZE]
    </SPAN></SPAN>
    Greg Craill: "Life's hard - Get a helmet !!"

  • #2
    Re: Changing Hex Codes

    This looks weird.

    Are you using the SNDBRKMSG command itself or the preferable and more suitable QMHSNDBM or QMHSNDPM API ?

    Pls paste here the program snippet where you send the message.
    Last edited by Mercury; July 6, 2011, 05:27 AM.
    Philippe

    Comment


    • #3
      Re: Changing Hex Codes

      Originally posted by Mercury View Post
      This looks weird.

      Are you using the SNDBRKMSG command itself or the preferable and more suitable QMHSNDBM or QMHSNDPM API ?

      Pls paste here the program snippet where you send the message.
      At the risk of opening a pandora's box about technique and hijacking this thread..... How are the API's more preferable or suitable for sending a break message as opposed to using the command to send a break message? Which is more intuitive to the newbie maintenance programmer months or years later?

      Comment


      • #4
        Re: Changing Hex Codes

        initialize to blanks prior to loading the data? also is this a varying char field? if so you may need to set the length to it's max size prior to populating with data.
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: Changing Hex Codes

          Did anyone read about %scanrpl -- version 7.1 required.
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: Changing Hex Codes

            Originally posted by jamief View Post
            Did anyone read about %scanrpl -- version 7.1 required.
            http://www.code400.com/forum/showthr...ght=%25scanrpl
            you'd need to be extra careful...if you just check for x'00' you'd screw up the last blank character so instead of x'4000' you'd end up with x'4404' if you don't take that into consideration...
            Last edited by tomholden; July 6, 2011, 09:03 AM.
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #7
              Re: Changing Hex Codes

              Good catch Tom,

              you can use the length in %scanrpl ... so if you did something like this it SHOULD work .. MAYBE
              PHP Code:
              %len(%trim(mybigazzfield))-
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: Changing Hex Codes

                Originally posted by tomholden View Post
                you'd need to be extra careful...if you just check for x'00' you'd screw up the last blank character so instead of x'4000' you'd end up with x'4404' if you don't take that into consideration...
                Are you sure it would scan between byte boundries? I would have thought that the scan, even for hex characters, would have been on a full byte boundry.
                Michael Catalani
                IS Director, eCommerce & Web Development
                Acceptance Insurance Corporation
                www.AcceptanceInsurance.com
                www.ProvatoSys.com

                Comment


                • #9
                  Re: Changing Hex Codes

                  Originally posted by MichaelCatalani View Post
                  Are you sure it would scan between byte boundries? I would have thought that the scan, even for hex characters, would have been on a full byte boundry.
                  hmm...i may have to test that...
                  I'm not anti-social, I just don't like people -Tommy Holden

                  Comment


                  • #10
                    Re: Changing Hex Codes

                    Originally posted by tomholden View Post
                    hmm...i may have to test that...
                    I just tried the %scan with hex codes with this program:
                    Code:
                    d HexData         c                   Const(x'400400000000')
                    d FoundPosition   s             10i 0                       
                                                                                
                     /free                                                      
                                                                                
                        FoundPosition = %scan ( x'00' : HexData );              
                        dsply %char( FoundPosition );                           
                                                                                
                        *inlr = *on;
                    This returned a value of 3 for the position, which would be correct. The third byte contains x'00'. I'm not on 7.1, so I cant try %scanrpl, but I would think it would operate the same way.
                    Michael Catalani
                    IS Director, eCommerce & Web Development
                    Acceptance Insurance Corporation
                    www.AcceptanceInsurance.com
                    www.ProvatoSys.com

                    Comment


                    • #11
                      Re: Changing Hex Codes

                      yup verified... %scanrpl works as you said. good to know
                      I'm not anti-social, I just don't like people -Tommy Holden

                      Comment


                      • #12
                        Re: Changing Hex Codes

                        Originally posted by RBOrrell
                        At the risk of opening a pandora's box about technique and hijacking this thread..... How are the API's more preferable or suitable for sending a break message as opposed to using the command to send a break message? Which is more intuitive to the newbie maintenance programmer months or years later?
                        The API's are more preferable and suitable to use in programs than the command since you don't need to build the command on the fly in the program. Besides most API's work more quickly and use less system overhead than the CL commands. It is usually best practise to work with API's wherever possible, they also show your professional touch. As much as possible the commands should be avoided for using in a program if an equivalent API is available.

                        API use has the following advantages:
                        • APIs provide better performance when getting system information or when using system functions that are provided by CL commands or output file support.
                        • APIs provide system information and functions that are not available through CL commands.
                        • You can use calls from high-level languages to APIs.
                        • You can access system functions at a lower level than what was initially provided on the system.
                        • Data is often easier to work with when returned by an API.
                        Philippe

                        Comment


                        • #13
                          Re: Changing Hex Codes

                          Originally posted by tomholden View Post
                          yup verified... %scanrpl works as you said. good to know
                          You did successfully put me in panic mode for a second.
                          Michael Catalani
                          IS Director, eCommerce & Web Development
                          Acceptance Insurance Corporation
                          www.AcceptanceInsurance.com
                          www.ProvatoSys.com

                          Comment


                          • #14
                            Re: Changing Hex Codes

                            Originally posted by Mercury View Post
                            This looks weird.

                            Are you using the SNDBRKMSG command itself or the preferable and more suitable QMHSNDBM or QMHSNDPM API ?

                            Pls paste here the program snippet where you send the message.
                            Program-1 opens a display file where i can type in the message. Once all done it submits Program-2 to batch (passing the &MsgTxt field as one of the parms)

                            Program-2 finds all interactive jobs that match the filters, and sends them a message with the SNDBRKMSG command.

                            Running in debug mode, when leaving pgm1 the field is fine. As soon as it hits Pgm2 it is garbled. So it's not the SNDBRKMSG command, its the parm being called to the 2nd Pgm that is getting scrambled.
                            Greg Craill: "Life's hard - Get a helmet !!"

                            Comment


                            • #15
                              Re: Changing Hex Codes

                              Originally posted by gcraill View Post
                              Program-1 opens a display file where i can type in the message. Once all done it submits Program-2 to batch (passing the &MsgTxt field as one of the parms)

                              Program-2 finds all interactive jobs that match the filters, and sends them a message with the SNDBRKMSG command.

                              Running in debug mode, when leaving pgm1 the field is fine. As soon as it hits Pgm2 it is garbled. So it's not the SNDBRKMSG command, its the parm being called to the 2nd Pgm that is getting scrambled.
                              Pgm2 is a CL program, isnt it? Because the garble is happening starting beyond position 32.
                              Michael Catalani
                              IS Director, eCommerce & Web Development
                              Acceptance Insurance Corporation
                              www.AcceptanceInsurance.com
                              www.ProvatoSys.com

                              Comment

                              Working...
                              X