home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOTDOC.ZIP / CHAPT15.TXT < prev    next >
Encoding:
Text File  |  1991-02-11  |  7.0 KB  |  178 lines

  1.                                                                    Miscellaneous
  2.  
  3.  
  4.  
  5.  
  6.          "I got the bill for my surgery. Now I know why those doctors were
  7.          wearing masks."
  8.  
  9.                                                                  James H. Barrie
  10.  
  11.  
  12.  
  13.  
  14.          The totMISC unit contains a grab-bag of miscellaneous procedures and
  15.          functions that don't logically fit anywhere else in the Toolkit! One
  16.          day they may grow up to have their own units. Some of these routines
  17.          are required by other parts of the Toolkit, and may be of little value
  18.          to you. Nonetheless, they are here if you need them. The procedures and
  19.          functions are organized into three categories: File, Printer and Misc.
  20.  
  21.  
  22.  
  23. File Routines
  24.  
  25.          The following file related functions are included in the unit:
  26.  
  27.  
  28.          Exist(Filename:string):boolean;
  29.  
  30.          This function returns true if a file can be found. The function is
  31.          passed one parameter indicating the name of the file to look for. The
  32.          filename may include an optional drive or path, and even filemasks are
  33.          supported.
  34.  
  35.  
  36.          Copyfile(Sourcefile,Targetfile:string):byte;
  37.  
  38.          This function physically copies a file like the DOS copy command. The
  39.          function is passed two string parameters: the first string is the name
  40.          of the source file, and the second is the name of the target file. If a
  41.          file with the same name as Target already exists, it will be overwrit-
  42.          ten. The function returns one of the following byte values:
  43.  
  44.               0     successful
  45.               1     source and target the same
  46.               2     cannot open source
  47.               3     unable to create target
  48.               4     error during copy
  49.  
  50.          The function uses a small 2048 byte buffer to copy the file. If you
  51.          want faster file copying, increase the buffer size by modifying the
  52.          variable declaration in the CopyFile function.
  53.  
  54.  
  55.          FSize(Filename:string): longint;
  56.  
  57.          This function returns a longint indicating the size of a file in bytes.
  58.          The function is passed a single string parameter indicating the name of
  59.          the file. The name may optionally include a drive or path qualifier. If
  60.          the file is not found, a -1 is returned.
  61.  
  62. 15-2                                                                User's Guide
  63.  
  64. --------------------------------------------------------------------------------
  65.  
  66.          FileDrive(Full:string): string;
  67.  
  68.          This function extracts and returns the drive letter (without the colon)
  69.          from a filename. The function is passed one string parameter indicating
  70.          the name of the file. If the name does not include a drive, a null is
  71.          returned, i.e. ''.
  72.  
  73.  
  74.          FileDirectory(Full:string): string;
  75.  
  76.          This function extracts the directory path (without the drive letter)
  77.          from a filename. The function is passed one string parameter indicating
  78.          the name of the file. If the name does not include a path, a null is
  79.          returned, i.e. ''. The trailing backslash is always removed.
  80.  
  81.  
  82.  
  83.          FileName(Full:string): string;
  84.  
  85.          This function extracts the file name (excluding the extension) from a
  86.          filename. The function is passed one string parameter indicating the
  87.          name of the file. If the string does not include a name, a null is
  88.          returned, i.e. ''.
  89.  
  90.  
  91.          FileExt(Full:string): string;
  92.  
  93.          This function extracts the file extension (excluding the period) from a
  94.          filename. The function is passed one string parameter indicating the
  95.          name of the file. If the string does not include an extension, a null
  96.          is returned, i.e. ''.
  97.  
  98.  
  99.  
  100.          SlashedDirectory(Dir:string): string;
  101.  
  102.          This function is useful for building fully-qualified filenames. The
  103.          function is passed one string parameter indicating the directory. The
  104.          same directory is returned, with a backslash added if the string did
  105.          not already terminate with a backslash or colon.
  106.  
  107.  
  108.  
  109. Printer Routines
  110.  
  111.          The unit includes the following printer-related procedures and func-
  112.          tions:
  113.  
  114.  
  115.          PrinterStatus: byte;
  116.  
  117.  
  118.  
  119. Miscellaneous                                                               15-3
  120.  
  121. --------------------------------------------------------------------------------
  122.  
  123.          This function is designed to indicate if a parallel printer is attached
  124.          and on-line. The global variable LPTport indicates which port to test.
  125.          Set LPTport to 0 for LPT1 (default), 1 for LPT2, etc. The function
  126.          returns one of the following byte values to indicate the status of the
  127.          printer:
  128.  
  129.               0     printer ready
  130.               1     no paper
  131.               2     off line
  132.               3     busy
  133.               4     undetermined error
  134.  
  135.  
  136.          AlternatePrinterStatus: byte;
  137.  
  138.          This function is very similar in operation to PrinterStatus but uses a
  139.          slightly different technique. If you have problems using PrinterStatus
  140.          with some wierdo printer, try this function instead.
  141.  
  142.  
  143.          PrinterReady: boolean;
  144.  
  145.          This functions returns true if a printer is detected as being on-line
  146.          and ready.
  147.  
  148.  
  149.          ResetPrinter;
  150.  
  151.          These procedure should reset any printer back to its default (boot-up)
  152.          settings.
  153.  
  154.  
  155.          PrintScreen;
  156.  
  157.          This procedure emulates the user pressing the PrtScr key, and dumps the
  158.          visible display to the printer port.
  159.  
  160.  
  161.  
  162. Misc. Routines
  163.  
  164.          You know you're in trouble when you are reading the Miscellaneous sec-
  165.          tion in the Miscellaneous chapter!
  166.  
  167.          Listed below are the remaining Toolkit procedures and functions:
  168.  
  169.  
  170.          Beep;
  171.  
  172.          You guessed! This function emits a brief, but nonetheless irritating,
  173.          beep from the PC speaker.
  174.  
  175.  
  176.          CurrentTime: string;
  177.  
  178.  
  179.  
  180. 15-4                                                                User's Guide
  181.  
  182. --------------------------------------------------------------------------------
  183.  
  184.          This function returns a formatted string representing the current time
  185.          according to the PCs internal clock. The string uses the twelve hour
  186.          format HH:MM:SS a.m./p.m.
  187.  
  188.  
  189.          Swap(var A,B:longint);
  190.  
  191.          This procedure is passed two longint variable parameters. The procedure
  192.          swaps the contents of the two variables, i.e. A is assigned the value
  193.          of B, and B is assigned the value of A.
  194.  
  195.  
  196.          WithinRange(Min,Max,Test:longint):boolean;
  197.  
  198.          This function is passed three longint parameters. The function returns
  199.          true if the third value is greater than or equal to the first parameter
  200.          and less than or equal to the second parameter.
  201.  
  202.  
  203.  
  204.          Be sure to check the README file for any routines that may have been
  205.          added to totMISC since the manual was printed.
  206.