home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PASNET.ZIP / SAMPLE1.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1988-06-28  |  40.2 KB  |  1,155 lines

  1. { This program has been designed to give developers an  example of how to interface
  2. with the assembly library provided.  The library has been revised and the
  3. version contained on this disk should be used in place of the original library
  4. that came with the programmers' guide diskette. The programmers' guide will
  5. help provide a better understanding of what parameters each call needs and
  6. how each function works.  The following declaration needs to made when ever the 
  7. library routines are accessed, since all function calls are referenced from 
  8. the "xtndopn" function.
  9.                          ALWAYS DECLARE THE FOLLOWING:
  10. function xtndopn(var mode,handle:integer;var filename:str):integer; external 'pasneta'; }
  11.  
  12. {===========================================================================================}
  13.  
  14. program FuncInterface;
  15.  
  16. uses
  17.    Dos,
  18.    Crt,
  19.    PasNet;
  20.  
  21.     type   str = string[52];
  22.  
  23.     var
  24.          hex,filename,asciiz,sema4,recstr,request,reply: str;
  25.          Handle, retcode, Hoff, Loff, HLen, LLen, FLAG, TMO, Func, Attribute: integer;
  26.          semavalu,Hihandle,Lohandle,opencnt,volume,newserv: integer;
  27.          I, Len, mode, seg, off: integer;
  28.          ans: char;
  29.  
  30.  
  31. procedure Explain;
  32.  
  33.     begin
  34.         writeln('This program will display a menu of different function calls that can be');
  35.         writeln('performed. Each call will prompt the user for the parameters needed by the');
  36.         writeln('function call.  After a function call has completed execution, the user ');
  37.         writeln('must hit the <enter>  key to get back to the main menu.  This program has ');
  38.         writeln('been written to provide examples of how to use the function call interfaces,');
  39.         writeln('contained in pasneta.asm.');
  40.     write('       Type return to continue: ');
  41.         readln;
  42.         clrscr;
  43.     end;
  44.  
  45.  
  46. function HexConvert(num:integer):str;
  47.     var quot, rem: integer;
  48.         dum:str;
  49.  
  50.     begin
  51.         quot:=num div 16;
  52.         rem:= num mod 16;
  53.       
  54.         case rem of
  55.             0:hex:='0'+hex;
  56.             1:hex:='1'+hex;
  57.             2:hex:='2'+hex;
  58.             3:hex:='3'+hex;
  59.             4:hex:='4'+hex;
  60.             5:hex:='5'+hex;
  61.             6:hex:='6'+hex;
  62.             7:hex:='7'+hex;
  63.             8:hex:='8'+hex;
  64.             9:hex:='9'+hex;
  65.             10:hex:='A'+hex;
  66.             11:hex:='B'+hex;
  67.             12:hex:='C'+hex;
  68.             13:hex:='D'+hex;
  69.             14:hex:='E'+hex;
  70.             15:hex:='F'+hex;
  71.         end;
  72.       
  73.         if quot > 15 then 
  74.             dum:=HexConvert(quot)
  75.         else
  76.             begin
  77.                 case quot of
  78.                     0:hex:='0'+hex;
  79.                     1:hex:='1'+hex;
  80.                     2:hex:='2'+hex;
  81.                     3:hex:='3'+hex;
  82.                     4:hex:='4'+hex;
  83.                     5:hex:='5'+hex;
  84.                     6:hex:='6'+hex;
  85.                     7:hex:='7'+hex;
  86.                     8:hex:='8'+hex;
  87.                     9:hex:='9'+hex;
  88.                     10:hex:='A'+hex;
  89.                     11:hex:='B'+hex;
  90.                     12:hex:='C'+hex;
  91.                     13:hex:='D'+hex;
  92.                     14:hex:='E'+hex;
  93.                     15:hex:='F'+hex;
  94.                 end;
  95.             end;
  96.         hexconvert:=hex;
  97.     end;
  98.  
  99.  
  100. procedure get_filename;
  101.     
  102.     begin
  103.         write('Enter the name of the file you want to use:  ');
  104.         readln(filename);
  105.         write('Press the <enter> key to begin .....');
  106.         readln;
  107.         Len:=length(filename);
  108.         filename[Len+1]:=chr(0);        { Make it an ASCIIZ string }
  109.     end;
  110.  
  111.  
  112. (************************************************************************)
  113. (* Open_File is the Novell Extended Open Function Call. It opens the    *)
  114. (* file shareable, read/write.                                          *)
  115. (************************************************************************)
  116. procedure open;
  117.     
  118.     begin
  119.         get_filename;
  120.         writeln('The file is being opened Sharable Read Write');
  121.         writeln('This is accomplished by placing a hex 42 in the AL register');
  122.         write('Type return to continue......');
  123.     readln;
  124.     flag:=$42;
  125.         clrscr;
  126.         retcode:=xtndopn(flag,handle,filename);
  127.         if retcode <> 0 then 
  128.             writeln('Return code = ',hexconvert(retcode),' file has not been opened')
  129.         else
  130.             begin
  131.                 writeln('The file handle is ',handle,' the return code is : ',retcode);
  132.                 writeln('Remember the file handle number above, it will be needed to release locked records.');
  133.             end;
  134.     end;
  135.  
  136.  
  137. (*************************************************************************)
  138. (* Get or Set file Attributes *)
  139. (*************************************************************************)
  140.  
  141. procedure setget;
  142.     var get:integer;
  143.  
  144.     begin
  145.         get:=0;
  146.         get_filename;
  147.         writeln('Enter a ''0'' to get the attributes.');
  148.         write('Enter a ''1'' to set the attributes: ');
  149.         readln(func);
  150.         if func = 1 then
  151.             begin
  152.                 writeln('Enter one of the following attributes: ');
  153.                 writeln;
  154.                 writeln('1 - Read only. 2 - Hidden. 4 - system. 128 - Sharable.');
  155.                 readln(attribute);
  156.             end
  157.         else 
  158.             get:=1;
  159.         retcode:=setattr(FUNC,ATTRIBUTE,filename);
  160.         if get = 1 then 
  161.             writeln(' The attribute is : ',hexconvert(attribute));
  162.          writeln('The return code is: ',retcode);
  163.     end;
  164.  
  165. (************************************************************************)
  166. (* Set EOJ flag *)
  167. (************************************************************************)
  168.  
  169. procedure SetEOJ;
  170.  
  171.     begin
  172.         writeln('Enter a ''0'' to disable the End Of Job flag.');
  173.     write('Enter a ''1'' to enable the End Of Job flag: ');
  174.         readln(flag);
  175.         retcode:=eojstat(flag);
  176.         writeln('The return code is: ',retcode);
  177.     end;        
  178.  
  179.  
  180. (************************************************************************)
  181. (* Physical record LOG and LOCK  *)
  182. (************************************************************************)
  183.  
  184. procedure Log_Lock;
  185.  
  186.     begin
  187.         ans:='n';
  188.         write('If the target file is already open, type a ''y'': ');
  189.         readln(ans);
  190.         if ans <> 'y' then 
  191.             OPEN
  192.         else
  193.             begin
  194.                 write('Enter the appropriate file handle: ');
  195.                 readln(handle);
  196.             end;
  197.         write('Enter the Low Word Starting Offset of the record: ');
  198.         readln(Loff);
  199.         write('Enter the High Word Starting Offset of the record: ');
  200.         readln(Hoff);
  201.         write('Enter the Low Word Length of the record: ');
  202.         readln(LLen);
  203.         write('Enter the High Word Length of the record: ');
  204.         readln(HLen);
  205.         write('Enter a ''1'' to lock and log, or enter a ''3'' to do a shared lock: ');
  206.     readln(flag);
  207.        if flag = 1 then
  208.             begin
  209.                  write('Enter the lock timeout in 1/18 secs intervals: ');
  210.                 readln(TMO);
  211.             end;
  212.         retcode:=PRLH_Log(handle,Hoff,Loff,HLen,LLen,Flag,TMO);
  213.         writeln('The return code is: ',retcode);
  214.     end;
  215.  
  216.  
  217. (**************************************************************************)
  218. (* PRLH_Rel  -  Release a record, but it keep it in the log table. *)
  219. (* PRLH_CLr  -  Release a record and remove it from the log table (clear the record).*)
  220. (**************************************************************************)
  221.  
  222. procedure Rel_Clr;
  223.  
  224.     begin
  225.         ans:='n';
  226.         writeln('To release a record you must have opened the file and obtained a valid file handle.'); 
  227.     write('To proceed type a ''y'': ');
  228.     readln(ans);
  229.         if ans = 'y' then
  230.             begin
  231.                 write('Enter the file handle of the appropriate file: ');
  232.                 readln(handle);
  233.                 write('Enter the Low Word Starting Offset of the record: ');
  234.         readln(Loff);
  235.             write('Enter the High Word Starting Offset of the record: ');
  236.         readln(Hoff);
  237.             write('Enter the Low Word Length of the record: ');
  238.         readln(LLen);
  239.             write('Enter the High Word Length of the record: ');
  240.         readln(HLen);
  241.             write('If you want to release the record, but not remove it from the log table, type an ''r'': ');
  242.             readln(ans);
  243.             if ans ='r' then
  244.                  begin
  245.                       writeln('Releasing the record...');
  246.                   retcode:=PRLH_Rel(handle,Hoff,Loff,HLen,LLen);
  247.                  end
  248.                 else
  249.                  begin
  250.                       writeln('Removing the record from the log table...');
  251.                    retcode:=PRLH_Clr(handle,Hoff,Loff,HLen,LLen);
  252.                  end;
  253.             writeln('The return code is: ',retcode);
  254.             end;
  255.         end;
  256.  
  257.  
  258. (*********************************************************************)
  259. (* PRLS_Lck  -  Lock the record set (all records in the log table *)
  260. (* PRLS_Rel  -  Release record set  *)
  261. (* PRLS_Clr     Release, and clear the record set from the log table.*)
  262. (*********************************************************************)
  263.  
  264. procedure Lock_Set;
  265.  
  266.     begin
  267.         write('Enter a ''1'' to do a shared lock, nonexclusive:  ');
  268.         readln(flag);
  269.         write('Enter the timeout amount in 1/18 secs intervals, 0 means no wait: ');
  270.     readln(TMO);
  271.       retcode:=PRLS_Lck(flag,TMO);
  272.       writeln('The return code is: ',retcode);
  273.     end;
  274.  
  275.  
  276.  procedure Set_Rel_Clr;
  277.  
  278.     begin
  279.         ans:='n';
  280.       writeln('To release the entire record set without removing the records');
  281.         write('from the log table, enter an ''r'' : ');
  282.     readln(ans);
  283.         if ans = 'r' then
  284.             begin
  285.                 writeln('Releasing the record set...');
  286.                  retcode:=PRLS_Rel;
  287.             end
  288.        else
  289.             begin
  290.                 write('Removing all records from log table...');
  291.                 retcode:=PRLS_Clr;
  292.             end;
  293.         write('Return code is : ',retcode);
  294.     end;
  295.  
  296.  
  297. (**********************************************************************)
  298. (* Open a Semaphore *)
  299. (**********************************************************************)
  300.  
  301. procedure Sem_Open;
  302.  
  303.     begin
  304.         write('Enter the name of the semaphore: ');
  305.     readln(sema4);
  306.         write('Enter the initial semaphore value, it must be positive: ');
  307.     readln(semavalu);
  308.         retcode:=opensem(sema4,semavalu,Hihandle,Lohandle,opencnt);
  309.         writeln;writeln;
  310.         writeln('The return code is : ',retcode);
  311.     writeln('The number of stations using this semaphore is : ',opencnt);
  312.         write('The semaphore handle is : HiPart = ',hexconvert(Hihandle));
  313.         hex:=' ';
  314.         writeln(' LoPart = ',hexconvert(Lohandle));
  315.         writeln('WRITE DOWN THIS HANDLE EXACTLY AS YOU SEE IT, IT WILL BE NEEDED TO ACCESS THIS SEMAPHORE');
  316.         writeln;
  317.     end;
  318.  
  319.  
  320. procedure Sem_Exam;
  321.  
  322.     begin
  323.         writeln('When entering the file handle, enter the HEX digits in the following manner: ');
  324.         writeln('    ie.    low part first: $adcb  (put a ''$'' before the hex digits) ');
  325.         writeln;
  326.         write('Enter the semaphore handle, low part first: ');
  327.     readln(Lohandle);
  328.         write('  enter the high part of the handle: ');
  329.     readln(Hihandle);
  330.         retcode:=ExamSem(Hihandle,Lohandle,semavalu,opencnt);
  331.         writeln('The return code is : ',retcode);
  332.         writeln('The open count is : ',opencnt);
  333.         writeln('The semaphore value is : ',semavalu);
  334.     end;
  335.  
  336.  
  337. procedure Sem_Wait_Sig;
  338.  
  339.     begin
  340.         ans:='n';
  341.         writeln('When entering the file handle, enter the HEX digits in the following manner: ');
  342.         writeln('    ie.    low part first: $adcb  (put a ''$'' before the hex digits) ');
  343.         writeln;
  344.         write('Enter the semaphore handle, low part first: ');
  345.     readln(Lohandle);
  346.         write('  enter the high part of the handle: ');
  347.     readln(Hihandle);
  348.         writeln('     If you desire to SIGNAL the semaphore (increment) ');
  349.         write('  enter an ''s'' else type return: ');
  350.         readln(ans);
  351.         if ans = 's' then 
  352.             retcode:= SigSem(Hihandle,Lohandle)
  353.          else
  354.             begin
  355.                 write('Enter the timeout value in 1/18 secs intervals: ');
  356.         readln(TMO);
  357.         writeln;
  358.                 write('waiting... ');
  359.               retcode:=WaitSem(Hihandle,Lohandle,TMO);
  360.             end;
  361.         writeln('The return code is : ',retcode);
  362.     end;
  363.  
  364.  
  365. procedure Sem_Close;
  366.  
  367.     begin
  368.         writeln('When entering the file handle, enter the HEX digits in the following manner: ');
  369.         writeln('    ie.    low part first: $adcb  (put a ''$'' before the hex digits) ');
  370.         writeln;
  371.         write('Enter the semaphore handle, low part first: ');
  372.     readln(Lohandle);
  373.         write('  enter the high part of the handle: ');
  374.     readln(Hihandle);
  375.         retcode:= ClosSem(Hihandle,Lohandle);
  376.         writeln('    closing... the return code is : ',retcode);
  377.     end;
  378.  
  379.  
  380. (************************************************************************)
  381. (* GetOrSet_LockMode sets the Lock Mode to 01 as explained in Function      *)
  382. (* call guide.                                                          *)
  383. (************************************************************************)
  384.  
  385. procedure GetOrSet_LockMode;
  386.  
  387.     begin
  388.        writeln('Enter one of the following choices: ');
  389.     writeln;
  390.        writeln('      0 - set to old compatibility mode');
  391.        writeln('      1 - set to new extended locks mode');
  392.        write('      2 - return current lock mode    ---->  ');
  393.     readln(func);
  394.        retcode:=setlck(func);
  395.        writeln('Current lock mode is : ',retcode);
  396.     end;
  397.  
  398.  
  399. (************************************************************************)
  400. (* Transaction Tracking Begin, End, TTS verify, Abort trans,
  401.    Transaction status *)
  402. (************************************************************************)
  403.  
  404.  
  405. procedure TTS_functions;
  406.  
  407.     begin
  408.      writeln('Enter a TTS function code');
  409.         writeln('  Enter a ''0'' to begin a transaction');
  410.         writeln('  Enter a ''1'' to end a transaction (Note - NO Transaction Reference No. is returned)');
  411.         writeln('  Enter a ''2'' to verify whether or not the preferred file server supports transaction tracking');
  412.         writeln('  Enter a ''3'' to abort a transaction');
  413.        write('  ------> ');
  414.     readln(func);
  415.       retcode:=BakOuts(func);
  416.       writeln('The return code is : ',retcode);
  417.     end;
  418.  
  419.  
  420. (*************************************************************************)
  421. (* Begin or End logical locking read-modify-update cycle *)
  422. (*************************************************************************)
  423.  
  424. procedure Logical_Begin_End;
  425.  
  426.     begin
  427.       writeln('To begin logical locking enter a ''b''');
  428.         writeln('To end logical locking enter an ''e''');
  429.         write('-------> ');
  430.     readln(ans);
  431.       if ans = 'b' then
  432.            begin
  433.                 ans:='n';
  434.             write('This function assumes that the Lock Mode has been set to 1. If true, type a ''y'' : ');
  435.             readln(ans);
  436.                 if ans = 'y' then
  437.                  begin
  438.                         write('Enter the time out amount in 1/18 secs intervels : ');
  439.             readln(TMO);
  440.                   retcode:=btrans(TMO);
  441.                         write('Logical locking installed');
  442.                  end;
  443.            end
  444.     else
  445.            begin
  446.                 retcode:=etrans;
  447.         write('Logical locking ended');
  448.            end;
  449.       writeln('The return code is : ',retcode);
  450.     end;
  451.         
  452.  
  453. (**************************************************************************)
  454. (* Logical record lock functions--Log, Lock, Unlock, Unlock set, Clear rec,
  455.    Clear set *)
  456. (**************************************************************************)
  457.  
  458. procedure Logical_locking;
  459.  
  460.     begin
  461.       ans:='n';
  462.       write('This procedure assumes the Lock Mode has been set to 1 if true enter a ''y'': ');
  463.     readln(ans);
  464.       if ans = 'y' then
  465.            begin
  466.             writeln('Choose one of the following functions: ');
  467.             writeln('    0 - Log and Lock a logical record');
  468.             writeln('    1 - Lock all the logical records in the log table');
  469.             writeln('    2 - Release a logical record lock, but do not remove it from the log table');
  470.             writeln('    3 - Release all the logical records in the log table');
  471.             writeln('    4 - Release and remove a logical record it from the log table');
  472.             writeln('    5 - Release and remove the entire logical record set from the log table');
  473.             write(' ----> ');readln(ans);
  474.             if ans ='0' then
  475.                  begin
  476.                   clrscr;
  477.                   writeln('You have chosen to Log and Lock a record ');
  478.             writeln;
  479.                   writeln('Enter a ''1'' to Log and Lock the record (exclusive lock)');
  480.             writeln('Enter a ''3'' to Log and Lock the record  (non-exclusive lock)');
  481.             write('------>');
  482.             readln(flag);
  483.                   write('Enter the record string to lock : ');    
  484.             readln(recstr);
  485.                   write('Enter the time out amount in 1/18 sec intervals : ');
  486.             readln(TMO);
  487.                   retcode:=reclog(recstr,flag,TMO);
  488.                  end
  489.             else if ans = '1' then
  490.                  begin
  491.                   clrscr;
  492.                   writeln('You have chosen to Lock the Record Set ');
  493.                   write('Enter the time out in 1/18 sec intervels : ');    
  494.             readln(TMO);
  495.                   retcode:=reclck(TMO);
  496.                  end
  497.             else if ans = '2' then
  498.                  begin
  499.                   clrscr;
  500.                   writeln('You have chosen to release a record');
  501.                   write('Enter the name of the record string : ');
  502.             readln(recstr);
  503.                   retcode:=reculk(recstr);
  504.                  end
  505.             else if ans = '3' then
  506.                  begin
  507.                   retcode:=reculks;
  508.                   write('Record set released');
  509.                  end
  510.             else if ans = '4' then
  511.                  begin
  512.                   clrscr;
  513.                   writeln('You have chosen to clear a record');
  514.                   write('Enter the name of the record string : ');
  515.             readln(recstr);
  516.                   retcode:=recclr(recstr);
  517.                  end
  518.             else if ans = '5' then
  519.                  begin
  520.                   retcode:=recclrs;
  521.                   write('Record Set Cleared');
  522.                  end;
  523.              writeln('The return code is : ',retcode);
  524.            end;
  525.     end;
  526.  
  527.  
  528. (**********************************************************************)
  529. (* Execute an End Of Job call *)
  530. (**********************************************************************)
  531.  
  532. procedure EndOfJob;
  533.  
  534.     begin
  535.     retcode:=eoj;
  536.     writeln('EOJ function call completed');
  537.       writeln('The return code is : ',retcode);
  538.      end;
  539.  
  540.  
  541. (********************************************************************)
  542. (* Logout from the network *)
  543. (********************************************************************)
  544.  
  545. procedure Sys_logout;
  546.  
  547.     begin
  548.     writeln('Executing the logout function call');
  549.       retcode:=sysout;
  550.       writeln('The return code is : ',retcode);
  551.     end;
  552.  
  553.  
  554. (*******************************************************************)
  555. (* Get the volume statistics *)
  556. (*******************************************************************)
  557.  
  558. procedure Get_Vol_Stat;
  559.  
  560.     begin
  561.        write('Enter the volume number : ');
  562.     readln(volume);
  563.     reply:='hi there';
  564.       retcode:=volstat(volume,reply);
  565.       writeln('executing... The return code is : ',retcode);
  566.       writeln;
  567.       writeln('Number of sectors per block : ',ord(reply[1]),ord(reply[2]));
  568.       writeln('Number of total blocks : ',ord(reply[3]),ord(reply[4]));
  569.       writeln('Number of unused blocks : ',ord(reply[5]),ord(reply[6]));
  570.       writeln('Number of directory entries : ',ord(reply[7]),ord(reply[8]));
  571.       writeln('Number of unused directory entries : ',ord(reply[9]),ord(reply[10]));
  572.       write('Volume Name : ',reply[11],reply[12],reply[13],reply[14],reply[15],reply[16]);
  573.       write(reply[17],reply[18],reply[19],reply[20],reply[21],reply[22]);
  574.       writeln(reply[23],reply[24],reply[25],reply[26]);
  575.       writeln('Removeable flag - 00 if volume is not removeable : ',ord(reply[27]),ord(reply[28]));
  576.     end;
  577.  
  578.  
  579. (***********************************************************************)
  580. (* Find number of local disk that the shell has drives mapped to *)
  581. (***********************************************************************)
  582.  
  583. procedure Number_Loc_drv;
  584.     begin
  585.       retcode:=locdrv;
  586.       writeln('Number of local drives : ',retcode);
  587.     end;
  588.  
  589.  
  590. (***********************************************************************)
  591. (* Get the Logical station number *)
  592. (***********************************************************************)
  593.  
  594. procedure Logical_Sta_Num;
  595.     begin
  596.       retcode:=wsid;
  597.       writeln('The logical station number is : ',retcode);
  598.     end;
  599.         
  600.  
  601. (*************************************************************************)
  602. (* SetErrorMode sets the Error Mode to 1, so that the program will       *)
  603. (* have control.                                                         *)
  604. (*************************************************************************)
  605.  
  606. procedure SetErrorMode;
  607.     begin
  608.        writeln('To set the error mode');
  609.       writeln('Enter one of the following : ');
  610.       writeln('      0 - to display errors on screen');
  611.       writeln('      1 - Extended errors for all file I/O returned in AL');
  612.       writeln('      2 - Critical errors returned in AL (Netware 2.x and up)');
  613.       write('------>  ');
  614.     readln(func);
  615.       retcode:=errmode(func);
  616.       writeln('The previous error mode was : ',retcode);
  617.     end;
  618.  
  619.  
  620. (*************************************************************************)
  621. (* This function allows programs to change the way the shell treats network *)
  622. (* broadcast messages. *)
  623. (*************************************************************************)
  624.  
  625. procedure Change_Bcast;
  626.  
  627.     begin
  628.       writeln('To set the broadcast mode, choose one of the following : ');
  629.       writeln('       0 - Receive console and workstation broadcasts');
  630.       writeln('       1 - Receive console broadcasts only');
  631.       writeln('       2 - Disable receipt of all broadcasts');
  632.       writeln('       3 - Store broadcast messages');
  633.       writeln('       4 - Return current broadcast mode');
  634.       writeln('       5 - Shell timer interrupt checks are disabled');
  635.       writeln('       6 - Shell timer interrupts are enabled');
  636.       write('---->  ');
  637.     readln(func);
  638.       retcode:=bcsmode(func);
  639.       writeln;
  640.     writeln('The current mode is : ',retcode);
  641.     end;      
  642.  
  643.  
  644. (************************************************************************)
  645. (* The Modify LST Device function enables the use of the network spool device*)
  646. (************************************************************************)
  647.  
  648. procedure Spool_func;
  649.  
  650.     begin
  651.       writeln('You have chosen to start your spool device, enter one of the following :');
  652.       writeln('       0 - Start the LST catch');
  653.       writeln('       1 - End the LST catch and queue for printing');
  654.       writeln('       2 - End the LST catch and abort print');
  655.       writeln('       3 - Queue for printing and restart LST catch');
  656.       write('---->  ');
  657.     readln(func);
  658.       retcode:=ctlspl(func);
  659.       writeln;
  660.     writeln('The return code is : ',retcode);
  661.     end;
  662.  
  663.  
  664. (*********************************************************************)
  665. (* Spool data to a capture file located on the server *)
  666. (*********************************************************************)
  667.  
  668. procedure Spool_Capture;
  669.     var packet, tab, copy, prnt, form: integer;
  670.         ban: str;
  671.         res: char;
  672.     
  673.     begin
  674.         ans:='n';
  675.       writeln('Choose one of the following spool functions : ');
  676.       writeln('              0 - Spool data to a capture file on the server');
  677.       writeln('              1 - Close and Queue or Abort the capture file');
  678.       writeln('              2 - Set the spool flags');
  679.       write('---->  ');
  680.     readln(func);
  681.     writeln;
  682.       if func = 0 then
  683.            begin
  684.             writeln('Enter the string to be spooled (length = 1 to 52) :');
  685.               readln(request);
  686.             request:=chr(length(request) + 1) + chr(0) + chr(func) + request;
  687.            end
  688.       else if func = 1 then
  689.            begin
  690.             write('If you want to ABORT the queue type a ''y'' : ');
  691.         readln(ans);
  692.             if ans = 'y' then
  693.                   request:=chr(2) + chr(0) + chr(func) + chr(255)
  694.             else request:=chr(1) + chr(0) + chr(func);
  695.            end
  696.       else if func = 2 then
  697.            begin
  698.             write('Do you want a banner page? (y/n) : ');
  699.         readln(ans);
  700.             if ans = 'y' then 
  701.             packet:=21 
  702.         else packet:=6;
  703.          writeln('Enter the print flags, the choices are: ');
  704.             writeln('    08h - Suppress auto form feed at the end of a print job');
  705.             writeln('    20h - Delete spool file after printing');
  706.             writeln('    40h - Enable tab expansion');
  707.             writeln('    80h - Print a banner page');
  708.             writeln('  example: to suppress form feed and print a banner page add the two numbers');
  709.             writeln('    in HEX --> 008h + 80h = 88h.   TO ENTER --> $88 ($ = HEX) ');
  710.         writeln;
  711.             write('--->  ');
  712.         readln(flag);
  713.         writeln;
  714.             write('Enter the Tab size 1..20 : ');
  715.         readln(tab);
  716.             write('Enter the target printer 0..p : ');
  717.         readln(prnt);
  718.             write('Enter the number of copies to print 0..255 (0 copies = no printing : ');
  719.         readln(copy);
  720.             write('Enter the form type 0..255 : ');
  721.         readln(form);
  722.             write('Enter the string for the banner 1..13 chars : ');
  723.         readln(ban);
  724.             request:=chr(packet)+chr(0)+chr(2)+chr(flag)+chr(tab)+chr(prnt)+chr(copy)+chr(form)+res+ban+chr(0);
  725.         end;
  726.     reply:=chr(0) + chr(0);
  727.       retcode:=splreq(request,reply);
  728.       writeln('The return code is : ',retcode);
  729.     end;
  730.  
  731. (*************************************************************************)
  732. (* Network Communication Function Calls-- Pipes and broadcast *)
  733. (*************************************************************************)
  734.  
  735. procedure Pipes;
  736.     var numsta,stanum: integer;
  737.         message: str;
  738.  
  739.     begin
  740.         writeln('Choose one of the following piping functions: ');
  741.       writeln;
  742.       writeln('       0 - Send a broadcast message');
  743.       writeln('       1 - Get a broadcast message');
  744.       writeln('       2 - Disable station broadcasts');
  745.       writeln('       3 - Enable station broadcasts');
  746.       writeln('   Pipe functions can be added, see function call manual');
  747.       writeln;
  748.       write('-----> ');
  749.     readln(func);
  750.     writeln;
  751.       reply:=chr(255)+chr(0);
  752.       if func = 0 then
  753.            begin
  754.             writeln('For our purposes, only one station needs to receive the message ');
  755.             write('Enter the station number: ');
  756.         readln(stanum);
  757.         numsta:=1;
  758.             write('Enter the string you want to send: ');
  759.         readln(message);
  760.             request:= chr(length(message)+4)+chr(0)+chr(0)+chr(numsta)+chr(stanum)+chr(length(message))+message;
  761.             retcode:=pipreq(request,reply);
  762.            end
  763.       else if func = 1 then
  764.            begin
  765.             request:=chr(1)+chr(0)+chr(1);
  766.             retcode:=pipreq(request,reply);
  767.             reply[0]:=chr(ord(reply[3])+3);    { make printable to the screen }
  768.             reply[3]:=chr(0);                  { "       "   "       "     "   "    }
  769.             writeln(reply);
  770.            end
  771.       else if func = 2 then
  772.            begin
  773.             request:=chr(1)+chr(0)+chr(2);
  774.             retcode:=pipreq(request,reply);
  775.            end
  776.       else if func = 3 then
  777.            begin
  778.             request:=chr(1)+chr(0)+chr(3);
  779.             retcode:=pipreq(request,reply);
  780.            end;
  781.       writeln;
  782.       writeln('Error code is: ',retcode);
  783.     end;
  784.  
  785.  
  786. (************************************************************************)
  787. (* Directory Request functions *)
  788. (************************************************************************)
  789.  
  790. procedure directory;
  791.     var sbase: integer;
  792.  
  793.     begin
  794.       writeln('Get the Base Path Mapping for the entered drive');
  795.       write('Enter a SOURCEBASE (drive handle--1 or 2): ');
  796.     readln(sbase);
  797.       request:=chr(2)+chr(0)+chr(1)+chr(sbase);
  798.       reply:=chr(255)+chr(0);
  799.       retcode:=dpath(request,reply);
  800.       reply[0]:=chr(ord(reply[3])+3);
  801.       reply[3]:=chr(0);
  802.       writeln('Return code is: ',retcode);
  803.       writeln(reply);
  804.     end;
  805.  
  806.  
  807. (*************************************************************************)
  808. (* Log request functions  *)
  809. (**************************************************************************)
  810.  
  811. procedure SystemLog;
  812.     var connection: integer;
  813.  
  814.     begin
  815.       writeln('Get a Stations Logged Information');
  816.           write('Enter the logical station number or connection number:  ');
  817.       readln(connection);
  818.       request:=chr(2)+chr(0)+chr(5)+chr(connection);
  819.       reply:=chr(255)+chr(1);
  820.       retcode:=syslog(request,reply);
  821.       reply[0]:=chr(255);
  822.       writeln('The return code is: ',retcode);
  823.       writeln('The return string is: ');
  824.       writeln(reply);
  825.     end;
  826.  
  827.  
  828. (************************************************************************)
  829. (* Get the Date/Time String *)
  830. (************************************************************************)
  831.  
  832. procedure GetTime;
  833.  
  834.     var time:str;
  835.      begin
  836.             retcode:=nettod(time);  { The value in the str is found at byte#-1 }
  837.           writeln('The return code is: ',retcode);
  838.             writeln('The month/day/year is: ',ord(time[1]),'/',ord(time[2]),'/',ord(time[0]));
  839.             writeln('The time is: ',ord(time[3]),':',ord(time[4]),':',ord(time[5]));
  840.             case ord(time[6]) of
  841.            0:writeln('The day is Sunday');
  842.            1:writeln('The day is Monday');
  843.            2:writeln('The day is Tuesday');
  844.            3:writeln('The day is Wednesday');
  845.            4:writeln('The day is Thursday');
  846.            5:writeln('The day is Friday');
  847.            6:writeln('The day is Saturday');
  848.           end;
  849.      end;
  850.  
  851.  
  852. (*************************************************************************)
  853. (* Get the shell's Base Status *)
  854. (*************************************************************************)
  855.  
  856. procedure driveHand;
  857.     var drive: integer;
  858.  
  859.     begin
  860.           write('Enter the drive number to check (A = 0, B = 1 etc.): ');
  861.     readln(drive);
  862.       retcode:=drvmap(drive);
  863.       writeln('The network pathbase (drive handle) is: ',retcode);
  864.     end;
  865.  
  866.  
  867. (*************************************************************************)
  868. (* Return the Shell Version *)
  869. (*************************************************************************)
  870.  
  871. procedure RetShellVer;
  872.     var envirstr: str;
  873.         mode: integer;
  874.  
  875.     begin
  876.       writeln('Enter the mode:');
  877.     writeln('       0 - Find hardware type only');
  878.       writeln('       1 - get the OS, version and hardware type');
  879.       write('------>  ');
  880.     readln(mode);
  881.       if mode = 0 then
  882.            begin
  883.             retcode:=retshl(envirstr,mode);
  884.             writeln('Hardware type is: ',retcode);
  885.             writeln('The type is defined as follows: 0 - IBM PC, 1 - Victor 9000');
  886.            end
  887.       else
  888.            begin
  889.             retcode:=retshl(envirstr,mode);
  890.             envirstr[0]:=chr(30);
  891.             writeln(envirstr);
  892.            end;
  893.     end;
  894.  
  895.  
  896. (*************************************************************************)
  897. (* Log and/or Lock an ASCIIZ String *)
  898. (*************************************************************************)
  899.  
  900. procedure AsciizStr;
  901.  
  902.     begin
  903.       writeln('Choose one of the following:');
  904.         writeln('         0 - Log or Lock the Asciiz string');
  905.       writeln('         1 - Release an Asciiz string');
  906.       writeln('         2 - Clear an Asciiz string');
  907.       write('-------> ');
  908.     readln(func);
  909.       writeln;
  910.       if func = 0 then
  911.            begin
  912.             writeln('Type a ''0'' if you only want to log the string');
  913.         writeln('Type a ''1''if you want to log and lock the string');
  914.         write('-------> ');
  915.         readln(flag);
  916.             write('Enter the string name: ');
  917.         readln(asciiz);
  918.             asciiz[length(asciiz)+1]:=chr(0);
  919.             writeln(asciiz);
  920.             write('Enter the desired timeout value in 1/18 second intervals: ');
  921.         readln(TMO);
  922.             writeln;
  923.             retcode:=asclog(flag,TMO,asciiz);
  924.             end
  925.       else if func = 1 then
  926.            begin
  927.             write('Enter the name of the string to be released: ');
  928.         readln(asciiz);
  929.             asciiz[length(asciiz)+1]:=chr(0);   { Make an asciiz string }
  930.             retcode:=asculkf(asciiz);
  931.            end
  932.       else if func = 2 then
  933.            begin
  934.             write('Enter the name of the string to be cleared: ');
  935.         readln(asciiz);
  936.             asciiz[length(asciiz)+1]:=chr(0);   {Make an asciiz string }
  937.             retcode:=ascclrf(asciiz);
  938.            end;
  939.        writeln('The return code is: ',retcode);
  940.     end;
  941.  
  942.  
  943. (************************************************************************)
  944. (* Get Physical station Number--switch setting on the Network Interface Card*)
  945. (************************************************************************)
  946.  
  947. procedure GetPhsNum;
  948.  
  949.     begin
  950.         retcode:=get_psn;
  951.         writeln('The Physical Station Number is : ',retcode);
  952.     end;
  953.  
  954.  
  955. (************************************************************************)
  956. (* Get the Shell table Addresses *)
  957. (************************************************************************)
  958.  
  959. procedure GetShlAdr;
  960.  
  961.     begin
  962.       writeln('Enter one of the following choices: ');
  963.       writeln('         0 - Get the Drive Handle Table');
  964.       writeln('         1 - Get the Drive Flag Table');
  965.       writeln('         2 - Get the Drive Server Table');
  966.       writeln('         3 - Get the Server Mapping Table');
  967.       write('----->  ');
  968.     readln(mode);
  969.       retcode:=get_sta(mode,seg,off);
  970.       writeln;
  971.       writeln('These segment and offset addresses have been displayed in decimal');
  972.       writeln;
  973.       writeln('The segment address is: ',seg);
  974.       writeln('The offset address is: ',off);
  975.     end;
  976.  
  977.  
  978. (************************************************************************)
  979. (* Set the preferred File Server *)
  980. (************************************************************************)
  981.  
  982. procedure PrefServ;
  983.  
  984.     begin
  985.       writeln('Enter one of the following: ');
  986.       writeln('        0 - Set the preferred file server');
  987.       writeln('        1 - Get the preferred file server');
  988.       writeln('        2 - Get the Effective File Server');
  989.       writeln('        3 - Get the Spooled file server');
  990.       writeln('        4 - Set the primary file server');
  991.       writeln('        5 - Get the Primary file server');
  992.       write('----->  ');
  993.     readln(mode);
  994.       writeln;
  995.       write('Enter the preferred server 1-8:  ');
  996.     readln(newserv);
  997.       retcode:=setserv(mode,newserv);
  998.       writeln('The return code is:  ',retcode);
  999.     end;
  1000.  
  1001.  
  1002. (************************************************************************)
  1003. (* Attach or Detach to a file server *)
  1004. (************************************************************************)
  1005.  
  1006. procedure AttDetServ;
  1007.  
  1008.     begin
  1009.       writeln('Enter one of the following: ');
  1010.       writeln('       0 - Attach to a specfied server');
  1011.       writeln('       1 - Logout and detach from a specified server');
  1012.       writeln('       2 - Logout but do not detach from a specified server');
  1013.       write('----> ');
  1014.     readln(mode);
  1015.       writeln;
  1016.       write('Enter the specified server numbers 1-8: ');
  1017.     readln(newserv);
  1018.       writeln;
  1019.       retcode:=modserv(mode,newserv);
  1020.       writeln('The return code is: ',retcode);
  1021.     end;
  1022.  
  1023.  
  1024. (*************************************************************************)
  1025.  
  1026.  
  1027. procedure menu;
  1028.     var stop:boolean;
  1029.  
  1030.     begin
  1031.         repeat
  1032.             clrscr;
  1033.             stop:=false;
  1034.             hex:=' ';
  1035.             writeln('Choose one of the following: ');
  1036.             writeln('    0 - Get or Set the lock mode');
  1037.             writeln('    1 - OPEN a file');
  1038.             writeln('    2 - SET or Get a files attributes');
  1039.             writeln('    3 - Check the EOJ status');
  1040.             writeln('    4 - Log and Lock a record');
  1041.             writeln('    5 - Release a locked record');
  1042.             writeln('    6 - Lock a record set, all the records in the stations log table');
  1043.             writeln('    7 - Release a locked record set');
  1044.             writeln('    8 - Open a semaphore');
  1045.             writeln('    9 - Examine a semaphore');
  1046.             writeln('    A - Wait semaphore (decrement value) or Signal semaphore (increment value)');
  1047.             writeln('    B - Close a semaphore');
  1048.             writeln('    C - TTS Functions');
  1049.             writeln('    D - Begin or End logical locking read_modify_update cycle');
  1050.             writeln('    E - Logical locking functions');
  1051.             writeln('    F - Execute an End Of Job');
  1052.             writeln('    G - Logout');
  1053.             writeln('    Z - Quit');
  1054.             writeln;
  1055.             writeln('  ENTER A CORRESPONDING CHARACTER OR TYPE RETURN TO SEE THE REST OF THE MENU ');
  1056.             writeln('******************************************************************************');
  1057.             write('----> ');readln(ans);
  1058.         
  1059.             if NOT (ans IN ['0','1','2','3','4','5','6','7','8','9',
  1060.                     'a','b','c','d','e','f','g','z','A','B','C','D','E','F','G','Z']) then
  1061.                 begin
  1062.                     clrscr;
  1063.                     writeln('H - Get the volume statistics');
  1064.                     writeln('I - Get the number of local drives');
  1065.                     writeln('J - Get the logical station number');
  1066.                     writeln('K - Set the error mode');
  1067.                     writeln('L - Set the broadcast mode');
  1068.                     writeln('M - Start the spooler under program control');
  1069.                     writeln('N - Various spooling functions');
  1070.                     writeln('O - Piping functions');
  1071.                     writeln('P - Directory Functions');
  1072.                     writeln('Q - Sytem log functions');
  1073.                     writeln('R - Get the Date/Time string');
  1074.                     writeln('S - Get the shells Base Status');
  1075.                     writeln('T - Get the shell version');
  1076.                     writeln('U - Log, Lock, Release and clear an Asciiz string.');
  1077.                     writeln('     Any Asciiz string function are assuming the Lock mode is 1');
  1078.                     writeln('V - Get the Physical Station Number');
  1079.                     writeln('W - Get the shell table addresses');
  1080.                     writeln('X - Get the preferred server, different functions');
  1081.                     writeln('Y - Attach or Detach a specified server');
  1082.                     writeln('Z - Quit');
  1083.                     writeln;
  1084.                     writeln('       ENTER A CORRESPONDING CHARACTER OR TYPE RETURN TO SEE MENU AGAIN...');
  1085.                     writeln('******************************************************************************');
  1086.                     write('------> ');readln(ans);
  1087.                 end;
  1088.         
  1089.                 clrscr;
  1090.  
  1091.                 case ans of
  1092.                     '0':GetOrSet_LockMode;
  1093.                     '1':OPEN;
  1094.                     '2':SETGET;
  1095.                     '3':SetEOJ;
  1096.                     '4':Log_Lock;
  1097.                     '5':Rel_Clr;
  1098.                     '6':Lock_Set;
  1099.                     '7':Set_Rel_Clr;
  1100.                     '8':Sem_Open;
  1101.                     '9':Sem_Exam;
  1102.                     'a', 'A':Sem_Wait_Sig;
  1103.                     'b', 'B':Sem_Close;
  1104.                     'c', 'C':TTS_Functions;
  1105.                     'd', 'D':Logical_Begin_End;
  1106.                     'e', 'E':Logical_Locking;
  1107.                     'f', 'F':EndOfJob;
  1108.                     'g', 'G':Sys_logout;
  1109.                     'h', 'H':Get_Vol_Stat;
  1110.                     'i', 'I':Number_loc_drv;
  1111.                     'j', 'J':Logical_Sta_Num;
  1112.                     'k', 'K':SetErrorMode;
  1113.                     'l', 'L':Change_Bcast;
  1114.                     'm', 'M':Spool_Capture;
  1115.                     'n', 'N':Spool_Capture;
  1116.                     'o', 'O':Pipes;
  1117.                     'p', 'P':Directory;
  1118.                     'q', 'Q':SystemLog;
  1119.                     'r', 'R':GetTime;
  1120.                     's', 'S':DriveHand;
  1121.                     't', 'T':RetShellVer;
  1122.                     'u', 'U':AsciizStr;
  1123.                     'v', 'V':GetPhsNum;
  1124.                     'w', 'W':GetShlAdr;
  1125.                     'x', 'X':PrefServ;
  1126.                     'y', 'Y':AttDetServ;
  1127.                     'z', 'Z':stop:=true;
  1128.                 end;
  1129.    
  1130.                 if stop = FALSE then
  1131.                 begin
  1132.                      writeln;writeln;
  1133.                  write('Type return to continue... ');readln;
  1134.                     end;                
  1135.         until stop = true;
  1136.     end;
  1137.  
  1138.  
  1139.  
  1140. (**************************** MAIN PROGRAM ******************************)
  1141.  
  1142.     begin
  1143.         clrscr;
  1144.         writeln;writeln;writeln;writeln;
  1145.         writeln('                  SAMPLE FUNCTION CALL LIBRARY INTERFACE ');
  1146.         write('         please type return to continue... ');readln;
  1147.         writeln;
  1148.         explain;
  1149.         writeln;writeln;writeln;writeln;
  1150.         func:=1;
  1151.         retcode:=errmode(func);
  1152.         writeln('The ERROR MODE has been set to 1, to proceed type return');readln;writeln;
  1153.         menu;
  1154.     end.
  1155.