From cf326b1fab06148774530db25844f29f5bf2524b Mon Sep 17 00:00:00 2001 From: Peter Johnson <5164283+delphidabbler@users.noreply.github.com> Date: Tue, 8 Nov 2022 00:37:07 +0000 Subject: [PATCH 01/81] Update csdb collection format docs Add documentation for keys for Delphi 10.2, 10.3, 10.4 & 11.x compilers due to be added to the csdb format in v2.2.0. Marked entries for these keys with `[from v2.2.0]` --- csdb/docs/collection-format.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/csdb/docs/collection-format.html b/csdb/docs/collection-format.html index 5201abe..95be1b4 100644 --- a/csdb/docs/collection-format.html +++ b/csdb/docs/collection-format.html @@ -187,6 +187,10 @@
DelphiXE8
– Delphi XE8 compilerDelphi10S
– Delphi 10 Seattle compilerDelphi101B
– Delphi 10.1 Berlin compilerDelphi102T
– Delphi 10.2 Tokyo compiler [from v2.2.0]Delphi103R
– Delphi 10.3 Rio compiler [from v2.2.0]Delphi104S
– Delphi 10.4 Sydney compiler [from v2.2.0]Delphi11A
– Delphi 11.x Alexandria compiler [from v2.2.0]FPC
– Free Pascal compiler@@ -717,7 +725,7 @@
Credits
and Credits_URL
keys work together.
- If Credits
="See [example 1]"
and Credits_URL
="http://example.com"
and the Extra
key is empty or missing then the extra REML code generated will be See <a href="example.com">example 1</a>.
+ If Credits
="See [example 1]"
and Credits_URL
="http://example.com"
and the Extra
key is empty or missing then the extra REML code generated will be See <a href="example.com">example 1</a>.
Returns the given date time value, which must be in GMT/UTC, as a RFC1123 formatted string.
" Units=SysUtils SeeAlso=NowGMT -TestInfo=advanced +TestInfo=basic Snip=629.dat Delphi2=N Delphi3=Y From f3a134216498f2adfbfea98aafc36337dc53d7b6 Mon Sep 17 00:00:00 2001 From: delphidabbler <5164283+delphidabbler@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:42:45 +0100 Subject: [PATCH 09/81] Update & enhance snippet test information Update `TestInfo` property of snippets that have demo code to `advanced`. Add new `AdvancedTest.Level` property that provides further information about testing of snippets which have `TestInfo=advanced`. Snippets that have demo code were given `AdvancedTest.Level` property with value `demo` while snippets that have unit tests were given `AdvancedTest.Level` property with value `unit-tests`. Add new `AdvancedTest.URL` property to all snippets with `TestInfo=advanced` that had value containing URL of related demo or unit test project. --- collection/arrays.ini | 2 ++ collection/date.ini | 22 ++++++++++++++++ collection/drive.ini | 48 +++++++++++++++++++++++++++++++++++ collection/hex.ini | 38 ++++++++++++++++++++++++++++ collection/maths.ini | 56 +++++++++++++++++++++++++++++++++++++++++ collection/registry.ini | 3 +++ collection/string.ini | 12 +++++++++ collection/winsys.ini | 51 +++++++++++++++++++++++++++++++++++++ 8 files changed, 232 insertions(+) diff --git a/collection/arrays.ini b/collection/arrays.ini index 2692d1f..22966b8 100644 --- a/collection/arrays.ini +++ b/collection/arrays.ini @@ -353,6 +353,8 @@ DescEx="A method-only advanced record that provides utility methods for worki Units=Generics.Defaults SeeAlso=IndexOfByte,ByteArraysEqual,ByteArraysSameStart TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Arrays" Snip=623.dat Delphi2=N Delphi3=N diff --git a/collection/date.ini b/collection/date.ini index 5829ee9..b54df79 100644 --- a/collection/date.ini +++ b/collection/date.ini @@ -57,6 +57,8 @@ Extra="
Adapted from code contributed by Bill Miller.
" Units=SysUtils SeeAlso=DateMonth,DateYear,DayOfYear TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=224.dat Delphi2=Y Delphi3=Y @@ -107,6 +109,8 @@ Units=SysUtils SeeAlso=DateMonth,DateMonthStart,DaysInMonth Depends=DaysInMonth TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=441.dat Delphi2=Y Delphi3=Y @@ -132,6 +136,8 @@ Extra="The date returned is midnight at the beginning of the first day of the Units="SysUtils" SeeAlso=DateMonth,DateMonthEnd TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=442.dat Delphi2=Y Delphi3=Y @@ -157,6 +163,8 @@ Extra="
Based on code contributed by Homolibere.
" Units=SysUtils SeeAlso=DateQuarterStart,DateQuarterEnd TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=413.dat Delphi2=Y Delphi3=Y @@ -182,6 +190,8 @@ Extra="Modified from code contributed by Homolibere.
" Units=SysUtils SeeAlso=DateQuarter,DateQuarterStart TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=414.dat Delphi2=N Delphi3=N @@ -207,6 +217,8 @@ Extra="Modified from code contributed by Homolibere.
" Units=SysUtils SeeAlso=DateQuarter,DateQuarterEnd TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=415.dat Delphi2=N Delphi3=N @@ -301,6 +313,8 @@ Extra="The date returned is midnight at the beginning of the last day of the Units=SysUtils SeeAlso=DateYear,DateYearStart TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=443.dat Delphi2=Y Delphi3=Y @@ -326,6 +340,8 @@ Extra="
The date returned is midnight at the beginning of the first day of the Units=SysUtils SeeAlso=DateYear,DateYearEnd TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=444.dat Delphi2=Y Delphi3=Y @@ -777,6 +793,8 @@ DescEx="
Formats a date in SQL format.
" Units=SysUtils SeeAlso=SQLDateToDateTime TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=237.dat Delphi2=Y Delphi3=Y @@ -802,6 +820,8 @@ Extra="Handles only the date component. Any time component is ignored.
" Units=SysUtils SeeAlso=SQLDate TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=412.dat Delphi2=Y Delphi3=Y @@ -1381,6 +1401,8 @@ DescEx="Returns the date of Easter Sunday for the given year in the Gregorian Extra="
This routine is derived from a snippet taken from the SWAG Archive. That snippet was converted to Pascal by Kerry Sokalsky from Modula-2 code written by Greg Vigneault in 1993.
The algorithm was taken from chapter 4 of "Astronomical Formulae for Calculators" 2nd edition; by Jean Meeus; publisher: Willmann-Bell Inc., ISBN 0-943396-01-8.
The algorithm is valid for all years in the Gregorian calendar, i.e. from 1583 onwards. The extreme dates of Easter are March 22 (as in 1818 and 2285) and April 25 (as in 1886, 1943, 2038).
For more details of the algorithm see this article on Wikipedia.
" Units=SysUtils TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Date" Snip=610.dat Delphi7=Y Delphi2005Win32=Y diff --git a/collection/drive.ini b/collection/drive.ini index 1033d49..bc9ae09 100644 --- a/collection/drive.ini +++ b/collection/drive.ini @@ -8,6 +8,9 @@ [CurentDrive] DescEx="Returns the letter that identifies the current drive.
" Extra="Modified from Bill Miller's snippets collection.
" +TestInfo=advanced +AdvancedTest.Level=demo +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Drive" Snip=352.dat Delphi2=Y Delphi3=Y @@ -32,6 +35,9 @@ DescEx="Gets list of display names for all the system's drives and stores in Units=Classes,ShellAPI,SysUtils Depends=ListDrives,DriveDisplayName SeeAlso=DriveDisplayName,ListDrives +TestInfo=advanced +AdvancedTest.Level=demo +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Drive" Snip=070.dat Delphi2=N Delphi3=N @@ -54,6 +60,9 @@ FPC=Y [DriveRootPath] DescEx="
Returns root drive path for drive with given number.
" SeeAlso=DriveTypeFromPath,IsValidDriveNum +TestInfo=advanced +AdvancedTest.Level=demo +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Drive" Snip=064.dat Delphi2=Y Delphi3=Y @@ -77,6 +86,9 @@ FPC=Y DescEx="Returns type of drive that contains the given (full) path.
" Units=Windows,SysUtils SeeAlso=DriveRootPath,DriveDisplayName,IsValidDrive +TestInfo=advanced +AdvancedTest.Level=demo +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Drive" Snip=028.dat Delphi2=Y Delphi3=Y @@ -100,6 +112,9 @@ FPC=Y DescEx="Returns name of a drive's file system or empty string if file system can't be determined or drive is not valid.
" Units=Windows SeeAlso=VolumeName +TestInfo=advanced +AdvancedTest.Level=demo +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Drive" Snip=138.dat Delphi2=N Delphi3=N @@ -123,6 +138,9 @@ FPC=Y DescEx="Returns the volume name of the given drive or empty string if the volume has no name or the drive is not valid.
" Units=Windows SeeAlso=FileSystemName,DeleteVolumeName,SetVolumeName +TestInfo=advanced +AdvancedTest.Level=demo +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Drive" Snip=137.dat Delphi2=N Delphi3=N @@ -147,6 +165,9 @@ DescEx="Deletes an existing volume label on a given drive. Returns True on su Extra="
Gets information about the size of a drive and the space available to the current user. Returns True if the the required information can be obtained and False if not.
On success AvailBytes is the amount of space available to the current user, TotalBytes is the total number of bytes on the disk that is available to the current user and FreeBytes is the total number of free bytes on the disk.
" Extra="Drive must be a valid drive such as
If per-user disk quotas are being used then the value of AvailBytes maybe less than the free space available on the disk and TotalBytes may be less that the total number of bytes on the disk.
Loosely based on code contributed by Bill Miller.
" Units=SysUtils +TestInfo=advanced +AdvancedTest.Level=demo +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Drive" Snip=166.dat Delphi2=N Delphi3=N @@ -194,6 +218,9 @@ DescEx="Returns the display name for the drive with the given root path.
" Extra="Note: On versions of Delphi that do not support the SysUtils.RaiseLastOSError routine, this call can be replaced by RaiseLastWin32Error.
" Units=ShellAPI,SysUtils SeeAlso=DriveDisplayNames,DriveTypeFromPath,ListDrives +TestInfo=advanced +AdvancedTest.Level=demo +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Drive" Snip=069.dat Delphi2=N Delphi3=N @@ -219,6 +246,9 @@ Extra="Drive can be specified as a disk letter (e.g.
The Drive parameter must either be the name of a local drive (e.g.
Drive can be specified as a disk letter (e.g.
A valid drive can be a disk letter (e.g.
Returns True if the drive specified by the given number is valid and Extra="
Drive numbers must be in the range 0..25, with 0 mapping onto
Note: On versions of Delphi that do not support the < Units=Classes,Windows,SysUtils Depends=MultiSzToStrings SeeAlso=DriveDisplayName,DriveDisplayNames +TestInfo=advanced +AdvancedTest.Level=demo +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Drive" Snip=068.dat Delphi2=N Delphi3=N @@ -364,6 +409,9 @@ DescEx="
Sets the name of the volume on a given drive. Returns True on success Extra="
Returns a hexadecimal representation of the bytes in the given buffer which has the given size.
" SeeAlso=BytesToHex,ByteToHex,LongWordToHex,QuadWordToHex,WordToHex TestInfo=advanced +TestInfo=advanced +AdvancedTest.Level=unit-testsgithub.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=312.dat Delphi2=Y Delphi3=Y @@ -59,6 +63,8 @@ DescEx="Returns a hexadecimal representation of the given array of bytes.
Depends=BufToHex SeeAlso=BufToHex,ByteToHex,LongWordToHex,QuadWordToHex,WordToHex TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=313.dat Delphi2=N Delphi3=N @@ -83,6 +89,8 @@ DescEx="Returns the hexadecimal representation of the given byte value.
" Units=SysUtils SeeAlso=BufToHex,BytesToHex,LongWordToHex,QuadWordToHex,WordToHex TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=314.dat Delphi2=Y Delphi3=Y @@ -107,6 +115,8 @@ DescEx="Returns the hexadecimal representation of the given long (4 byte) wor Units=SysUtils SeeAlso=BufToHex,BytesToHex,ByteToHex,QuadWordToHex,WordToHex TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=315.dat Delphi2=N Delphi3=N @@ -131,6 +141,8 @@ DescEx="
Returns the hexadecimal representation of the given quad (8 byte) wor Units=SysUtils SeeAlso=BufToHex,BytesToHex,ByteToHex,LongWordToHex,WordToHex TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=316.dat Delphi2=N Delphi3=N @@ -155,6 +167,8 @@ DescEx="
Strips any prefix from the given hexadecimal string. Both Delphi ('$' Units=SysUtils SeeAlso=AddHexPrefix TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=310.dat Delphi2=Y Delphi3=Y @@ -180,6 +194,8 @@ Extra="
The hexadecimal string must contain only valid hex digits, optionally Depends=AddHexPrefix SeeAlso=HexToInt,HexToIntDef,TryHexToBuf,TryHexToInt64 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=319.dat Delphi2=N Delphi3=N @@ -205,6 +221,8 @@ Extra="
The hexadecimal string must contain only valid hex digits, optionally Depends=AddHexPrefix SeeAlso=HexToInt64,HexToInt64Def,TryHexToBuf,TryHexToInt TestInfo=advanced +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" +AdvancedTest.Level=unit-tests Snip=320.dat Delphi2=N Delphi3=N @@ -229,6 +247,8 @@ DescEx="
Returns the hexadecimal representation of the given (2 byte) word val Units=SysUtils SeeAlso=BufToHex,BytesToHex,ByteToHex,LongWordToHex,QuadWordToHex TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=317.dat Delphi2=Y Delphi3=Y @@ -254,6 +274,8 @@ Extra="
Assumes that HexStr contains only valid hex digits, optiona Depends=StripHexPrefix SeeAlso=HexToBuf TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=318.dat Delphi2=Y Delphi3=Y @@ -279,6 +301,8 @@ Extra="
Use HexByteSize to determine the size of buffer required. T Depends=TryHexToBuf SeeAlso=TryHexToBuf,HexToBytes,HexToInt,HexToInt64 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=323.dat Delphi2=N Delphi3=N @@ -304,6 +328,8 @@ Extra="
HexStr must contain only valid hex digits, optionally prefi Depends=TBytes,TryHexToBytes SeeAlso=TryHexToBytes,HexToBuf,HexToInt,HexToInt64 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=324.dat Delphi2=N Delphi3=N @@ -329,6 +355,8 @@ Extra="
HexStr must contain only valid hex digits, optionally prefi Depends=TryHexToInt SeeAlso=TryHexToInt,HexToIntDef,HexToBuf,HexToBytes,HexToInt64 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=325.dat Delphi2=N Delphi3=N @@ -354,6 +382,8 @@ Extra="
HexStr must contain only valid hex digits, optionally prefi Depends=TryHexToInt64 SeeAlso=TryHexToInt64,HexToInt64Def,HexToBuf,HexToBytes,HexToInt TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=326.dat Delphi2=N Delphi3=N @@ -379,6 +409,8 @@ Extra="
HexStr may be prefixed by either '$' or '0x' or have no pre Depends=TryHexToInt64 SeeAlso=TryHexToInt64,HexToInt64,HexToIntDef TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=328.dat Delphi2=N Delphi3=N @@ -404,6 +436,8 @@ Extra="
HexStr may be prefixed by either '$' or '0x' or have no pre Depends=TryHexToInt SeeAlso=TryHexToInt,HexToInt,HexToInt64Def TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=327.dat Delphi2=N Delphi3=N @@ -429,6 +463,8 @@ Extra="
The hexadecimal string must not be empty and contain only valid hex di Depends=StripHexPrefix,TryHexToInt SeeAlso=HexToBuf,TryHexToBytes,TryHexToInt,TryHexToInt64 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=321.dat Delphi2=N Delphi3=N @@ -454,6 +490,8 @@ Extra="
The hexadecimal string must contain only valid hex digits, optionally Depends=HexByteSize,TBytes,TryHexToBuf SeeAlso=HexToBytes,TryHexToBuf,TryHexToInt,TryHexToInt64 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Hex" Snip=322.dat Delphi2=N Delphi3=N diff --git a/collection/maths.ini b/collection/maths.ini index a55b2f6..9175ffc 100644 --- a/collection/maths.ini +++ b/collection/maths.ini @@ -56,6 +56,8 @@ DescEx="
Counts the number of digits in the given integer.
" Extra="Contributed by Bill Miller.
" SeeAlso=DigitCount2,DigitCountR TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=202.dat Delphi2=N Delphi3=N @@ -81,6 +83,8 @@ Extra="Based on code suggested by Don Rowlett.
" Units=Math SeeAlso=DigitCount,DigitCountR TestInfo=advanced +TestInfo=advanced +AdvancedTest.Level=unit-testsgithub.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=204.dat Delphi2=N Delphi3=N @@ -105,6 +109,8 @@ DescEx="Counts the number of digits in the given integer using recursion.
Extra="Contributed by Rubem Nascimento da Rocha.
" SeeAlso=DigitCount,DigitCount2 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=417.dat Delphi2=N Delphi3=N @@ -434,6 +440,8 @@ FPC=Y DescEx="Returns the sum of the digits from the given integer, using recursion.
" Extra="Sums of digits of negative numbers are negative, for example
Contributed Rubem Nascimento da Rocha.
" TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=418.dat Delphi2=N Delphi3=N @@ -507,6 +515,8 @@ DescEx="Determines the greatest common divisor of two given non-zero integers Extra="
Uses Euclid's method.
Note that
Modified from code by Hans van Kruijssen.
" SeeAlso=GCD2,LCD TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=201.dat Delphi2=Y Delphi3=Y @@ -531,6 +541,8 @@ DescEx="Determines the greatest common divisor of two given non-zero integers Extra="
Uses a recursive implementation of Euclid's method.
Note that
Modified from code by Hans van Kruijssen.
" SeeAlso=GCD,LCD TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=416.dat Delphi2=Y Delphi3=Y @@ -555,6 +567,8 @@ DescEx="Checks if the given number is prime.
" Extra="On versions of Delphi that support Int64 parameters to the Sqrt function, the type of N, Max & Divisor can be changed to Int64.
Adapted from code contributed by Don Rowlett.
" SeeAlso=IsPrime2 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=232.dat Delphi2=Y Delphi3=Y @@ -579,6 +593,8 @@ DescEx="Checks if the given number is prime.
" Extra="Uses less code than IsPrime and does not require any floating point operations.
Contributed by daniel.
" SeeAlso=IsPrime TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=570.dat Delphi6=Y Delphi7=Y @@ -600,6 +616,8 @@ Extra="Note that
The array must not be empty.
" SeeAlso=MinOfArray_Double,MaxOfArray_Extended,MaxOfArray_Int64,MaxOfArray_Integer,MaxOfArray_Single,Mid_Double,MinMidMax_Double TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=428.dat Delphi2=N Delphi3=N @@ -648,6 +668,8 @@ DisplayName="MaxOfArray (Extended overload)" DescEx="Returns the maximum value contained in the given array of extended precision floating point values.
The array must not be empty.
" SeeAlso=MinOfArray_Extended,MaxOfArray_Double,MaxOfArray_Int64,MaxOfArray_Integer,MaxOfArray_Single,Mid_Extended,MinMidMax_Extended TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=429.dat Delphi2=N Delphi3=N @@ -672,6 +694,8 @@ DisplayName="MaxOfArray (Int64 overload)" DescEx="Returns the maximum value contained in the given array of 64 bit integer values.
The array must not be empty.
" SeeAlso=MinOfArray_Int64,MaxOfArray_Double,MaxOfArray_Extended,MaxOfArray_Integer,MaxOfArray_Single,Mid_Int64,MinMidMax_Int64 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=430.dat Delphi2=N Delphi3=N @@ -696,6 +720,8 @@ DisplayName="MaxOfArray (Integer overload)" DescEx="Returns the maximum value contained in the given array of integer values.
The array must not be empty.
" SeeAlso=MinOfArray_Integer,MaxOfArray_Double,MaxOfArray_Extended,MaxOfArray_Int64,MaxOfArray_Single,Mid_Integer,MinMidMax_Integer TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=431.dat Delphi2=N Delphi3=N @@ -720,6 +746,8 @@ DisplayName="MaxOfArray (Single overload)" DescEx="Returns the maximum value contained in the given array of single precision floating point values.
The array must not be empty.
" SeeAlso=MinOfArray_Single,MaxOfArray_Double,MaxOfArray_Extended,MaxOfArray_Int64,MaxOfArray_Integer,Mid_Single,MinMidMax_Single TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=432.dat Delphi2=N Delphi3=N @@ -745,6 +773,8 @@ DescEx="Returns the middle of three double precision floating point values. Units=Math SeeAlso=Mid_Extended,Mid_Int64,Mid_Integer,Mid_Single,MaxOfArray_Double,MinOfArray_Double,MinMidMax_Double TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=423.dat Delphi2=N Delphi3=N @@ -771,6 +801,8 @@ Extra="
Adapted from code from Bill Miller's snippets collection.
" Units=Math SeeAlso=Mid_Double,Mid_Int64,Mid_Integer,Mid_Single,MaxOfArray_Extended,MinOfArray_Extended,MinMidMax_Extended TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=424.dat Delphi2=N Delphi3=N @@ -796,6 +828,8 @@ DescEx="Returns the middle of three 64 bit integer values.
" Units=Math SeeAlso=Mid_Double,Mid_Extended,Mid_Integer,Mid_Single,MaxOfArray_Int64,MinOfArray_Int64,MinMidMax_Int64 TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=425.dat Delphi2=N Delphi3=N @@ -822,6 +856,8 @@ Extra="Adapted from code from Bill Miller's snippets collection.
" Units=Math SeeAlso=Mid_Double,Mid_Extended,Mid_Int64,Mid_Single,MaxOfArray_Integer,MinOfArray_Integer,MinMidMax_Integer TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=426.dat Delphi2=N Delphi3=N @@ -847,6 +883,8 @@ DescEx="Returns the middle of three single precision floating point values. Units=Math SeeAlso=Mid_Double,Mid_Extended,Mid_Int64,Mid_Integer,MaxOfArray_Single,MinOfArray_Single,MinMidMax_Single TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=427.dat Delphi2=N Delphi3=N @@ -991,6 +1029,8 @@ DisplayName="MinOfArray (Double overload)" DescEx="
Returns the minimum value contained in the given array of double precision floating point values.
The array must not be empty.
" SeeAlso=MaxOfArray_Double,MinOfArray_Extended,MinOfArray_Int64,MinOfArray_Integer,MinOfArray_Single,Mid_Double,MinMidMax_Double TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=433.dat Delphi2=N Delphi3=N @@ -1015,6 +1055,8 @@ DisplayName="MinOfArray (Extended overload)" DescEx="Returns the minimum value contained in the given array of extended precision floating point values.
The array must not be empty.
" SeeAlso=MaxOfArray_Extended,MinOfArray_Double,MinOfArray_Int64,MinOfArray_Integer,MinOfArray_Single,Mid_Extended,MinMidMax_Extended TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=434.dat Delphi2=N Delphi3=N @@ -1039,6 +1081,8 @@ DisplayName="MinOfArray (Int64 overload)" DescEx="Returns the minimum value contained in the given array of 64 bit integer values.
The array must not be empty.
" SeeAlso=MaxOfArray_Int64,MinOfArray_Double,MinOfArray_Extended,MinOfArray_Integer,MinOfArray_Single,Mid_Int64,MinMidMax_Int64 TestInfo=advanced +AdvancedTest.Level=unit-testser] +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=435.dat Delphi2=N Delphi3=N @@ -1063,6 +1107,8 @@ DisplayName="MinOfArray (Integer overload)" DescEx="Returns the minimum value contained in the given array of integer values.
The array must not be empty.
" SeeAlso=MaxOfArray_Integer,MinOfArray_Double,MinOfArray_Extended,MinOfArray_Int64,MinOfArray_Single,Mid_Integer,MinMidMax_Integer TestInfo=advanced +AdvancedTest.Level=unit-testsfArray (Single overload)" +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=436.dat Delphi2=N Delphi3=N @@ -1087,6 +1133,8 @@ DisplayName="MinOfArray (Single overload)" DescEx="Returns the minimum value contained in the given array of single precision floating point values.
The array must not be empty.
" SeeAlso=MaxOfArray_Single,MinOfArray_Double,MinOfArray_Extended,MinOfArray_Int64,MinOfArray_Integer,Mid_Single,MinMidMax_Single TestInfo=advanced +AdvancedTest.Level=unit-testsoStr,FractionToStrEx +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=437.dat Delphi2=N Delphi3=N @@ -1156,6 +1204,8 @@ Units=Types Depends=ResizeRect_B SeeAlso=ResizeRect_B,StretchRect_A,StretchRect_B,ScaleRect,ZoomRatio_A,ZoomRatio_B,ZoomRatio_C TestInfo=advanced +AdvancedTest.Level=unit-tests +AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths" Snip=420.dat Delphi2=N Delphi3=N @@ -1181,6 +1231,8 @@ DescEx="Resizes rectangle R to the width and height given by
Units=Types
SeeAlso=ResizeRect_A,StretchRect_A,StretchRect_B,ScaleRect,ZoomRatio_A,ZoomRatio_B,ZoomRatio_C
TestInfo=advanced
+AdvancedTest.Level=unit-testsmber
+AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths"
Snip=419.dat
Delphi2=N
Delphi3=N
@@ -1289,6 +1341,8 @@ DescEx=" Stretches rectangle R by the given scaling factors and ret
Units=SysUtils,Types
SeeAlso=StretchRect_B,ScaleRect,ResizeRect_A,ResizeRect_B,ZoomRatio_A,ZoomRatio_B,ZoomRatio_C
TestInfo=advanced
+AdvancedTest.Level=unit
+AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths"
Snip=421.dat
Delphi2=N
Delphi3=N
@@ -1315,6 +1369,8 @@ Units=Types
Depends=StretchRect_A
SeeAlso=StretchRect_A,ScaleRect,ResizeRect_A,ResizeRect_B,ZoomRatio_A,ZoomRatio_B,ZoomRatio_C
TestInfo=advanced
+AdvancedTest.Level=unit-tests
+AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths"
Snip=422.dat
Delphi2=N
Delphi3=N
diff --git a/collection/registry.ini b/collection/registry.ini
index e6bb291..cb6f5d8 100644
--- a/collection/registry.ini
+++ b/collection/registry.ini
@@ -8,6 +8,9 @@
[GetRegistryString]
DescEx=" Reads and returns the value named by Name from the registry sub-key SubKey in root key RootKey. String, expanded string and integer value types are all handled, with integer values being converted to strings. Other values types are not supported and cause an exception to be raised. The empty string is returned if the named value does not exist. Checks if the string Value contains a valid numeric value and returns True if so or False if not. If AllowFloat is true then Value may contain a floating point number, otherwise it must be an integer. If TrimWhiteSpace is True any white space surrounding Value is trimmed before testing. Floating point numbers can be in normal or scientific notation. Integers can be expressed as decimal or hexadecimal numbers, with hex numbers prefixed by either Renamed from a routine contributed by Rubem Nascimento da Rocha. Uses recursion. Renamed from a routine contributed by Rubem Nasc
Units=SysUtils,StrUtils
SeeAlso=ReverseStr
TestInfo=advanced
+AdvancedTest.Level=unit-tests
+AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-String"
Snip=439.dat
Delphi2=N
Delphi3=N
@@ -1166,6 +1172,8 @@ DescEx=" Strips all accelerator (' Renamed from a routine contributed by Rubem Nascimento da Rocha. If StrToParse contains adjacent Delimiter charac
Units=Classes
SeeAlso=ExplodeStr,ParseDelims,SplitStr,SplitString
TestInfo=advanced
+AdvancedTest.Level=unit-tests
+AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-String"
Snip=626.dat
Delphi7=Y
Delphi2005Win32=Y
@@ -1587,6 +1597,8 @@ Extra=" If AText contains adjacent Delimiter strings wit
Units=SysUtils,Classes
SeeAlso=ExplodeStr,ParseDelims,ParseStr,SplitStr
TestInfo=advanced
+AdvancedTest.Level=unit-tests
+AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-String"
Snip=627.dat
Delphi7=Y
Delphi2005Win32=Y
diff --git a/collection/winsys.ini b/collection/winsys.ini
index 9b7fc04..1c4bcac 100644
--- a/collection/winsys.ini
+++ b/collection/winsys.ini
@@ -9,6 +9,9 @@
DescEx=" Returns the Windows common files directory. Returns the name of the host computer. Returns the string value named by ValName from the Windows "CurrentVersion" registry key. Checks if the host operating system includes Windows Media Center. Checks if the host operating system is a Windows Tablet edition. Checks if the host operating system is Windows Vista or later. Works correctly even if the application has defined a Windows XP (or other) compatibility mode. Contributed by Laurent Pierre. Checks if the host operating system is on the Windows 9x platform. Checks if the host operating system is Windows 7 (or Windows Server 2
Extra=" Works correctly even if the application has defined a Windows Vista (or other) compatibility mode. Checks if the host operating system is on the Windows NT platform. Checks if the current process is executing as a 32 bit process under WOW64 on 64 bit Windows. Returns the Windows program files directory. Returns the Windows system directory. Returns the Windows temporary directory. Returns the name of the current user. Returns the Windows directory. Returns the Windows product ID. Checks if the program is running under Windows Terminal Server in a remote client session. Note: This function requires Windows NT4 SP4 or later. It does not work on the Windows 9x platform.
+ For any parts of this documentation that don't apply to all collection versions, the applicable versions may be specified using Ruby's twiddle-wakka pessimistic operator. For example ~>2.1
means that the item applies to all versions >=2.1
but <3.0
while ~>2.1.2
means that the item applies to all versions >=2.1.2
but <2.2.0
.
+
The sections in these files are named with identifiers that uniquely identify a snippet. This must be a valid Unicode Pascal identifier. The keys in a section have the following purpose:
++ The sections in these files are named with identifiers that uniquely identify a snippet. This must be a valid Unicode Pascal identifier. The keys in a section have the following purpose: +
DisplayName
@@ -216,44 +230,28 @@ Desc
Description of the snippet as plain text.
- For v2.0.x only, Desc
is ignored if a non-empty DescEx
key is present. At least one of the Desc
or DescEx
keys are required to be present and non-empty.
+ [~>2.0.0]: Desc
is ignored if a non-empty DescEx
key is present. At least one of the Desc
or DescEx
keys are required to be present and non-empty.
+
+ [~>2.1]: Desc
is deprecated and must not be used. DescEx
must be used instead.
DescEx
- Formatted description of the snippet using REML1 code. + Formatted description of the snippet. When present the value must be a valid string of REML1 code. +
+
+ [~>2.0.0]: DescEx
may be empty, in which case the Desc
key is used. Desc
is ignored if DescEx
has a non-empty value. At least one of the Desc
or DescEx
keys are required to be present and non-empty.
- For version 2.0.x only, DescEx
may be empty, in which case the Desc
key is used. Desc
is ignored if DescEx
has a non-empty value. At least one of the Desc
or DescEx
keys are required to be present and non-empty.
+ [~>2.1]: DescEx
is required to be present and non-empty.
May be omitted or empty.
-
- For v2.0.x only, if and only if Extra
is empty, extra information is generated from the Comments
, Credits
and Credits_URL
key values.
-
Credits
2
Text that notes any credits / acknowledgements. Credits
may optionally contain one (and only one) section of text delimited by [
and ]
characters that indicate the presence of a hyperlink. The enclosed text is used as the text of a hyperlink whose URL must be specified in the Credits_URL
key.
- May be omitted or empty. Credits
is ignored if a non-empty Extra
key is present.
+ [~>2.0.0]: May be omitted or empty. Credits
is ignored if a non-empty Extra
key is present.
+
+ [~>2.1]: Deprecated and must not be used. Use Extra
instead.
Credits_URL
2
The URL used in any hyperlink present in the Credits
key.
- Must be present if Credits
specifies a hyperlink. Ignored if Credits
contains no hyperlink section or if a non-empty Extra
key is present.
+ [~>2.0.0]: Must be present if Credits
specifies a hyperlink. Ignored if Credits
contains no hyperlink section or if a non-empty Extra
key is present.
+
+ [~>2.1] Deprecated and must not be used. +
Comments
Text string containing any additional comments about the snippet.
Optional. Ignored if a non-empty Extra
key is present.
+ [~>2.0.0]: May be omitted or empty. Comments
is ignored if a non-empty Extra
key is present.
+
+ [~>2.1]: Deprecated and must not be used. Use Extra
instead.
+
DelphiXXX
& FPC
@@ -423,10 +402,10 @@ DelphiXE8
– Delphi XE8 compilerDelphi10S
– Delphi 10 Seattle compilerDelphi101B
– Delphi 10.1 Berlin compilerDelphi102T
– Delphi 10.2 Tokyo compiler [from v2.2.0]Delphi103R
– Delphi 10.3 Rio compiler [from v2.2.0]Delphi104S
– Delphi 10.4 Sydney compiler [from v2.2.0]Delphi11A
– Delphi 11.x Alexandria compiler [from v2.2.0]Delphi102T
– Delphi 10.2 Tokyo compiler [~>2.2]Delphi103R
– Delphi 10.3 Rio compiler [~>2.2]Delphi104S
– Delphi 10.4 Sydney compiler [~>2.2]Delphi11A
– Delphi 11.x Alexandria compiler [~>2.2]FPC
– Free Pascal compiler@@ -470,20 +449,59 @@
none
– the snippet has not been tested.basic
– the snippet has passed some simple testing.basic
– the snippet has passed some simple, unspecified testing.advanced
– the snippet has passed more advanced testing, usually unit tests.
TestInfo
is optional. If it is not present then its value defaults to basic
.
AdvancedTest.Level
[~>2.2]
+
+ Provides detailed testing information for snippets with TestInfo
=advanced
. Valid values are:
+
unspecified
– the type of advanced testing has not been specified.unit-tests
– the snippet has passed unit tests.demo
- there exists demo code that exercises the snippet.other
- some other form of testing has been used.
+ AdvancedTest.Level
is optional. If it is not present or is empty then its value defaults to unspecified
.
+
+ AdvancedTest.Level
must not be present if TestInfo
≠ advanced
.
+
AdvancedTest.URL
[~>2.2]
+ + The URL of test code relating to the snippet. +
+
+ AdvancedTest.URL
is optional, but if present must be set to a valid URL.
+
+ AdvancedTest.URL
must not be present if TestInfo
≠ advanced
or AdvancedTest.Level
= unspecified
.
+
The format is quite messy, with several keys having similar or overlapping purposes. This has happened because new keys have been added over time while preserving backward compatibility.
- Backwards compatibility with older file formats has now been dropped, but to save development time, some of the old style values have been retained. However some duplication of keys has been removed from the collection. Over time some redundant keys may be removed. + Limited backwards compatibility with v1 file formats was retained for ~>2.0.0 in order to save development time. For ~>2.1 such duplication has been removed from the collection.
+ Do not attempt to use v1 format collection files. +
+ ++ Backwards compatibility is guaranteed for all versions ~>2.0. The file formats are defined in such a way that software designed to read a later collection version can make sensible decisions about missing values when reading earlier versions. +
+ ++ Forwards compatibility is not guaranteed, but every attempt is made to enable software designed to read older collection versions to be able to read newer versions, albeit with some loss of information. To be able to do this software must ignore values and files that it does not understand or expect. +
+ +.ini
files
+ + Given that the some keys duplicate or overlap with others, it can be confusing to know how to process this duplication in software. Here are some tips. +
+ +Desc
& DescEx
+
+ In v2.0.x, both Desc
and DescEx
keys can be found together or individually. Deal with them as follows:
+
DescEx
and ignore Desc
.
+ DescEx
is non-empty, use its value.
+ Desc
is non-empty then convert its plain text value into a REM1 paragraph and proceed as if DescEx
was defined with the REML as its value.
+
+ For ~>2.1 you can expect that DescEx
will always be non-empty and that Desc
does not exist.
+
Credits
, Credits_URL
, Comments
& Extra
+ + In version 2.0.x, various combinations of the above keys can be found. Deal with them as follows: +
+ +
+ If a non-empty Extra
key exists simply use the REML1 code it defines and ignore and Credits
, Credits_URL
and Comments
values.
+
+ Wheres there is no Extra
content do this:
+
Credits
value, but no Credits_URL
value, then create a REML1 paragraph containing the plain text of the Credits
value. Store this.
+ Credits
and Credits_URL
values then create REML1 as explained in footnote 2 and store it.
+ Credits_URL
value but no Credits
value then ignore the value.
+ Comments
value then create a REML1 paragraph containing the plain text value. Store this.
+
+ Now combine any REML1 paragraphs you generated from the Credits
and Comments
values and proceed as if there was an Extra
key with the same value.
+
+ For ~>2.1 you can expect that Credits
, Credits_URL
or Comments
won't exist and simply deal with Extra
if it present.
+
+ It is easy to deal with compilation results. Simply check for the existance of the key matching the required compiler (e.g. DelphiXE8
). If the key exists then read its value, otherwise proceed as if it had the value Q
.
+
+ Note that Delphi 10.2 Tokyo and later are only defined for ~>2.2. +
+ +
+ Before v2.2.0 there was just the single TestInfo
key that provided any information about program testing. v2.2.0 added the AdvancedTest.Level
and AdvancedTest.URL
keys.
+
+ Software that doesn't understand the new keys can safely ignore them and continue to use only TestInfo
.
+
+ ~>2.2 compliant software can get further information about snippets that have received advanced "testing", where such information is available. The possible values are documented above. +
+ +
+ Note that AdvancedTest.Level
= unspecified
simply means we know that "advanced" testing was undertaken, but we don't know exactly what form it took. There can be no URL linking to test source code: if AdvancedTest.URL
is non-empty that is an error and the value should be ignored. If AdvancedTest.Level
is not present then software should assume unspecified
, because that is the key's default value.
+
+ Having AdvancedTest.Level
set to any other value provides additional information. In these cases AdvancedTest.URL
may provide a URL that links to code containing the tests. This could be a source code repository or a Gist, for example. Given that AdvancedTest.URL
is optional, software should be able to handle cases where there is no link to the test code available.
+