SHARE
TWEET

RGB2HEX

a guest Dec 25th, 2018 156 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        >>SOURCE FORMAT IS FREE
  2. IDENTIFICATION DIVISION.
  3.    PROGRAM-ID. RGB2HEX.
  4. ENVIRONMENT DIVISION.
  5.    CONFIGURATION SECTION.
  6.       REPOSITORY.
  7.          FUNCTION ALL INTRINSIC.
  8. DATA DIVISION.
  9.    WORKING-STORAGE SECTION.
  10.    01 INPUT-ARRAY.
  11.       02 INPUT-VALUE     PICTURE 9(3) OCCURS 3 TIMES.
  12.    01 TEMP               PICTURE 9(2).
  13.    01 HEX-DIGITS         VALUE IS "0123456789ABCDEF".
  14.       02 HEX-DIGIT       PICTURE X    OCCURS 16 TIMES.
  15.    01 OUTPUT-MATRIX.
  16.       02 OUTPUT-VALUE                 OCCURS 3 TIMES.
  17.          03 OUTPUT-DIGIT PICTURE X    OCCURS 2 TIMES.
  18.    01 ITERATOR           PICTURE 9.
  19. PROCEDURE DIVISION.
  20. MAIN-PROCEDURE.
  21.    PERFORM VARYING ITERATOR FROM 1 BY 1 UNTIL ITERATOR IS GREATER THAN 3
  22.       DISPLAY ITERATOR UPON ARGUMENT-NUMBER
  23.       ACCEPT INPUT-VALUE(ITERATOR) FROM ARGUMENT-VALUE
  24.       DIVIDE INPUT-VALUE(ITERATOR) BY 16 GIVING TEMP
  25.       ADD 1 TO TEMP GIVING TEMP
  26.       MOVE HEX-DIGIT(TEMP) TO OUTPUT-DIGIT(ITERATOR,1)
  27.       ADD 1 TO MOD(INPUT-VALUE(ITERATOR),16) GIVING TEMP
  28.       MOVE HEX-DIGIT(TEMP) TO OUTPUT-DIGIT(ITERATOR,2)
  29.    END-PERFORM.
  30.    DISPLAY "#" OUTPUT-MATRIX.
  31.    STOP RUN.
  32. END PROGRAM RGB2HEX.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top