Difference between revisions of "ReNamer:Pascal Script:Functions"

From den4b Wiki
Jump to navigation Jump to search
(copy from current user manual)
 
(one big table to sections)
Line 1: Line 1:
{| class="prettytable"
+
=Basic String Handling Routines ==
| <center>'''<nowiki>*** Basic String Handling Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
procedure '''Insert'''(Source: String; var S: String; Index: Integer);
 
procedure '''Insert'''(Source: String; var S: String; Index: Integer);
Line 13: Line 9:
 
function '''Pos'''(Substr: String; S: String): Integer;
 
function '''Pos'''(Substr: String; S: String): Integer;
  
|-
+
== Length Managing Routines ==
| <center>'''<nowiki>*** Length Managing Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
procedure '''SetLength'''(var S: Array; NewLength: Integer);
 
procedure '''SetLength'''(var S: Array; NewLength: Integer);
Line 31: Line 23:
 
function '''Length'''(const S: WideString): Integer;
 
function '''Length'''(const S: WideString): Integer;
  
|-
+
== Unicode String Handling Routines ==
| <center>'''<nowiki>*** Unicode String Handling Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
procedure '''WideInsert'''(const Substr: WideString; var Dest: WideString; Index: Integer);
 
procedure '''WideInsert'''(const Substr: WideString; var Dest: WideString; Index: Integer);
Line 75: Line 63:
 
function '''WideCaseInvert'''(const S: WideString): WideString;
 
function '''WideCaseInvert'''(const S: WideString): WideString;
  
|-
+
== Meta Tags Extraction ==
| <center>'''<nowiki>*** Meta Tags Extraction ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''CalculateMetaTag'''(const FilePath: WideString; const MetaTagName String): String;
 
function '''CalculateMetaTag'''(const FilePath: WideString; const MetaTagName String): String;
  
|-
+
== Regular Expressions ==
| <center>'''<nowiki>*** Regular Expressions ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''ReplaceRegEx'''(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString;
 
function '''ReplaceRegEx'''(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString;
Line 95: Line 75:
 
function '''SubMatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TStringsArray;
 
function '''SubMatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TStringsArray;
  
|-
+
== Unicode Character Handling Routines ==
| <center>'''<nowiki>*** Unicode Character Handling Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''IsWideCharUpper'''(WC: WideChar): Boolean;
 
function '''IsWideCharUpper'''(WC: WideChar): Boolean;
Line 125: Line 101:
 
function '''WideCharLower'''(const WC: WideChar): WideChar;
 
function '''WideCharLower'''(const WC: WideChar): WideChar;
  
|-
+
== Unicode Conversion Routines ==
| <center>'''<nowiki>*** Unicode Conversion Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''WideToAnsi'''(const WS: WideString): String;
 
function '''WideToAnsi'''(const WS: WideString): String;
Line 139: Line 111:
 
function '''UTF8Decode'''(const S: String): WideString;
 
function '''UTF8Decode'''(const S: String): WideString;
  
|-
+
== Basic Conversion Routines ==
| <center>'''<nowiki>*** Basic Conversion Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''IntToStr'''(Value: Integer): String;
 
function '''IntToStr'''(Value: Integer): String;
Line 165: Line 133:
 
function '''Ord'''(X: Char): Byte;
 
function '''Ord'''(X: Char): Byte;
  
|-
+
== Date And Time Routines ==
| <center>'''<nowiki>*** Date And Time Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''Date''': TDateTime;
 
function '''Date''': TDateTime;
Line 213: Line 177:
 
function '''IncMilliSecond'''(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime;
 
function '''IncMilliSecond'''(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime;
  
|-
+
== File Management Routines ==
| <center>'''<nowiki>*** File Management Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''WideFileSize'''(const FileName: WideString): Int64;
 
function '''WideFileSize'''(const FileName: WideString): Int64;
Line 243: Line 203:
 
procedure '''WideScanDirForFolders'''(Dir: WideString; var Folders: TStringsArray; const Recursive, IncludeHidden, IncludeSystem: Boolean);
 
procedure '''WideScanDirForFolders'''(Dir: WideString; var Folders: TStringsArray; const Recursive, IncludeHidden, IncludeSystem: Boolean);
  
|-
+
== File Name Utilities ==
| <center>'''<nowiki>*** File Name Utilities ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''WideExtractFilePath'''(const FileName: WideString): WideString;
 
function '''WideExtractFilePath'''(const FileName: WideString): WideString;
Line 279: Line 235:
 
function '''WideGetEnvironmentVar'''(const VarName: WideString): WideString;
 
function '''WideGetEnvironmentVar'''(const VarName: WideString): WideString;
  
|-
+
== File Read/Write Routines ==
| <center>'''<nowiki>*** File Read/Write Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''FileReadFragment'''(const FileName: WideString; Start, Length: Integer): String;
 
function '''FileReadFragment'''(const FileName: WideString; Start, Length: Integer): String;
Line 297: Line 249:
 
procedure '''FileAppendContent'''(const FileName: WideString; const Content: String);
 
procedure '''FileAppendContent'''(const FileName: WideString; const Content: String);
  
|-
+
== File Properties Routines ==
| <center>'''<nowiki>*** File Properties Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''FileTimeModified'''(const FileName: WideString): TDateTime;
 
function '''FileTimeModified'''(const FileName: WideString): TDateTime;
Line 311: Line 259:
 
function '''SetFileTimeModified'''(const FileName: WideString; const DateTime: TDateTime): Boolean;
 
function '''SetFileTimeModified'''(const FileName: WideString; const DateTime: TDateTime): Boolean;
  
|-
+
== Process Execution Routines ==
| <center>'''<nowiki>*** Process Execution Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
function '''ShellOpenFile'''(const FileName: WideString): Boolean;
 
function '''ShellOpenFile'''(const FileName: WideString): Boolean;
Line 323: Line 267:
 
function '''ExecConsoleApp'''(const CommandLine: String; out Output: String): Cardinal;
 
function '''ExecConsoleApp'''(const CommandLine: String; out Output: String): Cardinal;
  
|-
+
== Interactive Dialogs ==
| <center>'''<nowiki>*** Interactive Dialogs ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
procedure '''ShowMessage'''(const Msg: String);
 
procedure '''ShowMessage'''(const Msg: String);
Line 345: Line 285:
 
function '''WideInputQuery'''(const ACaption, APrompt: WideString; var Value: WideString): Boolean;
 
function '''WideInputQuery'''(const ACaption, APrompt: WideString; var Value: WideString): Boolean;
  
|-
+
== Other Routines ==
| <center>'''<nowiki>*** Other Routines ***</nowiki>'''</center>
 
 
 
|-
 
|
 
  
 
procedure '''Randomize'''();
 
procedure '''Randomize'''();
Line 370: Line 306:
  
 
function '''SizeOf'''(X): Integer;
 
function '''SizeOf'''(X): Integer;
 
|}
 

Revision as of 13:05, 16 June 2009

Basic String Handling Routines

procedure Insert(Source: String; var S: String; Index: Integer);

procedure Delete(var S: String; Index, Count: Integer);

function Copy(S: String; Index, Count: Integer): String;

function Pos(Substr: String; S: String): Integer;

Length Managing Routines

procedure SetLength(var S: Array; NewLength: Integer);

procedure SetLength(var S: String; NewLength: Integer);

procedure SetLength(var S: WideString; NewLength: Integer);

function Length(const S: Array): Integer;

function Length(const S: String): Integer;

function Length(const S: WideString): Integer;

Unicode String Handling Routines

procedure WideInsert(const Substr: WideString; var Dest: WideString; Index: Integer);

procedure WideDelete(var S: WideString; Index, Count: Integer);

procedure WideSetLength(var S: WideString; NewLength: Integer);

function WideLength(const S: WideString): Integer;

function WideCopy(const S: WideString; Index, Count: Integer): WideString;

function WidePos(const SubStr, S: WideString): Integer;

function WidePosEx(const SubStr, S: WideString; Offset: Cardinal): Integer;

function WideUpperCase(const S: WideString): WideString;

function WideLowerCase(const S: WideString): WideString;

function WideCompareStr(const S1, S2: WideString): Integer;

function WideCompareText(const S1, S2: WideString): Integer;

function WideSameText(const S1, S2: WideString): Boolean;

function WideTextPos(const SubStr, S: WideString): Integer;

function WideTrim(const S: WideString): WideString;

function WideReplaceStr(const S, OldPattern, NewPattern: WideString): WideString;

function WideReplaceText(const S, OldPattern, NewPattern: WideString): WideString;

function WideSplitString(const Input, Delimiter: WideString): TStringsArray;

function WideCaseCapitalize(const S: WideString): WideString;

function WideCaseInvert(const S: WideString): WideString;

Meta Tags Extraction

function CalculateMetaTag(const FilePath: WideString; const MetaTagName String): String;

Regular Expressions

function ReplaceRegEx(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString;

function MatchesRegEx(const Input, Find: WideString; const CaseSensitive: Boolean): TStringsArray;

function SubMatchesRegEx(const Input, Find: WideString; const CaseSensitive: Boolean): TStringsArray;

Unicode Character Handling Routines

function IsWideCharUpper(WC: WideChar): Boolean;

function IsWideCharLower(WC: WideChar): Boolean;

function IsWideCharDigit(WC: WideChar): Boolean;

function IsWideCharSpace(WC: WideChar): Boolean;

function IsWideCharPunct(WC: WideChar): Boolean;

function IsWideCharCntrl(WC: WideChar): Boolean;

function IsWideCharBlank(WC: WideChar): Boolean;

function IsWideCharXDigit(WC: WideChar): Boolean;

function IsWideCharAlpha(WC: WideChar): Boolean;

function IsWideCharAlphaNumeric(WC: WideChar): Boolean;

function WideCharUpper(const WC: WideChar): WideChar;

function WideCharLower(const WC: WideChar): WideChar;

Unicode Conversion Routines

function WideToAnsi(const WS: WideString): String;

function AnsiToWide(const S: String): WideString;

function UTF8Encode(const WS: WideString): String;

function UTF8Decode(const S: String): WideString;

Basic Conversion Routines

function IntToStr(Value: Integer): String;

function StrToInt(const S: String): Integer;

function StrToIntDef(const S: String; const Default: Integer): Integer;

function DateToStr(D: TDateTime): String;

function StrToDate(const S: String): TDateTime;

function IntToHex(Value: Integer; Digits: Integer): String;

function HexToInt(const HexNum: String): Integer;

function HexToIntDef(const HexNum: String; Default: Integer): Integer;

function Chr(X: Byte): Char;

function Ord(X: Char): Byte;

Date And Time Routines

function Date: TDateTime;

function Time: TDateTime;

function Now: TDateTime;

function EncodeDate(Year, Month, Day: Word): TDateTime;

function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;

function TryEncodeDate(Year, Month, Day: Word; var Date: TDateTime): Boolean;

function TryEncodeTime(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean;

procedure DecodeDate(const DateTime: TDateTime; var Year, Month, Day: Word);

procedure DecodeTime(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word);

function DayOfWeek(const DateTime: TDateTime): Word;

function DateTimeToUnix(D: TDateTime): Int64;

function UnixToDateTime(U: Int64): TDateTime;

function FormatDateTime(const fmt: String; D: TDateTime): String;

function IncYear(const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime;

function IncMonth(const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime;

function IncWeek(const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime;

function IncDay(const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime;

function IncHour(const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime;

function IncMinute(const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTime;

function IncSecond(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime;

function IncMilliSecond(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime;

File Management Routines

function WideFileSize(const FileName: WideString): Int64;

function WideFileExists(const FileName: WideString): Boolean;

function WideDirectoryExists(const Directory: WideString): Boolean;

function WideForceDirectories(Dir: WideString): Boolean;

function WideCreateDir(const Dir: WideString): Boolean;

function WideDeleteFile(const FileName: WideString): Boolean;

function WideRenameFile(const OldName, NewName: WideString): Boolean;

function WideFileSearch(const Name, DirList: WideString): WideString;

function WideGetCurrentDir: WideString;

function WideSetCurrentDir(const Dir: WideString): Boolean;

procedure WideScanDirForFiles(Dir: WideString; var Files: TStringsArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString);

procedure WideScanDirForFolders(Dir: WideString; var Folders: TStringsArray; const Recursive, IncludeHidden, IncludeSystem: Boolean);

File Name Utilities

function WideExtractFilePath(const FileName: WideString): WideString;

function WideExtractFileDir(const FileName: WideString): WideString;

function WideExtractFileDrive(const FileName: WideString): WideString;

function WideExtractFileName(const FileName: WideString): WideString;

function WideExtractBaseName(const FileName: WideString): WideString;

function WideExtractFileExt(const FileName: WideString): WideString;

function WideChangeFileExt(const FileName, Extension: WideString): WideString;

function WideStripExtension(const FileName: WideString): WideString;

function WideExpandFileName(const FileName: WideString): WideString;

function WideExtractRelativePath(const BaseName, DestName: WideString): WideString;

function WideExtractShortPathName(const FileName: WideString): WideString;

function WideIncludeTrailingPathDelimiter(const S: WideString): WideString;

function WideExcludeTrailingPathDelimiter(const S: WideString): WideString;

function WideSameFileName(const S1, S2: WideString): Boolean;

function WideGetEnvironmentVar(const VarName: WideString): WideString;

File Read/Write Routines

function FileReadFragment(const FileName: WideString; Start, Length: Integer): String;

function FileReadLine(const FileName: WideString; LineNum: Integer): String;

function FileCountLines(const FileName: WideString): Integer;

function FileReadContent(const FileName: WideString): String;

procedure FileWriteContent(const FileName: WideString; const Content: String);

procedure FileAppendContent(const FileName: WideString; const Content: String);

File Properties Routines

function FileTimeModified(const FileName: WideString): TDateTime;

function FileTimeCreated(const FileName: WideString): TDateTime;

function SetFileTimeCreated(const FileName: WideString; const DateTime: TDateTime): Boolean;

function SetFileTimeModified(const FileName: WideString; const DateTime: TDateTime): Boolean;

Process Execution Routines

function ShellOpenFile(const FileName: WideString): Boolean;

function ExecuteProgram(const Command: String; WaitForProgram: Boolean): Cardinal;

function ExecConsoleApp(const CommandLine: String; out Output: String): Cardinal;

Interactive Dialogs

procedure ShowMessage(const Msg: String);

procedure WideShowMessage(const Msg: WideString);

function DialogYesNo(const Msg: String): Boolean;

function WideDialogYesNo(const Msg: WideString): Boolean;

function InputBox(const ACaption, APrompt, ADefault: String): String;

function InputQuery(const ACaption, APrompt: String; var Value: String): Boolean;

function WideInputBox(const ACaption, APrompt, ADefault: WideString): WideString;

function WideInputQuery(const ACaption, APrompt: WideString; var Value: WideString): Boolean;

Other Routines

procedure Randomize();

procedure Sleep(Milliseconds: Cardinal);

procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);

procedure SetClipboardText(const S: WideString);

function GetClipboardText: WideString;

function RandomRange(const AFrom, ATo: Integer): Integer;

function Base64Encode(const S: String): String;

function Base64Decode(const S: String): String;

function GetTickCount: Cardinal;

function SizeOf(X): Integer;