RosettaCodeData/Task/Caesar-cipher/PL-I/caesar-cipher.pli

21 lines
726 B
Plaintext

caesar: procedure options (main);
declare cypher_string character (52) static initial
((2)'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
declare (text, encyphered_text) character (100) varying,
offset fixed binary;
get edit (text) (L); /* Read in one line of text */
get list (offset);
if offset < 1 | offset > 25 then signal error;
put skip list ('Plain text=', text);
encyphered_text = translate(text, substr(cypher_string, offset+1, 26),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' );
put skip list ('Encyphered text=', encyphered_text);
text = translate(encyphered_text, substr(cypher_string, 27-offset, 26),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' );
put skip list ('Decyphered text=', text);
end caesar;