dos_compilers/Digital Research PLI-86 v1/OPTIMIST.PLI
2024-06-30 12:01:25 -07:00

49 lines
1.6 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************/
/* This program demonstrates PL/I character string */
/* processing by turning a negative sentence into a */
/* positive one. */
/******************************************************/
optimist:
procedure options(main);
%replace
true by '1'b,
false by '0'b,
nwords by 5;
declare
negative (1:nwords) character(8) varying static initial
(' never',' none',' nothing',' not',' no'),
positive (1:nwords) character(10) varying static initial
(' always',' all',' something','',' some'),
upper character(28) static initial
('ABCDEFGHIJKLMNOPQRSTUVWXYZ. '),
lower character(28) static initial
('abcdefghijklmnopqrstuvwxyz. '),
sent character(254) varying,
word character(32) varying,
(i,j) fixed;
do while(true);
put skip list('What''s up? ');
sent = ' ';
do while
(substr(sent,length(sent)) ^= '.');
get list (word);
sent = sent !! ' ' !! word;
end;
sent = translate(sent,lower,upper);
if verify(sent,lower) ^= 0 then
sent = ' that''s an interesting idea.';
do i = 1 to nwords;
j = index(sent,negative(i));
if j ^= 0 then
sent = substr(sent,1,j-1) !!
positive(i) !!
substr(sent,j+length(negative(i)));
end;
put list('Actually,'!!sent);
put skip;
end;
end optimist;