help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



Notes

This unit is drop in replacement (partial) for Sysutils. It implements many functions from sysutils but does not cause your CGI/EXE to be about 60K larger. When you are pulling just a few functions from the unit, or you are pulling ones that don't rely on the sysutils initialization/finalization.. the CompactSysutils unit can help you.

Modular Utilities

Recently the CompactSysutils unit has been modularized into nice smaller units so you can pick which one you need: pwFileUtil, pwStrUtil, pwDirUtil, etc. Actually some more useful functions are in those units that aren't even available in the FPC rtl.

Consider also the CompactStrutils unit, the CompactUtils unit (based on KOL/MCK), and still you are able to use the CompactSysutils unit which now wraps the pwStrUtil, pwFileUtil etc units.

When To Use Sysutils

When you absolutely need to use Sysutils is for DateTime routines and some Float routines that currently not part of CompactSysutils, pwStrUtil, pwFileUtil, etc yet.

Download Units

See more notes on the unit here (including links to download it)

Latest units are on the SVN server, and some snapshots on sourceforge with each release of Powtils or sometimes as separate optional downloads.

Documentation

Some notes are on this page

Here are some of the functions included in CompactSTRUtils

  function strpos(str1,str2 : pchar) : pchar;
  function PosEx(const SubStr, S: string; Offset: Cardinal): Integer;
  function AnsiReplaceText(const AText, AFromText, AToText: string): string;

