/**********************************************************************/
filename myreport namepipe '\pipe\report' server;
/**********************************************************************/
filename finances namepipe '\pipe\money.dat' client;
/**********************************************************************/
filename orders namepipe '\pipe\lunch\orders' server;
/**********************************************************************/
filename myreport namepipe '\\fastpc\pipe\report' client;
/**********************************************************************/
filename central namepipe '\pipe\report' server;
/**********************************************************************/
/* named pipe server code */
data prices;
input item price;
cards;
10 10.4
20 13.87
30 9.52
40 18.77
50 20.38
;
filename main namepipe '\pipe\orders' server
retry=60;
data trans;
infile main;
input item quan;
set prices;
where item=item;
tax=1.05;
total=quan*price*tax;
file main;
put total;
run;
/**********************************************************************/
/* named pipe client code */
filename sales namepipe '\\prices\pipe\orders'
client retry=30;
data a;
length acct item quan $5;
if _n_=1 then
do;
window Entry color=black rows=15
#2 @3 'Account Number - ' c=cyan acct c=cyan
#4 @3 'Item Number - ' c=cyan item c=cyan
#6 @3 'Quantity - ' c=cyan quan c=cyan
#8 @10 'Type END on command line when finished.'
c=yellow;
window Total color=black irow=16 rows=9
#2 @3 'The total for this order is '
c=yellow total dollar8.2 c=yellow;
end;
do while(upcase(_cmd_) ne 'END');
display entry;
infile sales truncover missover;
file sales;
if item in ('10','20','30','40','50') then
do;
put item quan;
input total;
display total noinput;
output;
item='';
quan='';
acct='';
end; /* item check do loop */
else _msg_ = 'Not a valid Item number';
end; /* _cmd_ ne END do loop */
stop;
run;
title 'Information for all orders taken';
proc print;
run;
/**********************************************************************/
/* named pipe server code */
filename in namepipe '\pipe\code' server retry=-1
eofconnect;
filename myout namepipe '\pipe\results' server retry=60
eofconnect;
filename mylog namepipe '\pipe\loginfo' server retry=60
eofconnect;
options mtrace mprint source source2;
%include in;
/**********************************************************************/
/* code for AFTER.SAS */
data _null_;
file print;
x=time();
y=date();
put 'Job Completed - ' y mmddyy. x time.;
run;
dm 'log; file mylog replace;';
dm 'output; file myout replace;';
dm 'clear output; clear log;';
/**********************************************************************/
/* named pipe client code */
filename in namepipe '\\fast486\pipe\code'
client retry=-1;
filename my out namepipe '\\fast486\pipe\results'
client retry=100;
filename mylog namepipe '\\fast486\pipe\loginfo'
client retry=100;
filename after 'after.sas';
%keydef 'F12'
"inc after;file in replace;undo;top;note log;
inc mylog;note results;inc out";
/**********************************************************************/
/* named pipe client code */
filename bids namepipe '\\baseball\pipe\offer'
client retry=-1;
filename reply namepipe '\\baseball\pipe\reply'
client retry=-1;
data baseball;
length action $4 player $17 yr 4 type $7;
window offers color=black rows=15
#2 @3 'Offer' @20 'Player' @41 'Yr' @53 'Type'
@62 'Price' c=yellow
#4 @3 action protect=yes @21 player protect=yes
@40 yr protect=yes @52 type protect=yes
@61 price PROTECT=YES
#7 @3 'Type ACCEPT or REJECT on the command line to
respond to offer.' c=yellow
#8 @3 'Type END on command line when finished.'
c=yellow;
infile bids;
file reply;
input action $ fname $ lname $ yr type $ price;
player=trim(fname) || ' ' || lname;
do until(upcase(_cmd_) eq 'END');
display offers;
select (upcase(_cmd_));
when ('ACCEPT')
do;
put 'ACCEPTED';
output;
infile bids;
input action $ fname $ lname $ yr type $ price;
player=trim(fname) || ' ' || lname;
end;
when ('REJECT')
do;
put 'REJECTED';
output;
infile bids;
input action $ fname $ lname $ yr type $ price;
player=trim(fname) || ' ' || lname;
end;
when ('END') stop;
otherwise
do;
_msg_='You must enter ACCEPT, REJECT, or END.';
end;
end;
end;
stop;
run;
/**********************************************************************/
INIT:
rc=filename('offer','\pipe\offer','namepipe',
'server retry=60');
if rc=0 then link errmsg;
else
do;
fid1=fopen('offer','o');
if fid1=0 then link errmsg;
end;
rc=filename('reply','\pipe\reply','namepipe',
'server retry=60');
if rc=0 then link errmsg;
else
do;
fid2=fopen('reply','s');
if fid2=0 then link errmsg;
end;
rc=libname('baseball','e:\baseball\price\list');
prices=open('baseball.becket','i');
if not prices then link errmsg;
call set(prices);
call setrow(0,1,'n','y');
return;
MAIN:
select(choice);
when ('BUY') link write;
when ('SELL') link write;
when('QUIT') call execcmd('End');
otherwise
do;
choice='';
refresh;
end;
end;
return;
TERM:
rc=fclose(fid1);
rc=fclose(fid2);
if prices then rclose=close(prices);
return;
GETROW:
if fetchobs(prices,_currow_)<0 then call endtable();
return;
PUTROW:
row=_currow_ ;
rc=select(row);
cursor player;
return;
WRITE:
rcfetch=fetchobs(prices,row);
order=choice||' ' ||player||' ' ||yr||' '||
type||' '||price;
rc=fput(fid1,order);
rc=fwrite(fid1);
choice='';
rc=unselect(_currow_);
rc=fread(fid2);
rc=fget(fid2,answer,200);
reply='The offer for '|| player||' at '||
price||' is '||answer;
rc=unselect(row);
refresh;
return;
ERRMSG:
msg=sysmsg();
put msg;
_status_='H';
return;
/**********************************************************************/