{$DOUBLE}
{$NOWALKBACK$}
Program TEST1;

{ 
  Version x1.0
  File:[decnet]TEST1.PAS
  Author: Jim Bostwick 11-AUG-1988

  Last Edit: 12-JUN-1989 18:26:30 

  History:
;		 3-AUG-1989 10:50:29 - JMB - Add $DOUBLE switch


    This program is an initial test for the DECNET package.
 It builds a connect block, and then attempts to connect to 
 NML on a remote node. If nml connects, we're done, and 
 go away. 
}
{$Nolist}
{[a+,b+,l-,k+,r+] Pasmat }
 %INCLUDE 'PAS$EXT:General.typ';
 %INCLUDE 'PAS$EXT:DECNET.PKG';
 %INCLUDE 'PAS$EXT:STRING.PKG';
 %INCLUDE 'PAS$EXT:WAIT.EXT';
 %INCLUDE 'PAS$EXT:ALUN.EXT'; 
{$List }


VAR
    STAT, N: INTEGER;
    IOSB: IO_STATUS_BLOCK;
    CONB: NET_REQUEST_BLOCK;
    task, nul_msg, inmsg: CH16;
    outmsg: CH16;

BEGIN
    sclear(nul_msg);
    Sassign(task,'REC10');
    Writeln('DECNET TEST #1.');
    ALUN(1,'NS',0);
    ALUN(2,'NS',0);
    Writeln('Call NTCONB to build a connect block...');
    NTCONB('DRAGON',chr(0),Task,CONB,STAT);
    Writeln('done. STAT=',stat:-6,'.');
    If STAT = 1 THEN
       BEGIN
       Writeln('Call NTOPN to get a network LUN and start DECNET...');
       NTOPN(1,f1,1,1,IOSB);
       Writeln('done. IOSB[1]=',iosb.int[1]:-6,' IOSB[2]=',iosb.int[2]:-6);
       IF IOSB.int[1] = 1 THEN
	   BEGIN
	   Writeln('Call NTCON to connect (to REC10)...');
	   NTCON(2,f2,nul_msg,CONB,inmsg,IOSB);
           Writeln('done. IOSB[1]=',iosb.int[1]:-6,' IOSB[2]=',iosb.int[2]:-6);
	   NTDRB(Conb);
    	    if iosb.int[1] = 1 THEN
		BEGIN
		Writeln('Call NTSND to send 5 messages.');
		sassign(outmsg,'HI FROM TST1');
		N := 0;
	    	While (IOSB.int[1] = 1) AND (N < 5) DO 
		    BEGIN
		    NTSND(2,f2,loophole(address,ref(outmsg)),slen(outmsg),IOSB);
		    Writeln('done. IOSB[1]=',iosb.int[1]:-6,' IOSB[2]=',iosb.int[2]:-6);
		    N := N + 1
		    end
		end;
    	    Writeln('Waiting for link to clear....');
	    Wait(f3,5,seconds); { let things settle before disconnect...}
    	    Writeln('Call NTDSC to disconnect link...');
	    NTDSC(2,f2,nul_msg,IOSB);
	    Writeln('done. IOSB[1]=',iosb.int[1]:-6,' IOSB[2]=',iosb.int[2]:-6)
	   END
       END;
    Writeln('End of test.')
    end.	    
