I have a number of flags defined (by the header file far beyond my control) that look something like this:
* * OPTVAL field for IPV6_ADDR_PREFERENCES_FLAGS * 01 IPV6-ADDR-PREFERENCES-FLAGS PIC X(4). * * IPV6_ADDR_PREFERENCES_FLAGS mappings * 77 IPV6-PREFER-SRC-HOME PIC X(4) VALUE X'00000001'. 77 IPV6-PREFER-SRC-COA PIC X(4) VALUE X'00000002'. 77 IPV6-PREFER-SRC-TMP PIC X(4) VALUE X'00000004'. 77 IPV6-PREFER-SRC-PUBLIC PIC X(4) VALUE X'00000008'. 77 IPV6-PREFER-SRC-CGA PIC X(4) VALUE X'00000010'. 77 IPV6-PREFER-SRC-NONCGA PIC X(4) VALUE X'00000020'.
I need to execute binary OR code on several of these flags, and I wonder if there is an easy way to do this that I don't know about. Is there a simple keyword or syntax that will cause my program to treat these flags as binary values and allow me to do my math, or is this header file completely broken?
. COBOL, , COBOL. COMP, (S9 (9) COMP), COBOL .
, , , , . , .
COBOL . VMS COBOL :
IDENTIFICATION DIVISION. PROGRAM-ID. SAMPLEOR. DATA DIVISION. WORKING-STORAGE SECTION. * * OPTVAL field for IPV6_ADDR_PREFERENCES_FLAGS * 01 IPV6-ADDR-PREFERENCES-FLAGS PIC X(4). * * IPV6_ADDR_PREFERENCES_FLAGS mappings * 77 IPV6-PREFER-SRC-HOME PIC X(4) VALUE X'00000001'. 77 IPV6-PREFER-SRC-COA PIC X(4) VALUE X'00000002'. 77 IPV6-PREFER-SRC-TMP PIC X(4) VALUE X'00000004'. 77 IPV6-PREFER-SRC-PUBLIC PIC X(4) VALUE X'00000008'. 77 IPV6-PREFER-SRC-CGA PIC X(4) VALUE X'00000010'. 77 IPV6-PREFER-SRC-NONCGA PIC X(4) VALUE X'00000020'. PROCEDURE DIVISION. 1. CALL "BINARYOR" USING IPV6-PREFER-SRC-HOME IPV6-PREFER-SRC-COA IPV6-ADDR-PREFERENCES-FLAGS. CALL "BINARYOR" USING IPV6-PREFER-SRC-PUBLIC IPV6-ADDR-PREFERENCES-FLAGS IPV6-ADDR-PREFERENCES-FLAGS. IF IPV6-ADDR-PREFERENCES-FLAGS NOT = X'0000000B' DISPLAY "Failure" END-IF. END PROGRAM SAMPLEOR. IDENTIFICATION DIVISION. PROGRAM-ID. BINARYOR. DATA DIVISION. WORKING-STORAGE SECTION. LINKAGE SECTION. 01 ARG1 PIC S9(9) COMP. 01 ARG2 PIC S9(9) COMP. 01 RESULT PIC S9(9) COMP. PROCEDURE DIVISION USING ARG1 ARG2 RESULT. 1. ADD ARG1 TO ARG2 GIVING RESULT. END PROGRAM BINARYOR.
, COBOL , .
COBOL ( ) ( ) . . - . (, C), .
COMP. COMP COBOL . caluclate , COMP, COBOL. COMP, , , (.. 2 4 ). , H F, , 2 4 . , , COMP, - .
PIC 1 (8) ( 32- ) IPV6 , , PIC 1, 8 , .
Source: https://habr.com/ru/post/1711287/More articles:Using "expect" to send password automatically - linuxКак заменить текст в документе PowerPoint (.ppt)? - placeholderJava: Where can I find extended files / libraries for working with files? - javaWhere should I create temporary files for my application? - c #How to "click" UIImageView? - iphoneGoogle App Engine - насколько это быстро - google-app-engineFill text box with current username registered in sharepoint - sharepointGetting an item under the mouse cursor in a list control? - c #IUI method for displaying invalid password - designBufferedReader for a great ByteBuffer? - javaAll Articles