And in CompactSYSutils:


  function IntToStr(Value: integer): string;
  function IntToStr(Value: Int64): string;
  function IntToStr(Value: QWord): string;

  function strcopy(dest,source : pchar) : pchar;assembler;
  function strecopy(dest,source : pchar) : pchar;assembler;
  function strlcopy(dest,source : pchar;maxlen : sizeint) : pchar;assembler;
  function strend(p : pchar) : pchar;assembler;
  function strcomp(str1,str2 : pchar) : longint;assembler;
  function strlcomp(str1,str2 : pchar;l : sizeint) : longint;assembler;
  function stricomp(str1,str2 : pchar) : longint;assembler;
  function strlicomp(str1,str2 : pchar;l : sizeint) : longint;assembler;
  function strscan(p : pchar;c : char) : pchar;assembler;
  function strrscan(p : pchar;c : char) : pchar;assembler;
  function strupper(p : pchar) : pchar;assembler;
  function strlower(p : pchar) : pchar;assembler;

  function StrPas(Str: PChar): string;
  function StrAlloc(Size: cardinal): PChar;
  function strnew(p : pchar) : pchar;
  function StrPCopy(Dest: PChar; Source: string): PChar;
  function StrPLCopy(Dest: PChar; Source: string; MaxLen: SizeUInt): PChar;
  procedure StrDispose(Str: PChar);
  function StrBufSize(Str: PChar): SizeUInt;

  function strcat(dest,source : pchar) : pchar;
  function strlcat(dest,source : pchar;l : SizeInt) : pchar;
  function strmove(dest,source : pchar;l : SizeInt) : pchar;
  function strpos(str1,str2 : pchar) : pchar;

  function StrLen(const Str: PChar): Cardinal; assembler;


  function ChangeFileExt(const FileName, Extension: string): string;
  function ExtractFilePath(const FileName: string): string;
  function ExtractFileDrive(const FileName: string): string;
  function ExtractFileName(const FileName: string): string;
  function ExtractFileExt(const FileName: string): string;
  function ExtractFileDir(Const FileName : string): string;

  function ExtractRelativepath (Const BaseName,DestNAme : String): String;
  function IncludeTrailingPathDelimiter(Const Path : String) : String;
  function IncludeTrailingBackslash(Const Path : String) : String;
  function ExcludeTrailingBackslash(Const Path: string): string;
  function ExcludeTrailingPathDelimiter(Const Path: string): string;
  function IsPathDelimiter(Const Path: string; Index: Integer): Boolean;
  Procedure DoDirSeparators (Var FileName : String);
  Function SetDirSeparators (Const FileName : String) : String;
  Function GetDirs (Var DirName : String; Var Dirs : Array of pchar) : Longint;
  function NewStr(const S: string): PString;
  procedure DisposeStr(S: PString);
  procedure AssignStr(var P: PString; const S: string);
  procedure AppendStr(var Dest: String; const S: string);
  function UpperCase(const s: string): string;
  function LowerCase(const s: string): string; overload;
  function CompareStr(const S1, S2: string): Integer;
  function CompareMemRange(P1, P2: Pointer; Length: cardinal): integer;
  function CompareMem(P1, P2: Pointer; Length: cardinal): Boolean;
  function CompareText(const S1, S2: string): integer;
  function SameText(const s1,s2:String):Boolean;

  function AnsiUpperCase(const s: string): string;
  function AnsiLowerCase(const s: string): string;
  function AnsiCompareStr(const S1, S2: string): integer;
  function AnsiCompareText(const S1, S2: string): integer;
  function AnsiSameText(const s1,s2:String):Boolean;
  function AnsiSameStr(const s1,s2:String):Boolean;
  function AnsiStrComp(S1, S2: PChar): integer;
  function AnsiStrIComp(S1, S2: PChar): integer;
  function AnsiStrLComp(S1, S2: PChar; MaxLen: cardinal): integer;
  function AnsiStrLIComp(S1, S2: PChar; MaxLen: cardinal): integer;
  function AnsiStrLower(Str: PChar): PChar;
  function AnsiStrUpper(Str: PChar): PChar;
  function AnsiLastChar(const S: string): PChar;
  function AnsiStrLastChar(Str: PChar): PChar;

  function Trim(const S: string): string;
  function TrimLeft(const S: string): string;
  function TrimRight(const S: string): string;
  function QuotedStr(const S: string): string;
  function AnsiQuotedStr(const S: string; Quote: char): string;
  function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
  function AdjustLineBreaks(const S: string): string;

  function IsValidIdent(const Ident: string): boolean;

  function IntToHex(Value: integer; Digits: integer): string;
  function IntToHex(Value: Int64; Digits: integer): string;
  function StrToInt(const s: string): integer;
  function TryStrToInt(const s: string; var i : integer) : boolean;
  function StrToInt64(const s: string): int64;
  function TryStrToInt64(const s: string; var i : int64) : boolean;
  function StrToIntDef(const S: string; Default: integer): integer;
  function StrToInt64Def(const S: string; Default: int64): int64;
  function LoadStr(Ident: integer): string;

  Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
  Function FloatToStr(Value: Extended): String;
  Function StrToFloat(Const S : String) : Extended;
  Function StrToFloatDef(Const S: String; Const Default: Extended): Extended;
  Function TryStrToFloat(Const S : String; Var Value: Single): Boolean;
  Function TryStrToFloat(Const S : String; Var Value: Double): Boolean;
  Function TryStrToFloat(Const S : String; Var Value: Extended): Boolean;
  Function TextToFloat(Buffer: PChar; Var Value: Extended): Boolean;
  Function TextToFloat(Buffer: PChar; Var Value; ValueType: TFloatValue): Boolean;

  Function FloatToText(Buffer: PChar; Value: Extended; 
    format: TFloatFormat; Precision, Digits: Integer): Longint;

  Function ByteType(const S: string; Index: Integer): TMbcsByteType;
  Function StrByteType(Str: PChar; Index: Cardinal): TMbcsByteType;
  Function ByteToCharLen(const S: string; MaxLen: Integer): Integer;
  Function CharToByteLen(const S: string; MaxLen: Integer): Integer;
  Function ByteToCharIndex(const S: string; Index: Integer): Integer;
  Function StrCharLength(const Str: PChar): Integer;

  Function FindCmdLineSwitch(const Switch: string; 
    const Chars: TSysCharSet;IgnoreCase: Boolean): Boolean;

  Function FindCmdLineSwitch(const Switch: string; IgnoreCase: Boolean): Boolean;
  Function FindCmdLineSwitch(const Switch: string): Boolean;

  function WrapText(const Line, BreakStr: string; 
    const BreakChars: TSysCharSet;  MaxCol: Integer): string;

  function WrapText(const Line: string; MaxCol: Integer): string;
  function LeftStr(const S: string; Count: integer): string;
  function RightStr(const S: string; Count: integer): string;
  function BCDToInt(Value: integer): integer;







lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505