From 02826f27c912b30bb500133cf665ff7abcaa7c94 Mon Sep 17 00:00:00 2001 From: Hishutup Date: Fri, 4 Sep 2015 22:01:00 -0700 Subject: [PATCH 1/3] Added mteFunctions version check You may think of a better function name. --- trunk/Edit Scripts/mteFunctions.pas | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/trunk/Edit Scripts/mteFunctions.pas b/trunk/Edit Scripts/mteFunctions.pas index 86b4871..0991d46 100644 --- a/trunk/Edit Scripts/mteFunctions.pas +++ b/trunk/Edit Scripts/mteFunctions.pas @@ -5,6 +5,7 @@ A set of useful functions for use in TES5Edit scripts. **LIST OF INCLUDED FUNCTIONS** + - [CheckMteVersion]: compares a required version of mteFunctions to the current one. - [GetVersionString]: gets TES5Edit's version as a string. - [ColorToInt]: gets an integer value representing a color from a TColor record. - [ElementTypeString]: uses ElementType and outputs a string. @@ -145,6 +146,7 @@ unit mteFunctions; const + Ver=1.0; bethesdaFiles = 'Skyrim.esm'#13'Update.esm'#13'Dawnguard.esm'#13'HearthFires.esm'#13 'Dragonborn.esm'#13'Fallout3.esm'#13'FalloutNV.esm'#13'Oblivion.esm'#13 'Skyrim.Hardcoded.keep.this.with.the.exe.and.otherwise.ignore.it.I.really.mean.it.dat'#13 @@ -160,6 +162,22 @@ var sFiles, sGroups, sRecords: string; + +{ + CheckMteVersion + Compares an input float to the current version of mteFunctions. + If the input is greater than or equal to the current version then return true otherwise return False. + + Example usage: + if CheckMteVersion(1.0) then + AddMessage('Up-to-date') + else + raise Exception.Create('Please update your version of mteFunctions.pas'); +} +function CheckMteVersion(flt: float): Boolean; +begin + Result := flt >= Ver; +end; { GetVersionString: From 7ccd250556b3fbd34bdf146b6ab38d30313d42ea Mon Sep 17 00:00:00 2001 From: Hishutup Date: Fri, 4 Sep 2015 22:08:31 -0700 Subject: [PATCH 2/3] Fixed some examples --- trunk/Edit Scripts/mteFunctions.pas | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/trunk/Edit Scripts/mteFunctions.pas b/trunk/Edit Scripts/mteFunctions.pas index 0991d46..9833295 100644 --- a/trunk/Edit Scripts/mteFunctions.pas +++ b/trunk/Edit Scripts/mteFunctions.pas @@ -2490,7 +2490,7 @@ function CheckedToBool(cbs: TCheckBoxState): boolean; code more compact. Example usage: - group := ConstructGroup(frm, frm, 8, 8, 300, 300, 'My Group'); + group := ConstructGroup(frm, frm, 8, 8, 300, 300, 'My Group', ''); } function ConstructGroup(h, p: TObject; top, left, height, width: Integer; caption, t: string): TGroupBox; @@ -2519,7 +2519,7 @@ function ConstructGroup(h, p: TObject; top, left, height, Shortened version of ConstructGroup Example usage: - group := cGroup(frm, frm, 8, 8, 300, 300, 'My Group'); + group := cGroup(frm, frm, 8, 8, 300, 300, 'My Group', ''; } function cGroup(h, p: TObject; top, left, height, width: Integer; caption, t: string): TGroupBox; @@ -2726,7 +2726,7 @@ function cScrollBox(h, p: TObject; height: Integer; Example usage: cb1 := ConstructCheckBox(frm, pnlBottom, 8, 8, 160, - 'Remove persistent references', cbChecked); + 'Remove persistent references', cbChecked, ''); } function ConstructCheckBox(h, p: TObject; top, left, width: Integer; s: String; state: TCheckBoxState; t: string): TCheckBox; @@ -2754,7 +2754,7 @@ function ConstructCheckBox(h, p: TObject; top, left, width: Integer; Example usage: cb1 := cCheckBox(frm, pnlBottom, 8, 8, 160, - 'Remove persistent references', cbChecked); + 'Remove persistent references', cbChecked, ''); } function cCheckBox(h, p: TObject; top, left, width: Integer; s: String; state: TCheckBoxState; t: string): TCheckBox; @@ -2769,7 +2769,7 @@ function cCheckBox(h, p: TObject; top, left, width: Integer; Example usage: lbl3 := ConstructLabel(frm, pnlBottom, 65, 8, 0, 0, - 'Reference removal options:'); + 'Reference removal options:', ''); } function ConstructLabel(h, p: TObject; top, left, height, width: Integer; s, t: String): TLabel; @@ -2801,7 +2801,7 @@ function ConstructLabel(h, p: TObject; top, left, height, Example usage: lbl3 := cLabel(frm, pnlBottom, 65, 8, 0, 0, - 'Reference removal options:'); + 'Reference removal options:', ''); } function cLabel(h, p: TObject; top, left, height, width: Integer; s, t: String): TLabel; From fc1e96f9f71b35b2edd6b7401b1fe3af889de3b9 Mon Sep 17 00:00:00 2001 From: Hishutup Date: Fri, 4 Sep 2015 22:15:33 -0700 Subject: [PATCH 3/3] Added StrToBool I remember that for some reason the jvinterpreter doesn't know this function, so I made my own. --- trunk/Edit Scripts/mteFunctions.pas | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/trunk/Edit Scripts/mteFunctions.pas b/trunk/Edit Scripts/mteFunctions.pas index 9833295..24ca74a 100644 --- a/trunk/Edit Scripts/mteFunctions.pas +++ b/trunk/Edit Scripts/mteFunctions.pas @@ -29,6 +29,7 @@ Returns the path of the first file matching the given filename, if it is found. - [SanitizeFileName]: removes characters not allowed in filenames from a string. - [BoolToStr]: converts a boolean value to a string. + - [StrToBool]: converts a string into a boolean value; - [TimeStr]: returns a time string from a TDateTime. - [FileDateTimeStr]: returns a filename-safe DateTime string from a TDateTime. - [ReverseString]: reverses a string. @@ -760,6 +761,21 @@ function BoolToStr(b: boolean): string; Result := 'False'; end; +{ + StrToBool: + Converts a case-insensive "True" or a "1" string into a bool. + Any other input will result in False + + Example usage: + s := 'TruE'; + if StrToBool(s) then + AddMessage('True'); +} +function StrToBool(s: string): Boolean; +begin + result := (LowerCase(s) = 'true') OR (s = '1'); +end; + { ReverseString: Reverses a string.