+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: Binary field compares

  1. #1
    Guest.Visitor Guest

    Default Binary field compares

    I have a parm being passed in as binary 4,0 I want to compare the field to a fixed value. what is the easiest way in rpgiv. one of the values I am looking for is x'1803'. I have always used z-add to place a binary value into a numeric variable, but it does not seem to be working correctly in this situation TIA, Greg

  2. #2
    Guest.Visitor Guest

    Default Binary field compares

    Greg, Would a data structure work? Something like: DVal DS D TstVal 5I 0 C EVAL TstVal = 6147 C IF Val = x'1803' C* Do something C ENDIF David Morris

  3. #3
    Guest.Visitor Guest

    Default Binary field compares

    I am not sure I follow exactly what you are doing here, but I'll try to explain what I am doing in a little more detail. I am working on an exit point program, one large parm is being passed in. positions 29 to 32 is a 4 byte binary value which represent the function being performed. as an example: if the value is a X'1803', a clear to a database is being issued. I want to be able to compare the binary value in the parm to the hex value to determine if that operation is being attempted. 'IF BinaryValue = X'1803' do something ENDIF *this paticular code gives me an error durring the comple as: Message ID . . . . . . : RNF7421 Severity . . . . . . . : 30 Message type . . . . . : Diagnostic Message . . . . : Operands are not compatible with the type of operator. Cause . . . . . : Operands must be of class character or graphic for character operations, numeric for arithmetic operations, and indicator for logical and relational operations. In a comparison operation, both operands must have the same data type. The specification is ignored. Recovery . . . : Specify the correct operand classes and data types. Compile Again. I have tried a few different ways but just have not gotten something right yet. Thanks

  4. #4
    Guest.Visitor Guest

    Default Binary field compares

    Greg, prior to V4R4, you have to use a character view of your binary field to compare it to a hex literal. Declare a character(4) subfield overlaying the binary subfield. In V4R4, your code would be accepted by the compiler. By the way, if the binary field is 4 bytes long your hex literal should have 8 hex digits. If you just use x'1803', then for a numeric comparison (V4R4) it would compare to x'00001803' and for a character comparison, it would compare to x'18034040'. Barbara Morris

  5. #5
    Guest.Visitor Guest

    Default Binary field compares

    I have never had such a miserable time with anything like this before on the AS/400 (17 years). I have to define the overlay field a 2a because the compiler says that 4 bytes is too long. So it compiles, I try displaying the value, writing it to a file, moving it, adding it ,compareing it all with no luck. Using DBU or dsppfm the values are non-displayable (seem to be) they look like hex 0000. I make the program error out to get a program dump, enter the D or F at the system operator message queue, the dumps are nowhere to be found. I even watched the job in qserver, once the D is taken they disapear ???. Because it is an exit point I can't get it into debug. I dump the file in hex even, everything just seems to be non-displayable. any other ideas Thanks, Greg

  6. #6
    Guest.Visitor Guest

    Default Binary field compares

    Greg, You might try a definition like: DVal DS D TstVal 10I 0 INZ(*ZEROS) C EVAL TstVal = 6147 C IF Val = x'00001803' C* Do something C ENDIF David Morris

  7. #7
    Guest.Visitor Guest

    Default Binary field compares

    Greg, How are you defining the binary subfield? Maybe you're using length notation instead of from-and-to notation for the subfield. If so, make sure you say 9B 0 (or better, 10i 0) for the 4-byte binary field. If you are only able to define a char(2) field over the binary field, a value of x'0000' probably means the "good" part of the binary field is in the last 2 bytes. Barbara Morris

  8. #8
    Guest.Visitor Guest

    Default Binary field compares

    Greg, A couple of ideas. One is to just define a standalone field with the value you want to test. That is: DValue s 10i 0 inz(x'00001803') and then compare your input to Value. Also in case you weren't aware of it, DSPPFM supports F10 which puts the file into hex mode so you can see the true values being stored.

  9. #9
    Guest.Visitor Guest

    Default Binary field compares

    What is the attribute of VAL when defined as the datastructure? That works for me hard coded but when I try to use eval (eval tstval = binary value or val = binary value) the compile fails because of type miss matches. Thanks, Greg

  10. #10
    Guest.Visitor Guest

    Default Binary field compares

    You hit my problem right on the nail head! I was defining the datastructure by size and not by position and I defined the field as 4b 0. Now that I am defining it by position rather than size I have been able to get the value into a usable format. Thank you for your help, Greg

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Convert Binary Field To Decimal?
    By Guest.Visitor in forum Programming
    Replies: 1
    Last Post: 05-16-2001, 12:33 PM
  2. Is it possible to use OPNQRYF to select using a binary field
    By Guest.Visitor in forum Programming
    Replies: 5
    Last Post: 03-15-2001, 08:26 AM
  3. Binary OR
    By Guest.Visitor in forum Programming
    Replies: 3
    Last Post: 09-08-1999, 12:09 PM
  4. *TRUNC option for BINARY fields ???
    By Guest.Visitor in forum Programming
    Replies: 1
    Last Post: 06-26-1998, 06:15 AM
  5. Binary to Decimal conversion
    By flensburg@novasol.dk in forum Programming
    Replies: 1
    Last Post: 08-25-1997, 05:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts