home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / NWTP04 / XMESS / TSTMESS.PAS < prev    next >
Pascal/Delphi Source File  |  1993-12-28  |  4KB  |  111 lines

  1. {$X+,B-,V-}
  2. program test;
  3.  
  4. { Test program for the nwMess unit / NwTP 0.4 API. (c) 1994, R.Spronk }
  5.  
  6. uses nwmisc,nwMess;
  7.  
  8. Var t,tbm,bm:byte;
  9.     connL,connResultL:TconnectionList;
  10.     mess    :string;
  11.  
  12. Procedure DisplayBrMode(bm:byte);
  13. begin
  14.  Case bm of
  15.  00: begin writeln('Server Stores : Netware Messages and User Messages,');
  16.            writeln('Shell automaticly displays messages.')
  17.      end;
  18.  01: begin writeln('Server Stores : Server Messages. (User messages discarded)');
  19.            writeln('Shell automaticly displays messages.')
  20.      end;
  21.  02: begin writeln('Server stores : Server messages only.');
  22.            writeln('Applications have to use GetBroadCastMessage to see if there is a message.')
  23.      end;
  24.  03: begin writeln('Server stores : Server messages and User messages.');
  25.            writeln('Applications have to use GetBroadCastMessage to see if there is a message.')
  26.      end;
  27.  else writeln('Unknown broadcastMode')
  28.  end; {case}
  29. end;
  30.  
  31.  
  32. begin
  33. if BroadcastToConsole('Hello, Console Operator!')
  34.  then writeln('BroadcastToConsole: Msg was broadcasted..')
  35.  else writeln('Broadcast To Console error:'+hexstr(nwMess.result,2));
  36.  
  37. writeln;
  38. if GetBroadcastMode(bm)
  39.  then begin
  40.       writeln('GetBroadcastMode: $',HexStr(bm,2));
  41.       DisplayBrMode(bm);
  42.  
  43.       t:=3;
  44.       while (t>=0) and (t<=3)
  45.        do if SetBroadcastMode(t) and GetBroadcastMode(tbm) and (tbm=t)
  46.            then dec(t) { ok, try next mode, alowed modes: 0,1,2,3 }
  47.            else begin
  48.                 writeln('SetBroadcastMode/GetBroadcastMode test failed.');
  49.                 t:=$80;
  50.                 end;
  51.  
  52.       if t=byte(-1)
  53.        then begin
  54.             SetBroadCastMode(bm); { restore old broadcastmode.. }
  55.             if nwmess.result=$00
  56.              then begin
  57.                   writeln;
  58.                   writeln('SetBroadcastMode tested OK..');
  59.  
  60.                 {  SetBroadCastMode($00);
  61.                   IF NOT DisableStationBroadcast
  62.                    then writeln('Err: $',HexStr(nwMess.result,2));
  63.                   GetBroadcastMode(tbm);
  64.                   writeln;
  65.                   writeln('the effect of DisableStationBroadcast:');
  66.                   DisplayBrMode(tbm);
  67.                   SetBroadCastMode(bm); }
  68.  
  69.                   end
  70.              else writeln('SetBroadcastMode error: Old mode couldn''t be restored..');
  71.             end;
  72.       end
  73.  else writeln('GetBroadcastMode error:'+hexstr(nwMess.result,2));
  74.  
  75. writeln;
  76. for t:=1 to 20 do connL[t]:=t;
  77. IF sendBroadcastMessage('Hello u there!',20,connL,connResultL)
  78.  then begin
  79.       writeln('SendBroadcastMessage: Msg was broadcasted..');
  80.       writeln('--and displayed at the folowing connections:');
  81.       for t:=1 to 20 do if connResultL[t]=$00 then write(t,' ');
  82.       writeln;
  83.       end
  84.  else writeln('SendBroadcastMessage error:'+hexstr(nwMess.result,2));
  85.  
  86. writeln;
  87. IF SendConsoleBroadcast('Testmessage from Console-operator..',0,connL)
  88.  then writeln('SendConsoleBroadcast: console message sent.')
  89.  else begin
  90.       write('SendConsoleBroadCast: Error ');
  91.       if nwMess.result=$C6
  92.        then writeln('! You need to have console privileges..')
  93.        else writeln(HexStr(nwMess.result,2));
  94.       end;
  95.  
  96. GetBroadCastMode(bm);
  97.  
  98. writeln;
  99. if SetBroadCastMode(3) { store all messages at the server, no notification.. }
  100.  then begin
  101.       writeln('Test of getBroadCastMessage..');
  102.       writeln('--use SEND on another workstation and send a message to this station.');
  103.       writeln;
  104.       writeln('Polling for a message.....');
  105.       REPEAT {} UNTIL GetBroadCastMessage(mess);
  106.       writeln('Message: ',mess);
  107.       end;
  108.  
  109. SetBroadCastMode(bm); { restore broadcastmode }
  110.  
  111. end.