{

              
            
               ͻ ͻ ͻ    ͻ ͻ
                    ˼ ͹ ͼ ͹     ͻ
                   ͼ          ͼ ͼ

  The MAX Graphics GUI Kit is Copyright 1995-Current Larry L. Athey (LA-Soft).
  Color Averaging procedures are courtesy of Sean Price (Rude Dog Software).
}
{$I DEFINES.INC}
UNIT GUI_UTIL;

INTERFACE

CONST      {Operating system detection constants.                            }
 _DOS = 0; {DOS                                                              }
  OS2 = 1; {OS/2                                                             }
  WIN = 2; {Windows                                                          }
  DV  = 3; {DesqView                                                         }

VAR
  OS              : BYTE;       {The current operating system detected.      }
  ProgramVersion  : STRING[10]; {The version of your program.                }
  ProgramName     : STRING[40]; {The name of your program.                   }

{}
FUNCTION AllCaps(S : STRING) : STRING;
{^ Converts any string to a completely upper cased string.                   }
FUNCTION Lower(S : STRING) : STRING;
{^ Converts any string to a completely lower cased string.                   }
FUNCTION BooleanToStr(B : BOOLEAN) : STRING;
{^ Takes any boolean variable and returns a "True" or "False" string.        }
FUNCTION BoolToStr(B : BOOLEAN) : STRING;
{^ Takes any boolean variable and returns a "Y" or "N" character.            }
FUNCTION StrToBool(S : STRING) : BOOLEAN;
{^ Takes any string and will return TRUE if UPCASE(S[1]) = 'Y'...            }
FUNCTION IntToStr(N : LONGINT) : STRING;
{^ Converts any LONGINT to a string representation.                          }
FUNCTION StrToInt(S : STRING) : LONGINT;
{^ Converts any numeric string to a LONGINT value.                           }
FUNCTION HexToInt(HexStr : STRING) : LONGINT;
{^ Converts any $### hex string to a LONGINT value.                          }
FUNCTION StripLead(St : STRING; Ch : CHAR) : STRING;
{^ Strips any specified leading characters from a string.                    }
FUNCTION StripTrail(St : STRING; Ch : CHAR) : STRING;
{^ Strings any specified trailing characters from a string.                  }
FUNCTION StripBoth(St : STRING; Ch : CHAR) : STRING;
{^ Performs both functions in the above at the same time.                    }
FUNCTION Center(St : STRING; MaxPlace : BYTE) : STRING;
{^ Takes any string of text and adds the proper amount of spaces at both ends}
{  to make the string appear centered. MaxPlace the ending max string width. }
FUNCTION PadRight(S : STRING; Ch : CHAR; Len : BYTE) : STRING;
{^ Pads the right end of a string with "Ch" characters until it is "Len" wide}
FUNCTION PadLeft(S : STRING; Ch : CHAR; Len : BYTE) : STRING;
{^ Pads the left side of a string with "Ch" characters until it is "Len" wide}
FUNCTION FSize(Fn : PathStr) : LONGINT;
{^ Returns the size of a file in bytes if the file "Fn" is found.            }
FUNCTION FExist(Fn : PathStr) : BOOLEAN;
{^ Returns TRUE if the file "Fn" exists.                                     }
FUNCTION FErase(Fn : PathStr) : BOOLEAN;
{^ Erases the file "Fn" if it exists.                                        }
FUNCTION DExist(DirName : PathStr) : BOOLEAN;
{^ Returns TRUE if the directory/path defined by "DirName" exists.           }
FUNCTION CopyFile(SourceFile,TargetFile : STRING) : BYTE;
{^ Copies one file to another and returns a BYTE value depending on results. }
{  Return Codes:  0. Successful.                                             }
{                 1. Source and target the same.                             }
{                 2. Cannot open source.                                     }
{                 3. Unable to create target.                                }
{                 4. Error during copy.                                      }
FUNCTION GetFileName(InString : STRING) : STRING;
{^ Takes an entire path and file name, and only returns the file name.       }
FUNCTION GetFilePath(InString : STRING) : STRING;
{^ Takes an entire path and file name, and only returns the path name.       }
FUNCTION FixPath(Txt : STRING) : STRING;
{^ Takes a path string and adds a backslash if one doesn't already exist.    }
FUNCTION NoPath(Txt : STRING) : STRING;
{^ Strips the trailing backslash from a path string if one exists.           }
FUNCTION OSstr : STRING;
{^ Returns a verbal message telling you what operating system is running.    }
{}
PROCEDURE MakeDir(DirName : STRING);
{^ Makes a directory on the disk after checking for it's existence first.    }
PROCEDURE TimeSlice;
{^ Returns a time slice (free CPU time) to the operating system. Separate    }
{  time slice routines are included for Windows, OS/2, DesqView and DOS.     }
PROCEDURE DetectOS;
{^ Detects the operating system and sets the OS variable accordingly.        }
PROCEDURE ClearKeyBuffer;
{^ Clears any stray unread characters out of the keyboard buffer.            }
PROCEDURE Execute(Executable,Params : STRING);
{^ Executes an external program, and automatically swaps to EMS, XMS, Disk   }
{  as needed using the best available swapping mode.                         }
PROCEDURE DropToDOS;
{^ Temporarily shells to the command prompt using the same swapping technique}
{  as used by the Execute procedure.                                         }
{}
