×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hex Issue

Hex Issue

Hex Issue

(OP)
I have users that are putting in invalid codes, the hex value is 2A but I want to see if I can store these codes in a file and use the program to read thru all of them and scan the fields for them, the reason is that when I encounter more of them it would be easier to update the file with those values instead of changing the program when this happens.

Here's the code that I have that doesn't work..
HEXCOD is the field in the Hex Code File that I created

Read   FLOB
DOW    NOT %EOF(FLOB)
Read   HEXFILE
DOW    NOT %EOF(HEXFILE)
IF     %SCAN(HEXCOD:OBSITE) > 0    *NOTE HEXCOD Value is 2A
Eval   @FLAG = 'Y'
Else   
Eval   @FLAG = 'N'
Read   HEXFILE
ENDDO
Read   FLOB
ENDDO

However if I define a Constant like
@Hex   CONST(X'2A')

Then it works....

Read   FLOB
DOW    NOT %EOF(FLOB)
IF     %SCAN(@HEX:OBSITE) > 0
Eval   @FLAG = 'Y'
Else   
Eval   @FLAG = 'N'
Read   FLOB
ENDDO

Any Ideas or Suggestions? Thanks in advance

RE: Hex Issue

Pls paste here the definition of HEXCOD in the file.

Philippe

RE: Hex Issue

I guess I am missing something,, why are the codes in Hex??

RE: Hex Issue

Another possibility: @FLAG will only contain the value for the last record tested in FLOB.  If the last record in FLOB doesn't contain the last hex value from HEXFILE, then @FLAG will be 'N'.

RE: Hex Issue

I suspect that the HEXCOD field in your file is character. You cannot copare hexadecimal to a character representation of it. The reason using a named constant works is that it is hexadecimal.

You need to use the C function APIs to convert:

CODE

     H Option(*SRCSTMT : *NODEBUGIO)             
     H Dftactgrp(*NO) Actgrp(*CALLER)            
     H Bnddir('QC2LE')   
     H Datfmt(*USA) Timfmt(*HMS) Alwnull(*USRCTL)

       // Character to hexadecimal C function prototype      
     D Tohex           PR                  Extproc('cvthc')  
     D  Hexresult                 65534A   Options(*VARSIZE)
     D  Charinp                   32767A   Options(*VARSIZE)
     D  Charnibbles                  10I 0 Value             
                                                             
       // Hexadecimal to character C function prototype      
     D Fromhex         PR                  Extproc('cvtch')  
     D  Charresult                32767A   Options(*VARSIZE)
     D  Hexinp                    65534A   Options(*VARSIZE)
     D  Hexlen                       10I 0 Value             

       /Free
       // Call the API like this:
          Tohex(CharField : HexValue: %LEN(CharField));
 

-- Francis
I'd like to change the world, but I can't find the source code.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close