home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / Pascal / 10TLST.ZIP / NETTED.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-09-24  |  6.9 KB  |  226 lines

  1. Program Netted;
  2. Uses DOS,CRT,Tentools;
  3. VAR
  4.    Nodelist : NABuffer;
  5.    SSList : NABuffer;
  6.    DisplayList : NABuffer;
  7.    MaxRows,MaxNodes,MaxSS,MaxDisplay : Integer;
  8.    P2 : String;
  9.    QNode : S12;
  10.    CNode : S12;
  11.    I,L : Integer;
  12.    TestLetter : Char;
  13.    NetRet,RetCode : Word;
  14.    Super,WS : Boolean;
  15.    Sorted : Boolean;
  16.    TempNode : S12;
  17.    Param : Array[1..2] of String;
  18.  
  19. Procedure ErrorOut(ECode : Word);
  20. Begin
  21.    Writeln('Error in Tentools function NODES: ',ECode);
  22.    Halt;
  23. End;
  24.  
  25. Procedure Help;
  26. Begin
  27.    Writeln('Syntax:  NETTED [<S,W,*,!>] [<nodename>]');
  28.    Writeln(' where    "S" returns Superstations only');
  29.    Writeln('          "W" returns Workstations (& Superstations)');
  30.    Writeln('          "*" (same as "W")');
  31.    Writeln('          "!" returns the status of your local node');
  32.    Writeln('  and  <nodename> returns only the status of that node.');
  33.    Writeln(' NOTE: Usage with a nodename will return to DOS with ErrorCode set');
  34.    Writeln('       to 1 for a return of FALSE, or 0 for TRUE. Usage with "!"');
  35.    Writeln('       will also return a 0 if the local node is "Loaded" or a 1');
  36.    Writeln('       if it is not!');
  37.    Halt;
  38. End;
  39.  
  40. Function InGroup(NodeName : S12;VAR Group : NABuffer; Max : Integer): Boolean;
  41. { This function checks for the inclusion of Nodename in the NABuffer array
  42. "Group". Max is the size of the group. }
  43. VAR
  44.    I : Integer;
  45. Begin
  46.    I:=1;
  47.    While ((Group[I]<>Nodename)and(I<Max)) do Inc(I);
  48.    InGroup:=(Group[I]=Nodename);
  49. end;
  50.  
  51.  
  52. Begin
  53.    QNode:='';
  54.    TestLetter:=#0;
  55.    If ParamCount=0
  56.    then Help
  57.    else
  58.     begin
  59.        Param[1]:=ParamStr(1);
  60.        If (ParamCount>1)
  61.        then
  62.         begin
  63.            Param[2]:=ParamStr(2);
  64.            If (Length(Param[1])>1)
  65.            then
  66.             begin
  67.                QNode:=Param[1];
  68.                TestLetter:=Upcase(Param[2][1]);
  69.             end
  70.            else
  71.             begin
  72.                QNode:=Param[2];
  73.                TestLetter:=Upcase(Param[1][1]);
  74.             end;
  75.         end
  76.        else
  77.         begin
  78.            if (Length(Param[1])=1)
  79.            then TestLetter:=Upcase(Param[1][1])
  80.            else QNode:=Param[1];
  81.         end;
  82.        If QNode<>''
  83.        then
  84.         begin
  85.            for I:=1 to Length(QNode) do QNode[I]:=Upcase(QNode[I]);
  86.            While length(QNode)<12 do QNode:=QNode+' ';
  87.         end;
  88.     end;
  89.    IF TestLetter='!'
  90.    then
  91.     begin
  92.        if Loaded
  93.        then
  94.         begin
  95.            QNode:=Nodename;
  96.            TextColor(White);
  97.            Write(QNode,' is currently on the Network!');
  98.            Halt(0);
  99.         end
  100.        else
  101.         begin
  102.            TextColor(LightRed);
  103.            Write('This Node is NOT currently on the Network!');
  104.            Halt(1);
  105.         end
  106.     end
  107.    else
  108.     begin
  109.        MaxNodes:=140;
  110.        NetRet:=Nodes(Nodelist,MaxNodes,False); {Full list of Nodes}
  111.        If (NetRet<>0) then ErrorOut(NetRet);
  112.        MaxSS:=140;
  113.        NetRet:=Nodes(SSList,MaxSS,True);       {List of Superstations}
  114.        If (NetRet<>0) then ErrorOut(NetRet);
  115.        If (QNode<>'')
  116.        then
  117.         begin
  118.            Super:=InGroup(QNode,SSList,MaxSS);
  119.            If not Super then WS:=InGroup(QNode,NodeList,MaxNodes)
  120.            else WS:=True;
  121.            Case Testletter of
  122.            #0,'W' : If WS
  123.                     then
  124.                      begin
  125.                         RetCode:=0;
  126.                         TextColor(White);
  127.                      end
  128.                     else
  129.                      begin
  130.                         RetCode:=1;
  131.                         TextColor(LightRed);
  132.                      end;
  133.            'S' : If Super
  134.                  then
  135.                   begin
  136.                      RetCode:=0;
  137.                      TextColor(White);
  138.                   end
  139.                  else
  140.                   begin
  141.                      RetCode:=1;
  142.                      TextColor(LightRed);
  143.                   end;
  144.            else Help;
  145.            end; {Case}
  146.            If Super then Writeln(QNode,' is a Superstation!')
  147.            else if WS then Writeln(QNode,' is a WorkStation!')
  148.            else Writeln(QNode,' is not currently on the network!');
  149.            Halt(RetCode);
  150.         end
  151.        else
  152.         begin
  153.            QNode:=NodeName;
  154.            For I:=1 to Length(QNode) do QNode[I]:=Upcase(QNode[I]);
  155.            While length(QNode)<12 do QNode:=QNode+' ';
  156.            ClrScr;
  157.            {Sort Nodelist}
  158.            Repeat
  159.               Sorted:=True;
  160.               For I:=1 to MaxNodes-1 do
  161.                if Nodelist[I]>Nodelist[I+1] then
  162.                 begin
  163.                    TempNode:=Nodelist[I];
  164.                    Nodelist[I]:=NodeList[I+1];
  165.                    Nodelist[I+1]:=TempNode;
  166.                    Sorted:=False;
  167.                 end;
  168.            Until Sorted;
  169.            {Sort SSList}
  170.            Repeat
  171.               Sorted:=True;
  172.               For I:=1 to MaxSS-1 do
  173.                if SSlist[I]>SSlist[I+1] then
  174.                 begin
  175.                    TempNode:=SSlist[I];
  176.                    SSlist[I]:=SSList[I+1];
  177.                    SSlist[I+1]:=TempNode;
  178.                    Sorted:=False;
  179.                 end;
  180.            Until Sorted;
  181.            If (TestLetter='S')
  182.            then
  183.             begin
  184.                Move(SSList,DisplayList,Sizeof(SSList));
  185.                MaxDisplay:=MaxSS;
  186.             end
  187.            else
  188.             begin
  189.                Move(Nodelist,DisplayList,Sizeof(Nodelist));
  190.                MaxDisplay:=MaxNodes;
  191.             end;
  192.            For I:=1 to MaxDisplay do
  193.             begin
  194.                MaxRows:=MaxDisplay div 6;
  195.                If (MaxDisplay mod 6)>0 then Inc(MaxRows);
  196.                GotoXY(((I-1) div MaxRows)*13+1,(I-1) mod MaxRows+2);
  197. {               GotoXY(((I-1) mod 4)*20+1,(I-1) div 4+3); }
  198.                If (DisplayList[I]=QNode)
  199.                then
  200.                 begin
  201.                    TextColor(White);
  202.                    Write(DisplayList[I]);
  203.                    If InGroup(DisplayList[I],SSList,MaxSS)
  204.                    then TextColor(LightCyan) else TextColor(White);
  205.                    GotoXY(((I-1) div MaxRows)*13+1,(I-1) mod MaxRows+2);
  206.                    Write(DisplayList[I][1]);
  207.                 end
  208.                else
  209.                 begin
  210.                    TextColor(LightGreen);
  211.                    Write(DisplayList[I]);
  212.                    If InGroup(DisplayList[I],SSList,MaxSS)
  213.                    then TextColor(LightCyan) else TextColor(LightRed);
  214.                    GotoXY(((I-1) div MaxRows)*13+1,(I-1) mod MaxRows+2);
  215.                    Write(DisplayList[I][1]);
  216.                 end;
  217.             end;
  218.           GotoXY(1,MaxRows+3);
  219.           Write(MaxDisplay);
  220.           If (TestLetter='S') then Write(' Superstations ')
  221.           else Write(' Nodes ');
  222.           Writeln('on the Network...');
  223.           Halt(0);
  224.         end;
  225.    End;
  226. End.