Personal Notes File


PScript File

NOTEFILE comes with a default Pascal Script File (PSCRIPT.TXT) containing some sample Pascal scripts that are used by the PScript menu commands. This file must be present in the same directory as the NOTEFILE.EXE executable; otherwise it will not be utilized by these commands. A practical way to disable Pascal scripting is to remove the PSCRIPT.TXT file from the NOTEFILE directory.

You can open and edit this file with NOTEFILE as any other TXT (text) file. When you open this file with NOTEFILE to view or edit it, the scripts in the file will be displayed on separate cards. The first line of the card will be the script name and the remaining lines must contain program code that conforms to Pascal Script syntax.

At most the first 25 scripts in the PSCRIPT.TXT file will be used by NOTEFILE. Any remaining scripts will be silently ignored during startup of NOTEFILE or a Reload Scripts command. If you do not want some scripts to be loaded, please edit the PSCRIPT.TXT file, go to the relevant script, and put “//” in front of its name (i.e., the first line of the script card).

The PSCRIPT.TXT file must not be longer than 20 Kbytes. Otherwise it will not be loaded and an error message will be given.

The default PSCRIPT.TXT file comes with some sample scripts. You can modify or add new scripts to this file. Scripts have access to three variables which during entry to script contain information about NOTEFILE environment. The script may use and modify these variables. After the script finishes NOTEFILE will modify its environment as appropriate if any of these variables are modified by the script. These variables are:

Name of the variable On entry to the script, the variable contains On exit from the script, the new contents of the variable
CText the contents of the Clipboard. are copied to the Clipboard.
MText the contents (i.e., the Notes Information Area) of the currently open card. replace the contents of the currently open card.
SText a copy of the current selection (if any). replace the current selection or are inserted into the current insertion point.

An additional constant (actually a variable) named LineEnding is added to specify the line terminator for your current environment. Its value is #13#10 in Windows and #10 in Linux. This way, you can write portable code as shown in the examples in the PSCRIPT.TXT file.

You can use normal Pascal code and most of the standard Pascal functions in your scripts. The following additional Free Pascal functions are added to this environment:

function  CurrentYear: Word;
function  DateTimeToStr (DateTime: TDateTime): String;
function  ExtractFileDir (const FileName: String): String;
function  ExtractFileExt (const FileName: String): String;
function  ExtractFileName (const FileName: String): String;
function  PosEx (const SubStr, S: String; Offset: Cardinal): Integer;
function  Random (l: LongInt): LongInt;
procedure Randomize;
procedure ShowMessage (const aMsg: String);
function  StrToDateTime (const s: AnsiString): TDateTime;
function  UTF8Copy (const s: String; StartCharIndex,
    CharCount: Int64): String;
procedure UTF8Delete (var s: String; StartCharIndex, CharCount: Int64);
function  UTF8Length (const s: String): Int64;
function  UTF8LowerCase (const AInStr: String; ALanguage: String): String;
function  UTF8Pos (const SearchForText, SearchInText: String;
    StartPos: Int64): Int64;
function  UTF8StringReplace(const S, OldPattern, NewPattern: String;
    Flags: Byte; ALanguage: String): String;
function  UTF8UpperCase (const AInStr: String; ALanguage: String): String;

Note: Type LongInt is used instead of type Int64 on 32-bit versions of NOTEFILE.

If you need more functions to be added, please contact the author.

For more information about compile-time and run-time errors, please look at the Test PScript command.

Important: The PSCRIPT.TXT file is a UTF-8 encoded text file without BOM. Please be careful when you edit this file with another text editor! Please, also take care not to overwrite your customized PSCRIPT.TXT file by the standard version that comes in the ZIP file of a new version of NOTEFILE during an upgrade process.