! DISPLAY_CHARACTER.TPU !- ! This procedure writes a one line message describing the current character ! in terms of Octal, Decimal, Hexadecimal and (sometimes) '^' notation. ! --from DECUS submission by T. W. WILLIAMS PROCEDURE tww_eve_display_character LOCAL i,cc,reps,rep; REPS := "01234567" + "89101112131415" + "1617181920212223" + "2425262728293031" + "32127132133134135136" + "137138139140141142143" + "144145146147148149150" + "151155156157158159"; ! Handle end-of-buffer condition IF MARK( NONE ) = END_OF( CURRENT_BUFFER ) THEN MESSAGE( 'At end of buffer, no current character.' ); RETURN; ENDIF; ! Convert the character to an integer the hard way (no builtin yet) i := 0; LOOP; EXITIF i > 255; EXITIF CURRENT_CHARACTER = ASCII(i); i := i + 1; ENDLOOP; IF i > 255 THEN i := 0; ENDIF; ! On overflow, reset to NULL ! Provide ^ notation for ASCII control characters IF i < 32 THEN cc := ', ^' + ASCII(i+64); ELSE cc := ''; ENDIF; ! Provide mnemonic representation, too. IF ( I <= 32) OR ( I = 127) OR (( I > 131) AND ( I < 152)) OR (( I > 154) AND ( I < 160)) THEN REP := SUBSTR( REPS, INDEX( REPS, STR( I)) + LENGTH( STR( I)), 5); IF SUBSTR( REP, 5, 1) <> ">" THEN REP := SUBSTR( REP, 1, 4); ENDIF; ELSE REP := CURRENT_CHARACTER; ENDIF; ! Format and output the results MESSAGE( FAO( "Current Character is '!AS', Decimal=!UB, " + "Hex=!-!XB, Octal=!-!OB!AS", REP, i, cc ) ); ENDPROCEDURE; ! eve_display_character !+