http://www.den4b.com/w/api.php?action=feedcontributions&user=Den4b&feedformat=atomden4b Wiki - User contributions [en]2024-03-28T12:43:11ZUser contributionsMediaWiki 1.35.5http://www.den4b.com/w/index.php?title=Product_Registration&diff=3745Product Registration2024-03-07T11:53:36Z<p>Den4b: /* Transferring to a different computer */ Note the maintenance period.</p>
<hr />
<div>__TOC__<br />
<br />
Product registration is a simple process which is necessary to activate your purchase.<br />
<br />
* When you download, install and run a product for the first time you get the '''''Lite''''' version (non-commercial license).<br />
* To activate your purchase or a '''''Pro''''' version (commercial license) you will need a product registration code.<br />
<br />
== Locate your registration code ==<br />
<br />
You will receive your product registration code in an email soon after you complete the purchase. Please locate the registration code, either in plain text or as a file attachment.<br />
<br />
Example of the registration code in plain text:<br />
<pre><br />
C107141523E936CA8FA89F0CF383CCD9EECAB31F<br />
D9A35C5883BACCD2D2CF27F2E197A5C5B984976B<br />
4F83980250425A3A268FC85DA13140F116243B85<br />
45CBD91A62C23C7BEC7186DFA72C274A893229D4<br />
</pre><br />
<br />
'''Note:''' The registration code may be surrounded by dashed lines which <u>should not be included</u> when copying the code into the registration dialog.<br />
<br />
== Activating the registration code ==<br />
<br />
Download, install and run the product that you wish to activate.<br />
<br />
On the first run you should see "''Terms of Use''" dialog. Please click on the "''Enter registration code''" button, copy your registration code and paste it into the "''Registration''" window.<br />
<br />
If you have been using the product already you will not see the "''Terms of Use''" dialog. In that case, please open "''Help''" » "''Register''" from the main menu of the product to get to the "''Registration''" window.<br />
<br />
Product activation can also be [[#Automating product activation|automated]] for deploying on a large number of computers.<br />
<br />
== Registration code not working ==<br />
<br />
If you have any difficulties with registration process, please contact us by email mentioned in the ''About'' dialog, or simply respond to the email in which you have received your registration code.<br />
<br />
== License has expired ==<br />
<br />
If your license has expired, the application will be automatically downgraded from '''''Pro''''' to '''''Lite''''' version.<br />
<br />
A license can have different expiration criteria:<br />
# ''Expiry date'' - Means that your license is no longer valid as it has reached an expiration date. You need to purchase a new license to activate the '''''Pro''''' version.<br />
# ''Upgrade expiry date'' - Means that a period of free upgrades associated with your license has expired. This usually happens when you are using a significantly newer version which falls outside of your "free upgrade" window. You can either fallback to an older version of the application or purchase a new license to activate the '''''Pro''''' version.<br />
<br />
You can remove an expired license by opening "''Help''" » "''Unregister''" from the main menu of the application.<br />
<br />
'''Note:''' You have to remove an expired license before activating a new registration code.<br />
<br />
== Transferring to a different computer ==<br />
<br />
If you wish to transfer your license to a different computer:<br />
# Deactivate on the old computer via "''Help''" » "''Unregister''" from the main menu.<br />
# Activate on the new computer via "''Help''" » "''Register''" using the same registration code.<br />
<br />
Important considerations:<br />
* If your license is limited to a specific number of computers, then the number of activated instances must not exceed the limit.<br />
* If your license is outside of the maintenance period, then you need to use a version of the product which was released before the end of the maintenance period.<br />
<br />
== Automating product activation ==<br />
<br />
Customers who need to perform product activation on a large number of computers can automate this procedure. This can be especially useful when deploying an ''Unlimited'' license across an entire organization.<br />
<br />
Please contact the support team for more information.</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Failed_renaming&diff=3516ReNamer:Failed renaming2023-12-11T15:03:36Z<p>Den4b: Document the "long path" specification. Rephrase the introduction.</p>
<hr />
<div>{{Up|ReNamer}}<br />
{{Expand|<br />
* Give examples for all reasons<br />
* Include possible workarounds}}<br />
<br />
The renaming operation can fail for a variety of reasons.<br />
<br />
The built-in [[ReNamer:Validation|validation process]] attempts to identify common problems prior to renaming by raising warnings during the preview process, but it cannot catch all possible problems.<br />
<br />
The most common reasons for failed renaming are as follows:<br />
<br />
{| class="wikitable"<br />
|-<br />
! Reason<br />
! Solution<br />
|-<br />
| File path is too long<br />
| Shorten the name of the file or any of its parent folders so that the total characters in the entire path is within the limit.<br />
<br />
In Windows, the maximum file path length is '''260 characters''', as defined by the '''MAX_PATH''' constant. As a workaround, use the "long path" specification by prepending the file path with <code>\\?\</code> to effectively raise the maximum length of file paths to '''32,767 characters'''. See the [[ReNamer:Long paths|Long paths]] article for additional information.<br />
|-<br />
| Destination file already exists (name conflict)<br />
| There are multiple options:<br />
* Rename the name in the list (Refer to [[ReNamer:Menus_for_the_Files_pane#Options_menu|Fix conflicting new names]]). <br />
* Rename the 'other' file that is at the destination to avoid conflict.<br />
* [[ReNamer:Manual_editing|Manually edit the new name]] of the file to avoid conflict.<br />
|-<br />
| Source file does not exist<br />
| This can happen because:<br />
* You moved or manually renamed the file outside of ReNamer.<br />
* You [[ReNamer:Renaming_folders|renamed its folder first]].<br />
Just remove the items listed in '''Files''' pane, and then add them again (with the new path).<br />
|-<br />
| The file is being blocked by other program<br />
| Find the program that is currently using the file (using utilities like the '''Windows Task Manager''' or '''Process Explorer''') and close it. (Sometimes the file is still being downloaded, in which case just wait!)<br />
|-<br />
| You don't have sufficient privileges to rename the file.<br />
|Get privileges by contacting the Admin (or the owner if the item is shared on a neighborhood PC). If you are the Admin, check the permissions of the folder.<br />
|-<br />
| Invalid destination path<br />
| You may have included invalid characters to the file name, such as:<br />
<pre><nowiki>\/:*?"<>|</nowiki></pre><br />
|-<br />
| Parent path changed earlier in the list<br />
| A parent folder of the affected file has been renamed earlier in the list, which makes the path of the the affected file incorrect (out of date).<br />
<br />
This can occur when renaming both folders and their contained files/folders at the same time. For this reason, the content must always be renamed first, before the parent, which can be achieved by sorting the list by the ''Folder'' or ''Path'' column in descending order.<br />
<br />
For more information consult [[ReNamer:Renaming folders|Renaming folders]] article.<br />
|}<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Validation&diff=3515ReNamer:Validation2023-12-11T14:47:43Z<p>Den4b: Top navigation added.</p>
<hr />
<div>{{Up|ReNamer}}<br />
{{Expand|<br />
* Article is generally not finished}}<br />
<br />
Validation is a process which tries to prevent common renaming problems by analyzing the list of files and target destinations. A warning message is given when possible problems are discovered. Users should generally eliminate all warnings prior to renaming, otherwise items may [[ReNamer:Failed renaming|fail to rename]].<br />
<br />
Here is a list of reasons for a warning during validation process:<br />
<br />
# There are duplicated destination paths<br />
# New path contains forbidden characters <br />
# New path is already taken by an existing file <br />
# New path exceeds maximum length<br />
<br />
By default, automatic validation is enabled during the preview process. This behavior can be changed from within the [[ReNamer:Program settings|settings]].<br />
<br />
'''Note:''' Validation may require significant amount of time when processing large amount of files.<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Extension&diff=3514ReNamer:Rules:Extension2023-09-22T18:32:13Z<p>Den4b: Filename starts with a dot</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Rearrange|next=ReNamer:Rules:Strip}}<br />
<br />
== Extension Rule ==<br />
<br />
<center>[[Image:ExtensionsRule.png]]</center> <br />
<br />
This rule allows you to attach a new extension. It is useful when the extension of a file is missing (or if the file has a wrong extension). There is an option to find the correct extension based on the file's structure. <br />
<br />
The parameters are as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter <br />
! Details<br />
|-<br />
| New extension <br />
| New extension that has to be added to the filename. <br />
<br />
|-<br />
| Append to the original filename <br />
| If this option is selected, the new extension will be placed after the old extension. <br />
If it is deselected (default option) the new extension will replace the old one.<br />
<br />
|-<br />
| Detect using binary signature <br />
| Try to detect a correct file extension using built-in [[#Binary signatures|Binary signatures]] of commonly used files.<br />
|}<br />
<br />
=== Binary signatures ===<br />
<br />
Sometimes the extension of a file is missing. At other times it is simply wrong, e.g. some downloaded files get the '''aspx''' extension, although they may ''actually'' be '''zip '''or '''pdf''' files. One way to identify the file extension is by trial-and-error: Attach different extensions and try to open the file with its associated application. This is very tedious. <br />
<br />
A far more efficient way is to compare the file's ''digital signature'' with the signatures of known file types and identify the file's type. This is done internally within ReNamer, so you do not have to know what a ''digital signature'' means, or the actual value of the signature for the given file. <br />
<br />
Note that each extension has a range of signatures, and these ranges overlap. This means a given file's signature may match with the signature of several different extensions. In such cases, ReNamer shows the New filename with all matching extensions. For example, "<tt>fileName.wma|wmv|asf</tt>". ReNamer also pops up an error window (because the combined extension is invalid). Just read the suggested extensions and then try them out one by one. This method is still better compared to making wild guesses, because ReNamer suggests only 2-3 extensions.<br />
<br />
For more accurate results, use [[ReNamer:Scripts:TrID|ReNamer with TrID library]], a specialized utility for identifying the file's real extension. Be aware that even TrID often suggests multiple extensions, and you may still have to try them out.<br />
<br />
=== Filename starts with a dot ===<br />
<br />
Many operating systems treat the dot at the start of the filename as an indicator that the file should be hidden. For that reason, the dot at the start of the filename is not considered as a file extension delimiter.<br />
<br />
This behavior can be toggled via an option in the settings file:<br />
<br />
<pre>FirstDotAtFileNameStartIsExtension=1</pre><br />
<br />
The settings file is normally located in the [[Application Data Storage]].<br />
<br />
Examples of filenames and their considered extension depending on the value of the option:<br />
<br />
{| class=wikitable<br />
! Filename<br />
! Extension if 1<br />
! Extension if 0<br />
|-<br />
| file.ext<br />
| .ext<br />
| .ext<br />
|-<br />
| .file.ext<br />
| .ext<br />
| .ext<br />
|-<br />
| .file<br />
| .file<br />
| <br />
|}<br />
<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Replace&diff=3513ReNamer:Rules:Replace2023-08-08T18:49:36Z<p>Den4b: /* Wildcards */ Backreferences explained</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Remove|next=ReNamer:Rules:Rearrange}}<br />
<br />
== Replace Rule ==<br />
<br />
[[Image:ReplaceRule.png|center]]<br />
<br />
This rule removes the specified string from the name and replaces it with another string. It has options to replace the first occurrence, the last occurrence, or all the occurrences. You can replace multiple strings at a time. You can also use wildcards to create simple patterns.<br />
<br />
The parameters are as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter <br />
! Details<br />
|-<br />
| Find <br />
| Enter the string to be replaced. <br />
*You can enter multiple strings at a time. They will be searched &amp; replaced in the order as they appear. Press the + button to insert a separator between two strings. Instead of pressing this button, you can also enter '''*&#124;*''' from the keyboard. <br />
*If the name does not contain the specified string, the rule will not act on it. <br />
*If the name contains more than one of these strings, it will replace them according to the Occurrences parameter.<br />
<br />
|-<br />
| [[Image:PlusButton.png]] button <br />
| Inserts a separator ('''*&#124;*''') sequence between two delimiter entries.<br />
<br />
In that case, the n<sup>th</sup> entry in the '''Find''' field is replaced by the n<sup>th</sup> entry in the '''Replace''' field.<br />
<br />
|-<br />
| Replace <br />
| Enter strings that will replace the "Find" strings. <br />
<br />
Note that the number of strings (separated with '''*&#124;*''') in "Find" and "Replace" fields should be the same. If there is more strings in the "Find" field than in the "Replace" field the spare strings will be removed (replaced with an empty string). If there is more strings in the "Replace" field, the spare strings will be ignored.<br />
<br />
|-<br />
| Insert meta tag <br />
[[Image:ReNamer Insert Meta Tag Button.png]] <br />
<br />
| Click the button to see a list of [[ReNamer:Meta Tags|meta-tags]].<br />
|-<br />
| Occurrences <br />
| In case that strings occur more than once in the filename, specify which occurrences should be replaced.<br />
|-<br />
| Skip extension <br />
| If checked, the file extension will be excluded from the processing and will remain unaffected.<br />
|-<br />
| Case sensitive <br />
| Will only remove a specified string from the name if the case matches exactly.<br />
|-<br />
| Whole words only<br />
| Remove the subject text only when it is whole word, not a part of another word.<br />
<br />
For example, searching for "bar" would not find a match in "foobar" or "bars".<br />
|-<br />
| Interpret symbols as wild cards <br />
| Treat certain symbols as [[#Wildcards|Wildcards]] for matching simple patterns (similar to [[ReNamer:Regular Expressions|Regular Expressions]]). <br />
<br />
|}<br />
<br />
=== Wildcards ===<br />
<br />
{| class="wikitable"<br />
|-<br />
! Wildcard<br />
! Represents<br />
! Example<br />
|-<br />
| <center>*</center> <br />
| any number of characters (including numbers, space, underscores, etc.). <br />
| '''abc*''' equals '''abc''' followed by 0 or more characters.<br />
|-<br />
| <center>?</center> <br />
| Any single character (including numbers, space, underscores, etc.) <br />
| '''ab?d''' equals '''abcd''', '''ab1d''', '''ab d''', '''ab_d''', etc.<br />
|-<br />
| <center>[]</center> <br />
| Brackets enclose a set of characters, any one of which may match a single character at that position. <br />
| '''foo[ab]ar '''equals '''fooaar''' and '''foobar'''<br />
|-<br />
| <center>-</center> <br />
| (only within a pair of brackets) denotes a range of characters. <br />
| '''foo[a-z]ar '''equals '''fooaar''', '''foobar,''' '''foocar,''' '''foodar,''' etc.<br />
|}<br />
<br />
Backreferences allow for reuse of wildcard matches in the Replace field using the '''$N''' notation, where '''$1''' is the first wildcard match, '''$2''' is second, and so on.<br />
<br />
Examples of the use of backreferences:<br />
<br />
{| class="wikitable"<br />
|-<br />
! Find<br />
! Replace<br />
! Example Input<br />
! Produced Output<br />
|-<br />
| <code>*, *</code><br />
| <code>$2 $1</code><br />
| <code>Smith, John</code><br />
| <code>John Smith</code><br />
|-<br />
| <code>Happy ?-th birthday *</code><br />
| <code>$2 is $1 years old</code><br />
| <code>Happy 5-th birthday Bob</code><br />
| <code>Bob is 5 years old</code><br />
|}<br />
<br />
== Beware of conflicting replacements == <br />
<br />
If you enter multiple find and replace strings they will be executed as multiple Replace rules, so first string will go first and only after replacing all (or first, or last) occurrences of that string the second string in the Find field will be searched and replaced.<br />
<br />
{|<br />
|<br />
<br />
{| class="wikitable"<br />
! Find<br />
! Replace<br />
|-<br />
| A*{{Pipe}}*B<br />
| B*{{Pipe}}*A<br />
|}<br />
<br />
|<br />
<br />
{| class="wikitable"<br />
! Name<br />
! New Name<br />
|-<br />
| ABBA.mp3<br />
| AAAA.mp3<br />
|}<br />
<br />
|}<br />
<br />
You may expect the new name to be <tt>BAAB.mp3</tt>, but it's not. This happens because first all <tt>A</tt>'s are replaced with <tt>B</tt>'s (we get <tt>BBBB.mp3</tt>) and only then all <tt>B</tt>'s are replaced with <tt>A</tt>'s (and the final result is <tt>AAAA.mp3</tt>). <br />
<br />
If you need to apply character-to-character mappings you should use [[ReNamer:Rules:Translit|Translit rule]].<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Replace&diff=3512ReNamer:Rules:Replace2023-08-08T18:36:47Z<p>Den4b: Clean up, rephrase</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Remove|next=ReNamer:Rules:Rearrange}}<br />
<br />
== Replace Rule ==<br />
<br />
[[Image:ReplaceRule.png|center]]<br />
<br />
This rule removes the specified string from the name and replaces it with another string. It has options to replace the first occurrence, the last occurrence, or all the occurrences. You can replace multiple strings at a time. You can also use wildcards to create simple patterns.<br />
<br />
The parameters are as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter <br />
! Details<br />
|-<br />
| Find <br />
| Enter the string to be replaced. <br />
*You can enter multiple strings at a time. They will be searched &amp; replaced in the order as they appear. Press the + button to insert a separator between two strings. Instead of pressing this button, you can also enter '''*&#124;*''' from the keyboard. <br />
*If the name does not contain the specified string, the rule will not act on it. <br />
*If the name contains more than one of these strings, it will replace them according to the Occurrences parameter.<br />
<br />
|-<br />
| [[Image:PlusButton.png]] button <br />
| Inserts a separator ('''*&#124;*''') sequence between two delimiter entries.<br />
<br />
In that case, the n<sup>th</sup> entry in the '''Find''' field is replaced by the n<sup>th</sup> entry in the '''Replace''' field.<br />
<br />
|-<br />
| Replace <br />
| Enter strings that will replace the "Find" strings. <br />
<br />
Note that the number of strings (separated with '''*&#124;*''') in "Find" and "Replace" fields should be the same. If there is more strings in the "Find" field than in the "Replace" field the spare strings will be removed (replaced with an empty string). If there is more strings in the "Replace" field, the spare strings will be ignored.<br />
<br />
|-<br />
| Insert meta tag <br />
[[Image:ReNamer Insert Meta Tag Button.png]] <br />
<br />
| Click the button to see a list of [[ReNamer:Meta Tags|meta-tags]].<br />
|-<br />
| Occurrences <br />
| In case that strings occur more than once in the filename, specify which occurrences should be replaced.<br />
|-<br />
| Skip extension <br />
| If checked, the file extension will be excluded from the processing and will remain unaffected.<br />
|-<br />
| Case sensitive <br />
| Will only remove a specified string from the name if the case matches exactly.<br />
|-<br />
| Whole words only<br />
| Remove the subject text only when it is whole word, not a part of another word.<br />
<br />
For example, searching for "bar" would not find a match in "foobar" or "bars".<br />
|-<br />
| Interpret symbols as wild cards <br />
| Treat certain symbols as [[#Wildcards|Wildcards]] for matching simple patterns (similar to [[ReNamer:Regular Expressions|Regular Expressions]]). <br />
<br />
|}<br />
<br />
=== Wildcards ===<br />
<br />
{| class="wikitable"<br />
|-<br />
! Wildcard<br />
! Represents<br />
! Example<br />
|-<br />
| <center>*</center> <br />
| any number of characters (including numbers, space, underscores, etc.). <br />
| '''abc*''' equals '''abc''' followed by 0 or more characters.<br />
|-<br />
| <center>?</center> <br />
| Any single character (including numbers, space, underscores, etc.) <br />
| '''ab?d''' equals '''abcd''', '''ab1d''', '''ab d''', '''ab_d''', etc.<br />
|-<br />
| <center>[]</center> <br />
| Brackets enclose a set of characters, any one of which may match a single character at that position. <br />
| '''foo[ab]ar '''equals '''fooaar''' and '''foobar'''<br />
|-<br />
| <center>-</center> <br />
| (only within a pair of brackets) denotes a range of characters. <br />
| '''foo[a-z]ar '''equals '''fooaar''', '''foobar,''' '''foocar,''' '''foodar,''' etc.<br />
|}<br />
<br />
== Beware of conflicting replacements == <br />
<br />
If you enter multiple find and replace strings they will be executed as multiple Replace rules, so first string will go first and only after replacing all (or first, or last) occurrences of that string the second string in the Find field will be searched and replaced.<br />
<br />
{|<br />
|<br />
<br />
{| class="wikitable"<br />
! Find<br />
! Replace<br />
|-<br />
| A*{{Pipe}}*B<br />
| B*{{Pipe}}*A<br />
|}<br />
<br />
|<br />
<br />
{| class="wikitable"<br />
! Name<br />
! New Name<br />
|-<br />
| ABBA.mp3<br />
| AAAA.mp3<br />
|}<br />
<br />
|}<br />
<br />
You may expect the new name to be <tt>BAAB.mp3</tt>, but it's not. This happens because first all <tt>A</tt>'s are replaced with <tt>B</tt>'s (we get <tt>BBBB.mp3</tt>) and only then all <tt>B</tt>'s are replaced with <tt>A</tt>'s (and the final result is <tt>AAAA.mp3</tt>). <br />
<br />
If you need to apply character-to-character mappings you should use [[ReNamer:Rules:Translit|Translit rule]].<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=Application_Data_Storage&diff=3511Application Data Storage2023-05-04T10:27:13Z<p>Den4b: /* Change the storage path */ List of supported path tags</p>
<hr />
<div>== Introduction ==<br />
<br />
Applications often require a dedicated location for storing the application data, such user settings, profiles and documents.<br />
<br />
The choice of the storage location can vary wildly between different purposes, applications and operating systems, but generally speaking they follow one of the two common conventions.<br />
<br />
# '''Portable versions''' &ndash; Portable applications usually do not require any system specific installation or uninstallation routines, instead, they come in a form of an archive which you can unpack anywhere you like. All (or almost all) application data is stored in the same directory as the application executable file. This makes the application folder self-contained and portable. <br />
# '''Installer versions''' &ndash; The application executable is normally installed in a system protected location (e.g. "C:\Program Files"), while the application data is stored in a separate user-accessible location dedicated by the operating system, such as the user profile directory (e.g. "C:\Users\User").<br />
<br />
Being able to locate the application data can be instrumental for troubleshooting and backup purposes.<br />
<br />
== Where is my data ==<br />
<br />
If you are using the installer version, your application data should be stored in the user profile directory.<br />
<br />
Type the following path into the address bar of File Explorer:<br />
<br />
<pre>%USERPROFILE%\Documents\den4b\</pre><br />
<br />
There, you should see one or more sub-folders, one per installed application.<br />
<br />
In a standard Windows installation, for a username "UserName" and an application name "AppName", the fully resolved path should look like this:<br />
<br />
<pre>C:\Users\UserName\Documents\den4b\AppName\</pre><br />
<br />
== Change the storage path == <br />
<br />
You can redefine the path used for storing the application data.<br />
<br />
Edit or create <code>Storage.ini</code> file in the installation folder, where the application executable file is located.<br />
<br />
For example, if you have installed the application into:<br />
<br />
<pre>C:\Program Files\AppName\</pre><br />
<br />
Then, the expected full path for <code>Storage.ini</code> file is:<br />
<br />
<pre>C:\Program Files\AppName\Storage.ini</pre><br />
<br />
If you don't find the file or the file is empty, then the application data will stored in the same folder as the application executable file, which is the default behavior for ''Portable versions''.<br />
<br />
The content of <code>Storage.ini</code> can be either empty or contain the path to the application data. The path may also contains environment variables and predefined path tags.<br />
<br />
By default, the ''Installer versions'' should have the following content in <code>Storage.ini</code> file:<br />
<br />
<pre>#USER#</pre><br />
<br />
This is a path tag that stands for a vendor and application specific folder structure within the user profile directory.<br />
<br />
You can replace the content with any valid path, but be aware that the existing application data will not be automatically migrated to the new path.<br />
<br />
==== List of supported path tags ====<br />
<br />
{| class="wikitable"<br />
! Path tag || Equivalent environment path || Description<br />
|-<br />
| #ALL# || %PUBLIC%\Documents\AppVendor\AppName || Vendor specific folder in the public documents folder.<br />
|-<br />
| #USER# || %USERPROFILE%\Documents\AppVendor\AppName || Vendor specific folder in the current user documents folder.<br />
|-<br />
| #PUBLICDOCUMENTS# || %PUBLIC%\Documents || Public documents folder.<br />
|-<br />
| #USERDOCUMENTS# || %USERPROFILE%\Documents || Current user documents folder.<br />
|-<br />
| #USERPROFILE# || %USERPROFILE% || Current user profile folder.<br />
|-<br />
| #APPVENDOR# || -- || Application vendor name.<br />
|-<br />
| #APPNAME# || -- || Application name.<br />
|-<br />
| #APPDIR# || -- || Application directory.<br />
|-<br />
| #WORKINGDIR# || -- || Current working directory.<br />
|}<br />
<br />
See also the full list of [https://en.wikipedia.org/wiki/Environment_variable#Windows Environment variables].<br />
<br />
==== Examples of custom storage paths ====<br />
<br />
<pre><br />
Z:\Personal\Application\Settings\<br />
</pre><br />
<br />
<pre><br />
%USERPROFILE%\AppName\<br />
</pre><br />
<br />
<pre><br />
%APPDATA%\AppName\<br />
</pre><br />
<br />
== UAC and VirtualStore ==<br />
<br />
Microsoft has introduced a concept of virtual storage, as a part of the User Account Control (UAC) system, for backward compatibly with legacy applications which attempt to save data in protected locations, such as "C:\Program Files". This feature was introduced in Windows Vista and is also present in later versions of Windows. For more information, see [https://docs.microsoft.com/en-us/previous-versions/bb756960(v=msdn.10) New UAC Technologies for Windows Vista].<br />
<br />
This feature affects some older versions of den4b products, which always store user settings in the application executable folder. If the application was installed in a protected location, the actual saved content would be redirected to the so called ''VirtualStore'' location, usually without the application ever knowing the ''real'' path.<br />
<br />
Type the following path into the address bar of File Explorer to access the root ''VirtualStore'' location:<br />
<br />
<pre>%LOCALAPPDATA%\VirtualStore</pre><br />
<br />
==== Example of VirtualStore path ====<br />
<br />
For example, if a legacy application was installed in:<br />
<br />
<pre>C:\Program Files\AppName</pre><br />
<br />
And the application attempted to save a file in:<br />
<br />
<pre>C:\Program Files\AppName\Settings.ini</pre><br />
<br />
The actual file would be transparently saved in:<br />
<br />
<pre>C:\Users\UserName\AppData\Local\VirtualStore\Program Files\AppName\Settings.ini</pre><br />
<br />
Assuming a standard Windows installation with a username "UserName".</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Translit&diff=3510ReNamer:Rules:Translit2023-01-06T08:43:17Z<p>Den4b: Unicode character forms</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:CleanUp|next=ReNamer:Rules:RegEx}}<br />
<br />
[[Image:TranslitRule.png|center]]<br />
<br />
This rule transliterates one alphabet into another. Its main goal is to transliterate Non-English characters from different languages into their English/Latin representation. For example, the German character '''ü''' can be transliterated to '''ue''' (the name '''Müller '''can be also written as '''Mueller''').<br />
<br />
This rule uses ''transliteration maps'' (explained below). <br />
<br />
== Transliteration maps ==<br />
<br />
To transliterate, we create a pair of equivalent characters, like this: '''ü=ue''' <br />
<br />
(Note that the right side of this equation has ''two'' characters. Any number of characters may be placed on both sides of the equation.) <br />
<br />
We need several such ''equivalent character pairs'' to convert one language into another. The entire set is called a ''transliteration map''. (This is really some kind of a find-and-replace rule.) <br />
<br />
ReNamer has several such built-in maps. Each map is named after a language (the second language in all maps is English). <br />
<br />
Each map can be used in ''both'' directions (e.g. French-to-English or English-to-French.) <br />
<br />
When you start up the '''Translit''' Rule, its window does not show any maps. You are free to do any of the following: <br />
<br />
#Use any of the built-in maps (and use it in ''forward'' or ''reverse'' direction) <br />
#Create your own map and use it. <br />
#Edit a built-in map first, and then use it.<br />
<br />
Let us see how to do this. <br />
<br />
== Automatic case conversion ==<br />
<br />
Translit rule does automatic case conversion with an algorithm adopted specifically for transliteration. Translit rule discard the case on the input, i.e. "A=B" is same as "a=b". Case is decided upon case of the input fragment. Multiple character fragments are treated as part of words, with their case decided based on the case of letters around them.<br />
<br />
The logic for the case conversion is as follows (ReNamer Beta from 23 Aug 2009):<br />
<pre><br />
set OUTPUT-PART to lower case<br />
if first letter in INPUT-PART is upper case then<br />
if length of OUTPUT-PART bigger than 1 then<br />
if next letter in original name is upper case then<br />
convert whole OUTPUT-PART to upper case<br />
else<br />
convert only first letter in OUTPUT-PART to upper case<br />
else<br />
convert whole OUTPUT-PART to upper case<br />
</pre><br />
<br />
== Using a built-in transliteration map ==<br />
<br />
To select any of the built-in maps, press the [[Image:TranslitMapsButton.png]] button. A list of available transliteration maps pops up: <br />
<center>[[Image:TranslitMenu.png]]</center> <br />
Click on the desired transliteration map. As an example, let us click on the French (to English) transliteration map. <br />
<br />
The '''Rules''' window changes immediately to show the French characters and their English equivalents. <br />
<center>[[Image:TranslitRuleExample.png]]</center> <br />
You can edit any of the entry in this list, add new entries, or delete any of the entries. <br />
<br />
Note that such editing does not alter the saved version of the map. The map is edited just for a one-time use. If you select the same Translit map again, ReNamer will load the ''original'' version, not the ''edited'' version. You will see how to [[#Saving_a_transliteration_map|alter a transliteration map]] in a section below. <br />
<br />
Next, select the rule's parameters as shown below: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter<br />
! Details<br />
|-<br />
| forward <br />
| This is transliteration from-left-to-right direction, as defined in the map.<br />
|-<br />
| backward <br />
| This is transliteration from-right-to-left direction, as defined in the map.<br />
|-<br />
| skip extension <br />
| If this check box is selected, the extension will be ignored by the rule.<br />
|}<br />
<br />
Finally, press the [[Image:AddRuleButton.png]] button to add the rule to the stack.<br />
<br />
== Making your own transliteration map ==<br />
<br />
Click in the '''Translit Alphabet''' window, and start entering your custom alphabet.<br />
<br />
Transliteration alphabet consists of two equivalence parts (or a couple), which are entered one per line and two parts separated with "=" (equal sign). Alphabet should not contain spaces and should have case discarded ([[ReNamer:Rules:Translit#Automatic_case_conversion|case is adjusted automatically]]). Also, make sure to put couples which contain greater number of characters at the top, so they will get processed first and will not get processed partially by shorter representations. Below is a simple example:<br />
<br />
{| align="center"<br />
|<br />
<pre><br />
щ=sh<br />
ю=yu<br />
я=ya<br />
ь='<br />
э=e<br />
</pre><br />
|}<br />
<br />
After entering all such transliterations, press the [[Image:AddRuleButton.png]] button to add the rule to the rule-stack. <br />
<br />
Note that this rule is not saved yet (it was just composed for a one-time use). The following topic shows how to save a map.<br />
<br />
== Saving a transliteration map ==<br />
<br />
To save a newly composed Transliteration rule, <br />
<br />
#Press the [[Image:TranslitMapsButton.png]] button. <br />
#:A menu pops up. <br />
#:<center>[[Image:TranslitMenu.png]]</center> <br />
#Select the last option ('''Save Translit...'''). <br />
#:A window pops up, as shown below: <br />
#:<center>[[Image:SaveTranslitMapDialog.png]]</center> <br />
#Enter a new name for the map and press '''OK'''. The new map is saved.<br />
<br />
The process of saving an edited Transliteration map is similar. The only difference is that the '''Save Translit '''window (see above) shows the current map's name. You can press '''OK''' to save the changes you've just made, or enter a new name to create a new translit map for the edited version of the current map. <br />
<br />
The new map's name is added to the map list. <br />
<br />
From now on, the new map will also be available as "standard".<br />
<br />
== Unicode character forms ==<br />
<br />
Have you encounter a case where some characters don't get converted, despite having a visually identical character defined in the Translit alphabet?<br />
<br />
Unicode characters can be defined using exact character codes or using [https://en.wikipedia.org/wiki/Combining_character combining characters]. The displayed characters will look identical, but their binary content is completely different. The conversion process between these forms is covered by the [https://unicode.org/reports/tr15/ Unicode Normalization] standard.<br />
<br />
Alphabets in the Translit rule are normally defined using exact character codes, so the combining characters won't get affected. You can put a piece of text through a ''Unicode analyzer'' to see exactly how each character is defined and to identify the use of combining characters.<br />
<br />
To handle all possible forms of the same visual character in Translit alphabets, one could define all possible forms in an alphabet or one can simply strip away those combining characters, which can be accomplished by using the "Strip unicode marks" option found in the [[ReNamer:Rules:CleanUp|Clean Up rule]].<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script:Functions&diff=3509ReNamer:Pascal Script:Functions2022-12-23T11:01:41Z<p>Den4b: /* Unicode Conversion */ Version labels updated</p>
<hr />
<div>{{Go|up=ReNamer:Pascal Script|prev=ReNamer:Pascal Script:Types}}<br />
<br />
ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file, strings entered by the user, etc. This functionality is available for use via the [[ReNamer:Rules:PascalScript|PascalScript rule]].<br />
<br />
The difference between a "function" and a "procedure" is that while a function executes an algorithm and returns a value, a procedure just executes an algorithm without returning anything.<br />
<br />
A common "Wide" prefix in function names indicates that the function deals with '''WideString''' type rather than '''AnsiString''' or '''String''' type. For example, ''ShowMessage'' and ''WideShowMessage'' procedures. See the [[ReNamer:Pascal_Script:Types#String_types|String Types]] for more information.<br />
<br />
== Basic String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''Insert'''(Source: String; var S: String; Index: Integer); <br />
| Inserts the string '''S''' into string '''Source''' at position '''Index'''.<br />
|-<br />
| procedure '''Delete'''(var S: String; Index, Count: Integer); <br />
| Deletes '''Count''' characters from the string '''S''', starting from position '''Index'''.<br />
|-<br />
| function '''Copy'''(S: String; Index, Count: Integer): String; <br />
| Copies '''Count''' characters from string '''S''', starting at position '''Index''', and returns them as a new string.<br />
|-<br />
| function '''Pos'''(Substr: String; S: String): Integer; <br />
| Returns the position of a string '''Substr''' in another string '''S'''.<br />
|}<br />
<br />
'''Note:''' Indexes of characters in strings are 1 based, so first character in string S would be S[1].<br />
<br />
{{Top}}<br />
<br />
== Length Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''SetLength'''(var S: Array; NewLength: Integer); <br />
| Sets the length of array variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: String; NewLength: Integer); <br />
| Sets the length of string variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: WideString; NewLength: Integer); <br />
| Sets the length of widestring '''S''' to '''NewLength'''.<br />
|-<br />
| function '''Length'''(const S: Array): Integer; <br />
| Returns the length of array '''S ''' (number of elements).<br />
|-<br />
| function '''Length'''(const S: String): Integer; <br />
| Returns the length of string '''S''' (number of characters).<br />
|-<br />
| function '''Length'''(const S: WideString): Integer;<br />
| Returns the length of WideString '''S''' (number of characters).<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''WideInsert'''(const Substr: WideString; var Dest: WideString; Index: Integer); <br />
| Inserts '''Substr''' in '''Dest''' at position '''Index'''.<br />
|-<br />
| procedure '''WideDelete'''(var S: WideString; Index, Count: Integer); <br />
| Deletes '''Count''' characters from '''S''', starting from the '''Index''' position.<br />
|-<br />
| procedure '''WideDeleteRight'''(var S: WideString; Index, Count: Integer);<br />
| Delete '''Count''' characters from '''S''', starting from the '''Index''' position from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| procedure '''WideSetLength'''(var S: WideString; NewLength: Integer); <br />
| Change the length of string '''S''' to a new length specified by '''NewLength'''. If new length is smaller than original, the string is truncated. If new length is greater than original, the string will be expanded but additional characters will not be initialized and can be anything.<br />
|-<br />
| function '''WideLength'''(const S: WideString): Integer; <br />
| Returns the length of WideString '''S'''.<br />
|-<br />
| function '''WideCopy'''(const S: WideString; Index, Count: Integer): WideString; <br />
| Returns '''Count''' characters from '''S''', starting at position '''Index'''.<br />
|-<br />
| function '''WideCopyRight'''(const S: WideString; Index, Count: Integer): WideString;<br />
| Returns '''Count''' characters from '''S''', starting at position '''Index''' from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WidePos'''(const SubStr, S: WideString): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WidePosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S''' but start searching from position specified by '''Offset'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WideUpperCase'''(const S: WideString): WideString; <br />
| Returns the ALLCAPS version of the WideString '''S'''<br />
|-<br />
| function '''WideLowerCase'''(const S: WideString): WideString; <br />
| Returns the lowercase version of the WideString '''S'''<br />
|-<br />
| function '''WideCompareStr'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-sensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideCompareText'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideSameText'''(const S1, S2: WideString): Boolean; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive. Returns TRUE if both are identical, otherwise returns FALSE.<br />
|-<br />
| function '''WideTextPos'''(const SubStr, S: WideString): Integer; <br />
| Behaves like '''WidePos''' function, except text if processed in case-insensitive manner.<br />
|-<br />
| function '''WideTextPosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer;<br />
| Behaves like '''WidePosEx''' function, except text if processed in case-insensitive manner.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideTrim'''(const S: WideString): WideString; <br />
| Removes leading and trailing spaces and control characters from the given string '''S'''.<br />
|-<br />
| function '''WideTrimChars'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning and the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsLeft'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsRight'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideReverseString'''(const S: WideString): WideString;<br />
| Return a reversed version of string '''S''', i.e. reverse the order of characters.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideRepeatString'''(const S: WideString; Count: Integer): WideString;<br />
| Repeat a string a number of times.<br/>''Added in v6.9.0.3 Beta.''<br />
<br />
|-<br />
| function '''WideReplaceStr'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-sensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
<br />
|-<br />
| function '''WideReplaceText'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-insensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
|-<br />
| function '''WideSplitString'''(const Input, Delimiter: WideString): TWideStringArray; <br />
| <br />
Splits the '''Input''' wherever '''Delimiter''' occurs and returns an array that contains the split parts. <br />
<br />
*The '''Delimiter''' itself can be a multi-character WideString. <br>(Unlike the usual comma, hyphen or space that are used for this purpose) <br />
*The split parts (returned as elements of the array) do not contain the '''Delimiter'''.<br />
<br />
|-<br />
|-<br />
| function '''WideJoinStrings'''(const Strings: TWideStringArray; const Delimiter: WideString): WideString;<br />
| Joins all individual items from '''Strings''' into a single WideString, with '''Delimiter''' inserted between the joined items.<br />
<br />
|-<br />
| function '''WideCaseSentence'''(const S: WideString): WideString; <br />
| Returns a ''Sentence case'' version of parameter '''S'''. <br />
<br />
Only the first alphabetic character is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
''Added in v6.0.0.3 Alpha''.<br />
|-<br />
| function '''WideCaseCapitalize'''(const S: WideString): WideString; <br />
| <br />
Returns the ''Title case'' version of parameter '''S'''. <br />
<br />
First letter of every word is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
|-<br />
| function '''WideCaseInvert'''(const S: WideString): WideString; <br />
| Inverts case of all characters in '''S''' and returns it.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide Character Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsWideCharUpper'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in upper case.<br />
|-<br />
| function '''IsWideCharLower'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in lower case.<br />
|-<br />
| function '''IsWideCharDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a digit (numeric character 0-9). <br />
|-<br />
| function '''IsWideCharSpace'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a white-space character, such as: space, form-feed, newline, carriage-return, tab and vertical-tab (characters classified as C1_SPACE).<br />
|-<br />
| function '''IsWideCharPunct'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a punctuation mark (characters classified as C1_PUNCT).<br />
|-<br />
| function '''IsWideCharCntrl'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a control character (characters classified as C1_CNTRL).<br />
|-<br />
| function '''IsWideCharBlank'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a blank, such as: space and tab (characters classified as C1_BLANK).<br />
|-<br />
| function '''IsWideCharXDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a hexadecimal digit (0-9 or A-F).<br />
|-<br />
| function '''IsWideCharAlpha'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character (a-z or A-Z).<br />
|-<br />
| function '''IsWideCharAlphaNumeric'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character or a numeric character (a-z, A-Z or 0-9).<br />
|-<br />
| function '''IsWideWordBoundaryLeft'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the left.<br />
<br />
Conditions that qualify as word boundaries to the left of character:<br />
# If first character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.'' <br />
|-<br />
| function '''IsWideWordBoundaryRight'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the right.<br />
<br />
Conditions that qualify as word boundaries to the right of character:<br />
# If last character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideCharUpper'''(const WC: WideChar): WideChar; <br />
| Returns an upper case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideCharLower'''(const WC: WideChar): WideChar; <br />
| Returns a lower case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideChr'''(Code: Word): WideChar;<br />
| Create a character from a code point.<br/>''Added in v6.9.0.3 Beta.''<br />
|}<br />
<br />
'''Note:''' Character classifications, such as C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT, C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA - are part of Unicode definitions. More information regarding classification can be found on the internet. For example: [http://www.fileformat.info/info/unicode/ http://www.fileformat.info/info/unicode/].<br />
<br />
{{Top}}<br />
<br />
== Unicode Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideToAnsi'''(const WS: WideString): String; <br />
| Convert WideString type to AnsiString type.<br/>In v7.0 and later, this conversion is performed automatically on assignment.<br />
|-<br />
| function '''AnsiToWide'''(const S: String): WideString; <br />
| Convert AnsiString type to WideString type.<br/>In v7.0 and later, this conversion is performed automatically on assignment.<br />
|-<br />
| function '''UTF8Encode'''(const WS: WideString): String; <br />
| Convert WideString type to UTF-8 encoded string.<br />
|-<br />
| function '''UTF8Decode'''(const S: String): WideString;<br />
| Convert UTF-8 encoded string to WideString type.<br />
|-<br />
| function '''WinCPToUTF8'''(const S: String): String;<br />
| Convert a string encoded with active [https://en.wikipedia.org/wiki/Windows_code_page system code page] to a UTF-8 encoded string.<br/>Added in v7.4.0.3 Beta.<br />
|-<br />
| function '''UTF8ToWinCP'''(const S: String): String;<br />
| Convert a UTF-8 encoded string to a string encoded with active [https://en.wikipedia.org/wiki/Windows_code_page system code page].<br/>Added in v7.4.0.3 Beta.<br />
|}<br />
<br />
See [[ReNamer:Pascal_Script:Types#String_types|String types]] for additional information on the default encoding and conversion procedures.<br />
<br />
== Console Output Conversion ==<br />
<br />
OEM-defined character set is commonly used in the output of console applications.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''OemToAnsi'''(const S: String): String;<br />
| Convert OEM string into an ANSI string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''OemToWide'''(const S: String): WideString;<br />
| Convert OEM string into a WideString.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''AnsiToOem'''(const S: String): String;<br />
| Convert ANSI string into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''WideToOem'''(const S: WideString): String; <br />
| Convert WideString into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Basic Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''BoolToStr'''(B: Boolean): String;<br />
| Convert boolean variable into a string. Returns "''True''" or "''False''" string value.<br />
|-<br />
| function '''IntToStr'''(Value: Integer): String; <br />
| Converts an integer to a string. The following assumptions are correct:<br />
<div style="font-family: monospace"><br />
* IntToStr(123) = '123'<br />
* IntToStr(0123) = '123'<br />
* IntToStr(123) <> '0123'<br />
</div><br />
<b>Note:</b> Be cautious of supplying ''Int64'' type as a parameter as it will be type casted to ''Integer'', which significantly reduces the range of possible values (refer to [[ReNamer:Pascal Script:Types|Types]] for more information). You can use '''FormatFloat''' function to convert ''Int64'' values to a string without a loss of range.<br />
|-<br />
| function '''Int64ToStr'''(Value: Int64): String;<br />
| Same as '''IntToStr''' but takes in ''Int64'' typed parameter.<br />
|-<br />
| function '''StrToInt'''(const S: String): Integer; <br />
| Converts a string to an integer. The following equalities are correct:<br />
<div style="font-family: monospace"><br />
* StrToInt('123') = 123<br />
* StrToInt('123') = 0123<br />
* StrToInt('0123') = 123<br />
</div><br />
'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''StrToInt64'''(const S: String): Int64;<br />
| Same as '''StrToInt''' but returns ''Int64'' typed result.<br />
|-<br />
| function '''StrToIntDef'''(const S: String; const Default: Integer): Integer; <br />
| Behaves like '''StrToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''StrToInt64Def'''(const S: String; Default: Int64): Int64;<br />
| Same as '''StrToIntDef''' but operates with ''Int64'' type.<br />
|-<br />
| function '''TryStrToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Converts a string to an integer, but does not throw an error when invalid string is supplied, unlike '''StrToInt'''. Returns ''False'' if conversion operation has failed.<br />
|-<br />
| function '''FloatToStr'''(Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using default system format.<br />
|-<br />
| function '''StrToFloat'''(const S: string): Extended;<br />
| Converts supplied string to a floating point value.<br>'''Warning:''' An error will occur if the parameter to this function cannot be converted to a floating point value!<br />
|-<br />
| function '''StrToFloatDef'''(const S: string; const Default: Extended): Extended;<br />
| Behaves like '''StrToFloat''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to a floating point value.<br />
|-<br />
| function '''FormatFloat'''(const Format: string; Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using user specific '''Format'''.<br/>Check [[#Floating point format specifiers|floating point format specifiers]] below for more information.<br />
|-<br />
| function '''DateToStr'''(D: TDateTime): String; <br />
| Converts a date to a string, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''StrToDate'''(const S: String): TDateTime; <br />
| Converts a date string to a proper TDateTime value, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''IntToHex'''(Value: Integer; Digits: Integer): String; <br />
| Converts an integer to its hexadecimal representation. Here are samples:<br />
<div style="font-family: monospace"><br />
* IntToHex(1234, 1) = '4D2'<br />
* IntToHex(1234, 8) = '000004D2'<br />
</div><br />
|-<br />
| function '''HexToInt'''(const HexNum: String): Integer; <br />
| Converts a hexadecimal value to its decimal representation.<br/>'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''HexToIntDef'''(const HexNum: String; Default: Integer): Integer; <br />
| Behaves like '''HexToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''IntToRoman'''(Value: Integer): String;<br />
| Convert a decimal number to Roman numerals.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToInt'''(const S: String): Integer;<br />
| Convert Roman numerals to a decimal number.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToIntDef'''(const S: String; Default: Integer): Integer;<br />
| Convert Roman numerals to a decimal number. Returns the '''Default''' value in the conversion fails.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''TryRomanToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Try to convert Roman numerals to a decimal number. Does not throw an error on failure, instead it returns ''False''.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''Ord'''(X: Char): Byte; <br />
| Return an ordinal value (byte representation) of a character.<br />
|-<br />
| function '''Chr'''(X: Byte): Char; <br />
| Return a character by its ordinal value (byte representation).<br />
|}<br />
<br />
=== Floating point format specifiers ===<br />
<br />
{| class="wikitable"<br />
! Specifier<br />
! Represents<br />
|-<br />
| <tt>0</tt>&nbsp;(zero)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "0" appears in the format string, then that digit is copied to the output string. Otherwise, a "0" is stored in that position in the output string.<br />
|-<br />
| <tt>#</tt>&nbsp;(hash)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "#" appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string.<br />
|-<br />
| <tt>.</tt>&nbsp;(dot)<br />
| Decimal point. The first "." character in the format string determines the location of the decimal separator in the formatted value, any additional "." characters are ignored.<br />
|-<br />
| <tt>,</tt>&nbsp;(comma)<br />
| Thousand separator. If the format string contains one or more "," characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of "," characters in the format string does not affect the output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Date and Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''Date''': TDateTime; <br />
| Returns the current system date.<br />
|-<br />
| function '''Time''': TDateTime; <br />
| Returns the current system time.<br />
|-<br />
| function '''Now''': TDateTime; <br />
| Returns the current system date and time.<br />
|-<br />
| function '''EncodeDate'''(Year, Month, Day: Word): TDateTime; <br />
| Generates date value for the specified '''Year''', '''Month''', '''Day'''. Parameters must be within a valid date range: Year = 0..9999, Month = 1..12, Day = 1..31 (depending on month/year). An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeTime'''(Hour, Min, Sec, MSec: Word): TDateTime; <br />
| Generates time value for the specified '''Hour''', '''Min''', '''Sec''', '''MSec'''. Parameters must be within a valid time range: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word): TDateTime;<br />
| Generates date-time value for the specified components of date and time. Similar to '''EncodeDate''' and '''EncodeTime'''.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''TryEncodeDate'''(Year, Month, Day: Word; var Date: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeDate''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date value will be written in the '''Date''' variable.<br />
|-<br />
| function '''TryEncodeTime'''(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated time value will be written in the '''Time''' variable.<br />
|-<br />
| function '''TryEncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''EncodeDateTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date-time value will be written in the '''ADateTime''' variable.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| procedure '''DecodeDate'''(const DateTime: TDateTime; var Year, Month, Day: Word); <br />
| Extracts '''Year''', '''Month''' and '''Day''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeTime'''(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word); <br />
| Extracts '''Hour''', '''Min''', '''Sec''' and '''MSec''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeDateTime'''(const DateTime: TDateTime; out Year, Month, Day, Hour, Minute, Second, MilliSecond: Word);<br />
| Similar to '''DecodeDate''' and '''DecodeTime''' but extracts both date and time components at once.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''ComposeDateTime'''(const Date, Time: TDateTime): TDateTime;<br />
| Combine date and time components into a single date-time value.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DateTimeToUnix'''(D: TDateTime): Int64;<br />
| Converts '''D''' value of type '''TDateTime''' to a Unix timestamp.<br />
|-<br />
| function '''UnixToDateTime'''(U: Int64): TDateTime; <br />
| Converts a Unix timestamp to a value of '''TDateTime''' type.<br />
|-<br />
| function '''FormatDateTime'''(const Format: String; DateTime: TDateTime): String;<br />
| Convert date and time value to a string using [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Format''' parameter. <br />
|-<br />
| function '''ScanDateTime'''(const Pattern, Subject: String): TDateTime;<br />
| Convert '''Subject''' string to a date and time value by parsing it according to the [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Pattern''' parameter.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''TryScanDateTime'''(const Pattern, Subject: String; out DateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''ScanDateTime''' function, except it suppresses errors and returns either ''TRUE'' or ''FALSE'' depending on the success of the operation.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''IncYear'''(const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of years (plus or minus).<br />
|-<br />
| function '''IncMonth'''(const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of months (plus or minus).<br />
|-<br />
| function '''IncWeek'''(const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of weeks (plus or minus).<br />
|-<br />
| function '''IncDay'''(const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of days (plus or minus).<br />
|-<br />
| function '''IncHour'''(const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of hours (plus or minus).<br />
|-<br />
| function '''IncMinute'''(const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of minutes (plus or minus).<br />
|-<br />
| function '''IncSecond'''(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of seconds (plus or minus).<br />
|-<br />
| function '''IncMilliSecond'''(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of milliseconds (plus or minus).<br />
|-<br />
| function '''SecondSpan'''(const ANow, AThen: TDateTime): Double;<br />
| Calculate the approximate number of seconds between two date-time values.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DayOfWeek'''(const DateTime: TDateTime): Word; <br />
| Returns the day number of the week. Returned values: 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday.<br/>''Before v6.1 this function used to return 1=Sunday to 7=Saturday.''<br />
|-<br />
| function '''DayOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''DayOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the year.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the year.<br/>''Added in v6.1.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideFileSize'''(const FileName: WideString): Int64; <br />
| Returns the size of the file in bytes. If file does not exist "-1" is returned. The return value is of type ''Int64'' which can store the maximum file size of 9,223,372,036,854,775,807 bytes.<br />
|-<br />
| function '''WideFileExists'''(const FileName: WideString): Boolean; <br />
| Check whether specified file exists. Returns TRUE if file exists, otherwise FALSE.<br />
|-<br />
| function '''WideDirectoryExists'''(const Directory: WideString): Boolean; <br />
| Check whether specified directory exists. Returns TRUE if directory exists, otherwise FALSE.<br />
|-<br />
| function '''WideForceDirectories'''(const Dir: WideString): Boolean; <br />
| Makes sure that that all directories in the path exist. If they don't, function will try to create them, recursively. Returns TRUE if all folders exist or have been successfully created.<br />
|-<br />
| function '''WideCreateDir'''(const Dir: WideString): Boolean; <br />
| Create specified directory (non-recursive). Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideRemoveDir'''(const Dir: WideString): Boolean;<br />
| Remove a directory, if it is empty. Returns TRUE on success, otherwise FALSE.<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideDeleteFile'''(const FileName: WideString): Boolean; <br />
| Delete physical file from the disk. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideDeleteToRecycleBin'''(const FileName: WideString): Boolean;<br />
| Delete file or folder by placing it into the Recycle Bin. Returns TRUE on success, otherwise FALSE.<br />
<br />
'''Note:''' You must provide a full path to delete the file to the Recycle Bin (a quirk of Windows API).<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideRenameFile'''(const OldName, NewName: WideString): Boolean; <br />
| Rename file from '''OldName''' to '''NewName'''. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideCopyFile'''(const FromFile, ToFile: WideString; FailIfExists: Boolean): Boolean;<br />
| Rename file from '''FromFile''' to '''ToFile'''. If '''FailIfExists''' flag is TRUE, file will not be copied when destination file already exists, otherwise, destination file will be overwritten. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideFileSearch'''(const Name, DirList: WideString): WideString; <br />
| Search through the directories passed in '''DirList''' for a file named '''Name'''. DirList is a list of path names delimited by semicolons. If file matching Name is located, function returns a string specifying a path name for that file. If no matching file exists, function returns an empty string.<br />
|-<br />
| procedure '''WideScanDirForFiles'''(const Dir: WideString; var Files: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString); <br />
| You can get a list of the files inside a folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Files''': Where the list of files is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden files?<br />
*'''IncludeSystem''': Do you want to list the system files?<br />
*'''Mask''': List only the files which match a [[ReNamer:Masks|wildcard mask]], or specify an empty string to list all files.<br />
|-<br />
| procedure '''WideScanDirForFolders'''(const Dir: WideString; var Folders: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean); <br />
| You can get a list of the folders inside other folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Folders''': Where the list of folders is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden folders?<br />
*'''IncludeSystem''': Do you want to list the system folders?<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Name Utilities ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideExtractFilePath'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", including the trailing path delimiter, e.g. "C:\Folder\".<br />
|-<br />
| function '''WideExtractFileDir'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", excluding the trailing path delimiter, e.g. "C:\Folder".<br />
|-<br />
| function '''WideExtractFileDrive'''(const FileName: WideString): WideString; <br />
| Returns the drive letter, e.g. "C:".<br />
|-<br />
| function '''WideExtractFileName'''(const FileName: WideString): WideString; <br />
| Returns the filename with extension, e.g. "FileName.txt".<br />
|-<br />
| function '''WideExtractBaseName'''(const FileName: WideString): WideString; <br />
| Returns the base name of the file, i.e. file name without extension and path components.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| Document<br />
|}<br />
<br />
|-<br />
| function '''WideExtractFileExt'''(const FileName: WideString): WideString; <br />
| Returns the file's extension with the dot, e.g. ".txt".<br />
|-<br />
| function '''WideChangeFileExt'''(const FileName, Extension: WideString): WideString; <br />
| Replaces the original extension, and returns the new filename with extension, e.g. "FineName.txt" -&gt; "FineName.pdf".<br />
|-<br />
| function '''WideStripExtension'''(const FileName: WideString): WideString; <br />
| Strips off the extension from the filename, maintaining the path component unaffected.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| C:\Folder\Document<br />
|}<br />
<br />
|-<br />
| function '''WideExpandFileName'''(const FileName: WideString): WideString; <br />
| Converts the relative file name into a fully qualified path. This function does not verify that the resulting path refers to an existing file.<br />
|-<br />
| function '''WideExtractRelativePath'''(const BaseName, DestName: WideString): WideString; <br />
| Creates a relative path to go from '''BaseName''' to '''DestName'''. For example:<br />
<br />
{|<br />
| '''BaseName:'''<br />
| <nowiki>C:\Folder\FileName.txt</nowiki><br />
|-<br />
| '''DestName:'''<br />
| <nowiki>C:\Documents\Article.pdf</nowiki><br />
|-<br />
| '''Result:'''<br />
| <nowiki>..\Documents\Article.pdf</nowiki><br />
|}<br />
<br />
|-<br />
| function '''WideExtractShortPathName'''(const FileName: WideString): WideString; <br />
| It converts a path into it's representation in DOS format.<br />
|-<br />
| function '''WideIncludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a folder '''contains''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideExcludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a file does '''not contain''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideSameFileName'''(const FileName1, FileName2: WideString): Boolean;<br />
| Compares the filenames '''FileName1''' and '''FileName2''', and returns ''TRUE'' if they are considered to be same.<br />
<br />
Note that filenames on Windows platform are case insensitive for comparison purposes, but case preserving when creating new files.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMask'''(const FileName, Mask: WideString): Boolean;<br />
| Check if '''FileName''' matches a [[ReNamer:Masks|wildcard mask]] '''Mask'''. Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask <code>*.txt</code> matches files with a <code>.txt</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMaskList'''(const FileName, MaskList: WideString): Boolean;<br />
| Check if '''FileName''' matches any of the [[ReNamer:Masks|wildcard masks]] listed in '''MaskList'''. The list of masks is separated by semicolons (";"). Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask list <code>*.txt;*.doc</code> matches files with a <code>.txt</code> or <code>.doc</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Read/Write ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileReadFragment'''(const FileName: WideString; Start, Length: Integer): String; <br />
| Starting at position '''Start''', read '''Length''' number of characters of the file '''FileName''' and return them as a string. '''Start''' is 0-based, so in order to start the fragment at the beginning of the file, set this parameter to 0 (zero).<br />
|-<br />
| function '''FileReadLines'''(const FileName: WideString): TAnsiStringArray;<br />
| Read all lines from a file '''FileName'''.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''FileReadLine'''(const FileName: WideString; LineNum: Integer): String; <br />
| Read a line from a file '''FileName''' specified by a line index '''LineNum'''. '''LineNum''' is 1 based, so to get the first line set this parameter to 1 (one).<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileCountLines'''(const FileName: WideString): Integer; <br />
| Count number of lines in the file.<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileReadContent'''(const FileName: WideString): String; <br />
| Return the entire content of the file as a String.<br />
|-<br />
| procedure '''FileWriteContent'''(const FileName: WideString; const Content: String); <br />
| Write '''Content''' to the file. If target file already exists, it will be overwritten.<br />
|-<br />
| procedure '''FileAppendContent'''(const FileName: WideString; const Content: String); <br />
| Append '''Content''' to the end of the file. If target file does not exist, it will be created.<br />
|-<br />
| function '''FileReadText'''(const FileName: WideString): WideString;<br />
| Read text from a file, performing automatic text encoding handling.<br/>''Added in v6.6.0.6 Beta.''<br />
|-<br />
| function '''FileReadTextLines'''(const FileName: WideString): TWideStringArray;<br />
| Read lines of text from a file, performing automatic text encoding handling.<br/>''Added in v6.7.0.1 Beta.''<br />
|}<br />
<br />
Note: Automatic text encoding handling is based on [https://en.wikipedia.org/wiki/Byte_order_mark byte order mark] (BOM) and supports UTF-8, UTF-16BE and UTF-16LE. If no BOM found then text is interpreted as ANSI encoding.<br />
<br />
{{Top}}<br />
<br />
== File Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileTimeModified'''(const FileName: WideString): TDateTime; <br />
| Returns last modified time of the specified file.<br />
|-<br />
| function '''FileTimeCreated'''(const FileName: WideString): TDateTime; <br />
| Returns creation time of the specified file.<br />
|-<br />
| function '''SetFileTimeCreated'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets creation time for the specified file.<br />
|-<br />
| function '''SetFileTimeModified'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets last modified time for the specified file.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Meta Tags Extraction ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''CalculateMetaTag'''(const FilePath: WideString; const MetaTagName: String): WideString; <br />
| Extracts and returns the value of a meta tag specified by '''MetaTagName''' from the file specified by the complete absolute path '''FilePath'''.<br/>''Return type changed from String to WideString in v5.74.4 Beta.''<br />
|-<br />
| function '''CalculateMetaTagFormat'''(const FilePath: WideString; const MetaTagName, DateTimeFormat: String): WideString;<br />
| Same as '''CalculateMetaTag''' except an additional parameter '''DateTimeFormat''' is provided to specify custom Date/Time format to be used instead of the application's default setting.<br/>''Added in v5.74.4 Beta.''<br />
|}<br />
<br />
For example, to extract '''EXIF_Date''' tag from an image and set it to the filename using the default date/time formatting:<br />
<syntaxhighlight lang="pascal"><br />
begin<br />
FileName := CalculateMetaTag(FilePath, 'EXIF_Date');<br />
end.<br />
</syntaxhighlight><br />
<br />
The full list of meta tags can be found in [[ReNamer:Meta Tags|Meta Tags]] article. For help with date/time formatting refer to [[ReNamer:Date and Time format|Date and Time format]].<br />
<br />
{{Top}}<br />
<br />
== Regular Expressions ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsMatchingRegEx'''(const Input, Pattern: WideString; const CaseSensitive: Boolean): Boolean;<br />
| Check for a match against a RegEx pattern.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''ReplaceRegEx'''(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString; <br />
| Find and replace all RegEx pattern matches. Works like the [[ReNamer:Rules:RegEx|Regular Expressions rule]].<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''Replace''' - The replacement pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''UseSubstitution''' - Substitute [[ReNamer:Regular Expressions#Backreferences|backreferences]] in the replacement pattern.<br />
|-<br />
| function '''FindRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean; out Positions: TIntegerArray; out Matches: TWideStringArray): Integer;<br />
| Find matches and positions of a RegEx pattern. Returns the number of matches.<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''Positions''' - Receives a list of positions where the matches have been found.<br />
* '''Matches''' - Receives a list of matches.<br />
<br />
''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''MatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| Returns a list of RegEx matches as an array. Function returns an array of full matches, which matched the entire expression, not the sub-patterns.<br />
|-<br />
| function '''SubMatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| This function is very similar to '''MatchesRegEx''', but instead of returning full matches it will return an array of sub-expression matches for the '''first''' full match.<br />
<br />
In this way, it can easily be combined with '''MatchesRegEx''' function, to allow users to find all global matches, and then parse those matches through '''SubMatchesRegEx''' function to find individual sub-expression matches of each global match.<br />
|}<br />
<br />
Example input and matches for '''MatchesRegEx''' and '''SubMatchesRegEx''' functions:<br />
<br />
{| class="wikitable"<br />
|-<br />
! Input <br />
! Find<br />
! MatchesRegEx matches<br />
! SubMatchesRegEx matches<br />
|-<br />
| A1_B2_C3 <br />
| [A-Z]\d<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| ''(empty)''<br />
|-<br />
| A1_B2_C3 <br />
| ([A-Z])(\d)<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| <br />
* A<br />
* 1<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Process Execution ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''ShellOpenFile'''(const FileName: WideString): Boolean; <br />
| Run (open) a file specified by '''FileName'''. Works like "Start &gt; Run" command. Parameter does not have to be an executable file, it can by any file or protocol with assigned handler. For example, you can open a Word document or a web page, and associated application will be launched:<br />
* <tt><nowiki>ShellOpenFile('http://www.den4b.com/');</nowiki></tt><br />
* <tt><nowiki>ShellOpenFile('C:\Document.doc');</nowiki></tt><br />
<br />
'''Beware:''' This function will evaluate the command for the appropriate way of execution which may sometimes lead to unexpected results. For example when executing ''ShellOpenFile('notepad')'' it could actually run a ''Windows Notepad'' application normally located in "''C:\Windows\notepad.exe''", or some other "''notepad.exe''" file located on the search path (''%PATH%''), or even open "''notepad''" folder located in the current working directory.<br />
|-<br />
| function '''ExecuteProgram'''(const Command: String; WaitForProgram: Boolean): Cardinal; <br />
| Execute a command specified by '''Command''' parameter. Parameter '''WaitForProgram''' allows you to specify whether the code needs to wait until the command (launched program) has finished executing.<br />
|-<br />
| function '''ExecuteProgramShow'''(const Command: String; WaitForProgram: Boolean; ShowWindowFlag: Word): Cardinal;<br />
| Execute a command specified by '''Command''' parameter. '''WaitForProgram''' parameter allows you to specify whether the code needs to wait until the command (launched program) has finished executing. '''ShowWindowFlag''' parameter controls how the window is to be shown.<br />
<br />
Commonly used values for '''ShowWindowFlag''' parameter: <br />
* 0 = Hide the window.<br />
* 1 = Activate and display the window.<br />
* 2 = Activate the window and display it minimized.<br />
* 3 = Activate the window and display it maximized.<br />
* 4 = Display the window, but do not activate it.<br />
* 7 = Display the window minimized, but do not activate it.<br />
* More information: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx ShowWindow Windows API function].<br />
<br />
''Added in v5.75.3 Beta.''<br />
|-<br />
| function '''ExecConsoleApp'''(const CommandLine: String; out Output: String): Cardinal; <br />
| Execute a command line specified by '''CommandLine''' parameter and capture its standard output in the '''Output''' variable. This function should be used only for console style applications. Returns the exit code.<br />
<br />
Console application output uses OEM-defined character set by default, unless application itself changes its output code page. '''OemToAnsi''' and '''OemToWide''' functions can be used to convert OEM output.<br />
<br />
Prior to ''v6.6.0.2 Beta'', OEM to ANSI conversion was automatically applied to the console output. As of ''v6.6.0.2 Beta'', the console output is returned "as is" without any modifications, so to prevent corruption of binary or non-OEM encoded output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Dialogs ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''ShowMessage'''(const Msg: String); <br />
| Show a simple dialog with the message specified by '''Msg''' parameter.<br />
|-<br />
| procedure '''WideShowMessage'''(const Msg: WideString); <br />
| Same as '''ShowMessage''' function but parameter is Unicode text.<br />
|-<br />
| function '''DialogYesNo'''(const Msg: String): Boolean; <br />
| Show a simple prompt with the message specified by '''Msg''' parameter and two button: Yes and No. Returns TRUE if user clicks Yes button, otherwise FALSE.<br />
|-<br />
| function '''WideDialogYesNo'''(const Msg: WideString): Boolean; <br />
| Same as '''DialogYesNo''' function but parameter is WideString text.<br />
|-<br />
| function '''InputBox'''(const ACaption, APrompt, ADefault: String): String; <br />
| Displays a simple dialog box with the given '''ACaption''' and '''APrompt''' message. It asks the user to enter data in a text box on the dialog. A '''ADefault''' value is displayed in the text box initially. If the user presses OK, the value from the text box is returned, otherwise '''ADefault''' value is returned.<br />
|-<br />
| function '''InputQuery'''(const ACaption, APrompt: String; var Value: String): Boolean; <br />
| Operates similar to '''InputBox''' function. The default value and the value of the text box after the dialog is closed are transferred via the '''Value''' parameter. Function returns TRUE is user clicked OK, otherwise returns FALSE.<br />
|-<br />
| function '''WideInputBox'''(const ACaption, APrompt, ADefault: WideString): WideString; <br />
| Same as '''InputBox''' function but operates on WideString text.<br />
|-<br />
| function '''WideInputQuery'''(const ACaption, APrompt: WideString; var Value: WideString): Boolean; <br />
| Same as '''InputQuery''' function but operates on WideString text.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Application ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''GetApplicationPath''': WideString;<br />
| Return full path to the application, for example: "C:\Program Files\ReNamer\ReNamer.exe".<br />
|-<br />
| function '''GetApplicationParams''': TWideStringArray;<br />
| Return an array of command line parameters which were supplied to the application at launch.<br />
|-<br />
| function '''GetCurrentFileIndex''': Integer;<br />
| Get index of the current file. Index ranges from '''1''' to '''GetTotalNumberOfFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfFiles''': Integer;<br />
| Get total number of files in the application.<br />
|-<br />
| function '''GetCurrentMarkedFileIndex''': Integer;<br />
| Get index of the current file, counting only ''marked'' files. Index ranges from '''1''' to '''GetTotalNumberOfMarkedFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfMarkedFiles''': Integer;<br />
| Get total number of ''marked'' files in the application.<br />
|-<br />
| function '''GetAllFiles''': TWideStringArray;<br />
| Get file paths of all available files. ''Added in v5.74.2 Beta.''<br />
|-<br />
| function '''GetMarkedFiles''': TWideStringArray;<br />
| Get file paths of all marked files. ''Added in v5.74.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Global Variables ==<br />
<br />
Global variables allow for efficient storage and exchange of information between scripts.<br />
<br />
Variables do not get cleared automatically, so they exist until cleared manually or until the application terminates. If you wish to clear variables at each Preview, a good mechanism to do that is via the [[ReNamer:Pascal_Script:Initialization_of_variables|script initialization]].<br />
<br />
''Added in v7.4.0.2 Beta.''<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''SetGlobalVar'''(const Name: String; Value: Variant);<br />
| Set a global variable.<br />
|-<br />
| function '''GetGlobalVar'''(const Name: String): Variant;<br />
| Get a global variable. If variable does not exist, the function returns an ''Unassigned'' value.<br />
|-<br />
| function '''GetGlobalVarDef'''(const Name: String; Default: Variant): Variant;<br />
| Get a global variable. If variable does not exist, the function returns the ''Default'' value.<br />
|-<br />
| function '''HasGlobalVar'''(const Name: String): Boolean;<br />
| Check if a global variable exists.<br />
|-<br />
| function '''GetGlobalVarCount''': Integer;<br />
| Retrieve the total number of global variables.<br />
|-<br />
| function '''GetGlobalVarNames''': TAnsiStringArray;<br />
| Retrieve names of all global variables.<br />
|-<br />
| procedure '''ClearGlobalVar'''(const Name: String);<br />
| Clear a global variable.<br />
|-<br />
| procedure '''ClearGlobalVars''';<br />
| Clear all global variables.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== System ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideGetCurrentDir''': WideString; <br />
| Returns the current working directory.<br />
|-<br />
| function '''WideSetCurrentDir'''(const Dir: WideString): Boolean; <br />
| Sets the current working directory to the directory specified by parameter '''Dir'''.<br />
|-<br />
| function '''WideGetTempPath''': WideString;<br />
| Returns system defined temporary directory. If returned value is empty it means that temporary folder could not be determined.<br />
|-<br />
| function '''WideGetEnvironmentVar'''(const VarName: WideString): WideString; <br />
| Returns an environment variable by its name. For example:<br />
<syntaxhighlight lang="pascal"><br />
var<br />
UserName, ComputerName: WideString;<br />
begin<br />
UserName := WideGetEnvironmentVar('USERNAME');<br />
ComputerName := WideGetEnvironmentVar('COMPUTERNAME');<br />
end.<br />
</syntaxhighlight><br />
|}<br />
<br />
{{Top}}<br />
<br />
== Miscellaneous ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''Error'''(const Message: String);<br />
| Abruptly terminate the script with an error message.<br/>''Added in v7.2.0.7 Beta.''<br />
|-<br />
| procedure '''Sleep'''(Milliseconds: Cardinal); <br />
| Sleep (pause the execution) for specified number of '''Milliseconds'''.<br />
|-<br />
| procedure '''DivMod'''(Dividend: Integer; Divisor: Word; var Result, Remainder: Word); <br />
| Perform integer division and fetch the remainder as well, all in one operation. '''Dividend''' is the integer into which you are dividing. '''Divisor''' is the value by which to divide '''Dividend'''. '''Result''' returns the result of the integer division. '''Remainder''' returns the remainder (the difference between Result * Divisor and Dividend).<br />
|-<br />
| procedure '''Randomize'''; <br />
| Prepares the random number generator.<br />
'''Note:''' Should only be called once per application cycle, at the start of the process!<br />
|-<br />
| function '''RandomRange'''(const AFrom, ATo: Integer): Integer; <br />
| Return a random integer number within the specified range from '''AFrom''' (inclusive) to '''ATo''' (non-inclusive).<br />
|-<br />
| function '''RandomFloat''': Extended;<br />
| Return a random floating point value between 0.0 (including) and 1.0 (excluding).<br/>''Added in v6.2.0.8 Beta.''<br />
|- <br />
| function '''RandomBoolean''': Boolean;<br />
| Return a random boolean value, either ''True'' or ''False''.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''RandomString'''(Len: Integer; const Chars: String): String;<br />
| Generate a random string of length '''Len''' using characters selected at random from a string '''Chars'''.<br/>''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''MinInt'''(const A, B: Integer): Integer;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinInt64'''(const A, B: Int64): Int64;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinFloat'''(const A, B: Extended): Extended;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt'''(const A, B: Integer): Integer;<br />
| Return the largest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt64'''(const A, B: Int64): Int64;<br />
| Return the largest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxFloat'''(const A, B: Extended): Extended;<br />
| Return the largest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''GetClipboardText''': WideString; <br />
| Get the content of the the clipboard (text only).<br />
|-<br />
| procedure '''SetClipboardText'''(const S: WideString); <br />
| Set the content of the the clipboard (text only).<br />
|-<br />
| function '''Base64Encode'''(const S: String): String; <br />
| Encode string '''S''' into [http://en.wikipedia.org/wiki/Base64 Base64]. Useful for encoding binary data in order to minimize the likelihood of data being modified in transit through different systems, like email or internet.<br />
|-<br />
| function '''Base64Decode'''(const S: String): String; <br />
| Decode [http://en.wikipedia.org/wiki/Base64 Base64] encoded string.<br />
|-<br />
| function '''URLDecode'''(const Str: String; UsePlusAsSpace: Boolean): WideString;<br />
| Decode URL encoded string. All occurrences of ''%XX'' hex format are decoded, then entire string is decoded from UTF8.<br />
<br />
Optionally, plus signs ("+") can be interpreted as white space by enabling '''UsePlusAsSpace''' parameter, for compatibility with some encoders such as in [http://php.net/manual/en/function.urlencode.php PHP].<br />
<br />
''Added in v5.74.4 Beta. UsePlusAsSpace parameter added in v6.7.0.1 Beta.''<br />
|-<br />
| function '''URLEncode'''(const Str: WideString; UsePlusAsSpace: Boolean): String;<br />
| Encode string using URL encoding. Input string is encoded with UTF8, then all characters except digits and Latin letters are encoded in ''%XX'' hex format.<br />
<br />
Optionally, white spaces can be encoded as plus signs ("+") by enabling '''UsePlusAsSpace''' parameter, for compatibility with some decoders such as in [http://php.net/manual/en/function.urldecode.php PHP].<br />
<br />
''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''GetTickCount''': Cardinal; <br />
| Retrieves the number of milliseconds that have elapsed since the system was started (up to 49.7 days, then timer resets). The precision of this timer is very limited.<br />
|-<br />
| function '''SizeOf'''(X): Integer; <br />
| Pass a variable reference to determine the number of bytes used to represent the variable. Pass a type identifier to determine the number of bytes used to represent instances of that type.<br />
|}<br />
<br />
{{Top}}<br />
<br />
[[Category:ReNamer]]<br />
[[Category:Pascal Script]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script:Functions&diff=3508ReNamer:Pascal Script:Functions2022-12-23T10:59:10Z<p>Den4b: /* Unicode Conversion */ WinCPToUTF8 and UTF8ToWinCP added</p>
<hr />
<div>{{Go|up=ReNamer:Pascal Script|prev=ReNamer:Pascal Script:Types}}<br />
<br />
ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file, strings entered by the user, etc. This functionality is available for use via the [[ReNamer:Rules:PascalScript|PascalScript rule]].<br />
<br />
The difference between a "function" and a "procedure" is that while a function executes an algorithm and returns a value, a procedure just executes an algorithm without returning anything.<br />
<br />
A common "Wide" prefix in function names indicates that the function deals with '''WideString''' type rather than '''AnsiString''' or '''String''' type. For example, ''ShowMessage'' and ''WideShowMessage'' procedures. See the [[ReNamer:Pascal_Script:Types#String_types|String Types]] for more information.<br />
<br />
== Basic String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''Insert'''(Source: String; var S: String; Index: Integer); <br />
| Inserts the string '''S''' into string '''Source''' at position '''Index'''.<br />
|-<br />
| procedure '''Delete'''(var S: String; Index, Count: Integer); <br />
| Deletes '''Count''' characters from the string '''S''', starting from position '''Index'''.<br />
|-<br />
| function '''Copy'''(S: String; Index, Count: Integer): String; <br />
| Copies '''Count''' characters from string '''S''', starting at position '''Index''', and returns them as a new string.<br />
|-<br />
| function '''Pos'''(Substr: String; S: String): Integer; <br />
| Returns the position of a string '''Substr''' in another string '''S'''.<br />
|}<br />
<br />
'''Note:''' Indexes of characters in strings are 1 based, so first character in string S would be S[1].<br />
<br />
{{Top}}<br />
<br />
== Length Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''SetLength'''(var S: Array; NewLength: Integer); <br />
| Sets the length of array variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: String; NewLength: Integer); <br />
| Sets the length of string variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: WideString; NewLength: Integer); <br />
| Sets the length of widestring '''S''' to '''NewLength'''.<br />
|-<br />
| function '''Length'''(const S: Array): Integer; <br />
| Returns the length of array '''S ''' (number of elements).<br />
|-<br />
| function '''Length'''(const S: String): Integer; <br />
| Returns the length of string '''S''' (number of characters).<br />
|-<br />
| function '''Length'''(const S: WideString): Integer;<br />
| Returns the length of WideString '''S''' (number of characters).<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''WideInsert'''(const Substr: WideString; var Dest: WideString; Index: Integer); <br />
| Inserts '''Substr''' in '''Dest''' at position '''Index'''.<br />
|-<br />
| procedure '''WideDelete'''(var S: WideString; Index, Count: Integer); <br />
| Deletes '''Count''' characters from '''S''', starting from the '''Index''' position.<br />
|-<br />
| procedure '''WideDeleteRight'''(var S: WideString; Index, Count: Integer);<br />
| Delete '''Count''' characters from '''S''', starting from the '''Index''' position from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| procedure '''WideSetLength'''(var S: WideString; NewLength: Integer); <br />
| Change the length of string '''S''' to a new length specified by '''NewLength'''. If new length is smaller than original, the string is truncated. If new length is greater than original, the string will be expanded but additional characters will not be initialized and can be anything.<br />
|-<br />
| function '''WideLength'''(const S: WideString): Integer; <br />
| Returns the length of WideString '''S'''.<br />
|-<br />
| function '''WideCopy'''(const S: WideString; Index, Count: Integer): WideString; <br />
| Returns '''Count''' characters from '''S''', starting at position '''Index'''.<br />
|-<br />
| function '''WideCopyRight'''(const S: WideString; Index, Count: Integer): WideString;<br />
| Returns '''Count''' characters from '''S''', starting at position '''Index''' from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WidePos'''(const SubStr, S: WideString): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WidePosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S''' but start searching from position specified by '''Offset'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WideUpperCase'''(const S: WideString): WideString; <br />
| Returns the ALLCAPS version of the WideString '''S'''<br />
|-<br />
| function '''WideLowerCase'''(const S: WideString): WideString; <br />
| Returns the lowercase version of the WideString '''S'''<br />
|-<br />
| function '''WideCompareStr'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-sensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideCompareText'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideSameText'''(const S1, S2: WideString): Boolean; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive. Returns TRUE if both are identical, otherwise returns FALSE.<br />
|-<br />
| function '''WideTextPos'''(const SubStr, S: WideString): Integer; <br />
| Behaves like '''WidePos''' function, except text if processed in case-insensitive manner.<br />
|-<br />
| function '''WideTextPosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer;<br />
| Behaves like '''WidePosEx''' function, except text if processed in case-insensitive manner.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideTrim'''(const S: WideString): WideString; <br />
| Removes leading and trailing spaces and control characters from the given string '''S'''.<br />
|-<br />
| function '''WideTrimChars'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning and the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsLeft'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsRight'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideReverseString'''(const S: WideString): WideString;<br />
| Return a reversed version of string '''S''', i.e. reverse the order of characters.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideRepeatString'''(const S: WideString; Count: Integer): WideString;<br />
| Repeat a string a number of times.<br/>''Added in v6.9.0.3 Beta.''<br />
<br />
|-<br />
| function '''WideReplaceStr'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-sensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
<br />
|-<br />
| function '''WideReplaceText'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-insensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
|-<br />
| function '''WideSplitString'''(const Input, Delimiter: WideString): TWideStringArray; <br />
| <br />
Splits the '''Input''' wherever '''Delimiter''' occurs and returns an array that contains the split parts. <br />
<br />
*The '''Delimiter''' itself can be a multi-character WideString. <br>(Unlike the usual comma, hyphen or space that are used for this purpose) <br />
*The split parts (returned as elements of the array) do not contain the '''Delimiter'''.<br />
<br />
|-<br />
|-<br />
| function '''WideJoinStrings'''(const Strings: TWideStringArray; const Delimiter: WideString): WideString;<br />
| Joins all individual items from '''Strings''' into a single WideString, with '''Delimiter''' inserted between the joined items.<br />
<br />
|-<br />
| function '''WideCaseSentence'''(const S: WideString): WideString; <br />
| Returns a ''Sentence case'' version of parameter '''S'''. <br />
<br />
Only the first alphabetic character is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
''Added in v6.0.0.3 Alpha''.<br />
|-<br />
| function '''WideCaseCapitalize'''(const S: WideString): WideString; <br />
| <br />
Returns the ''Title case'' version of parameter '''S'''. <br />
<br />
First letter of every word is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
|-<br />
| function '''WideCaseInvert'''(const S: WideString): WideString; <br />
| Inverts case of all characters in '''S''' and returns it.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide Character Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsWideCharUpper'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in upper case.<br />
|-<br />
| function '''IsWideCharLower'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in lower case.<br />
|-<br />
| function '''IsWideCharDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a digit (numeric character 0-9). <br />
|-<br />
| function '''IsWideCharSpace'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a white-space character, such as: space, form-feed, newline, carriage-return, tab and vertical-tab (characters classified as C1_SPACE).<br />
|-<br />
| function '''IsWideCharPunct'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a punctuation mark (characters classified as C1_PUNCT).<br />
|-<br />
| function '''IsWideCharCntrl'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a control character (characters classified as C1_CNTRL).<br />
|-<br />
| function '''IsWideCharBlank'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a blank, such as: space and tab (characters classified as C1_BLANK).<br />
|-<br />
| function '''IsWideCharXDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a hexadecimal digit (0-9 or A-F).<br />
|-<br />
| function '''IsWideCharAlpha'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character (a-z or A-Z).<br />
|-<br />
| function '''IsWideCharAlphaNumeric'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character or a numeric character (a-z, A-Z or 0-9).<br />
|-<br />
| function '''IsWideWordBoundaryLeft'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the left.<br />
<br />
Conditions that qualify as word boundaries to the left of character:<br />
# If first character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.'' <br />
|-<br />
| function '''IsWideWordBoundaryRight'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the right.<br />
<br />
Conditions that qualify as word boundaries to the right of character:<br />
# If last character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideCharUpper'''(const WC: WideChar): WideChar; <br />
| Returns an upper case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideCharLower'''(const WC: WideChar): WideChar; <br />
| Returns a lower case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideChr'''(Code: Word): WideChar;<br />
| Create a character from a code point.<br/>''Added in v6.9.0.3 Beta.''<br />
|}<br />
<br />
'''Note:''' Character classifications, such as C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT, C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA - are part of Unicode definitions. More information regarding classification can be found on the internet. For example: [http://www.fileformat.info/info/unicode/ http://www.fileformat.info/info/unicode/].<br />
<br />
{{Top}}<br />
<br />
== Unicode Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideToAnsi'''(const WS: WideString): String; <br />
| Convert WideString type to AnsiString type.<br/>In ReNamer 7.0 and later, this conversion is performed automatically on assignment.<br />
|-<br />
| function '''AnsiToWide'''(const S: String): WideString; <br />
| Convert AnsiString type to WideString type.<br/>In ReNamer 7.0 and later, this conversion is performed automatically on assignment.<br />
|-<br />
| function '''UTF8Encode'''(const WS: WideString): String; <br />
| Convert WideString type to UTF-8 encoded string.<br />
|-<br />
| function '''UTF8Decode'''(const S: String): WideString;<br />
| Convert UTF-8 encoded string to WideString type.<br />
|-<br />
| function '''WinCPToUTF8'''(const S: String): String;<br />
| Convert a string encoded with active [https://en.wikipedia.org/wiki/Windows_code_page system code page] to a UTF-8 encoded string.<br/>Added in ReNamer 7.4.0.3 Beta.<br />
|-<br />
| function '''UTF8ToWinCP'''(const S: String): String;<br />
| Convert a UTF-8 encoded string to a string encoded with active [https://en.wikipedia.org/wiki/Windows_code_page system code page].<br/>Added in ReNamer 7.4.0.3 Beta.<br />
|}<br />
<br />
See [[ReNamer:Pascal_Script:Types#String_types|String types]] for additional information on the default encoding and conversion procedures.<br />
<br />
== Console Output Conversion ==<br />
<br />
OEM-defined character set is commonly used in the output of console applications.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''OemToAnsi'''(const S: String): String;<br />
| Convert OEM string into an ANSI string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''OemToWide'''(const S: String): WideString;<br />
| Convert OEM string into a WideString.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''AnsiToOem'''(const S: String): String;<br />
| Convert ANSI string into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''WideToOem'''(const S: WideString): String; <br />
| Convert WideString into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Basic Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''BoolToStr'''(B: Boolean): String;<br />
| Convert boolean variable into a string. Returns "''True''" or "''False''" string value.<br />
|-<br />
| function '''IntToStr'''(Value: Integer): String; <br />
| Converts an integer to a string. The following assumptions are correct:<br />
<div style="font-family: monospace"><br />
* IntToStr(123) = '123'<br />
* IntToStr(0123) = '123'<br />
* IntToStr(123) <> '0123'<br />
</div><br />
<b>Note:</b> Be cautious of supplying ''Int64'' type as a parameter as it will be type casted to ''Integer'', which significantly reduces the range of possible values (refer to [[ReNamer:Pascal Script:Types|Types]] for more information). You can use '''FormatFloat''' function to convert ''Int64'' values to a string without a loss of range.<br />
|-<br />
| function '''Int64ToStr'''(Value: Int64): String;<br />
| Same as '''IntToStr''' but takes in ''Int64'' typed parameter.<br />
|-<br />
| function '''StrToInt'''(const S: String): Integer; <br />
| Converts a string to an integer. The following equalities are correct:<br />
<div style="font-family: monospace"><br />
* StrToInt('123') = 123<br />
* StrToInt('123') = 0123<br />
* StrToInt('0123') = 123<br />
</div><br />
'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''StrToInt64'''(const S: String): Int64;<br />
| Same as '''StrToInt''' but returns ''Int64'' typed result.<br />
|-<br />
| function '''StrToIntDef'''(const S: String; const Default: Integer): Integer; <br />
| Behaves like '''StrToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''StrToInt64Def'''(const S: String; Default: Int64): Int64;<br />
| Same as '''StrToIntDef''' but operates with ''Int64'' type.<br />
|-<br />
| function '''TryStrToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Converts a string to an integer, but does not throw an error when invalid string is supplied, unlike '''StrToInt'''. Returns ''False'' if conversion operation has failed.<br />
|-<br />
| function '''FloatToStr'''(Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using default system format.<br />
|-<br />
| function '''StrToFloat'''(const S: string): Extended;<br />
| Converts supplied string to a floating point value.<br>'''Warning:''' An error will occur if the parameter to this function cannot be converted to a floating point value!<br />
|-<br />
| function '''StrToFloatDef'''(const S: string; const Default: Extended): Extended;<br />
| Behaves like '''StrToFloat''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to a floating point value.<br />
|-<br />
| function '''FormatFloat'''(const Format: string; Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using user specific '''Format'''.<br/>Check [[#Floating point format specifiers|floating point format specifiers]] below for more information.<br />
|-<br />
| function '''DateToStr'''(D: TDateTime): String; <br />
| Converts a date to a string, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''StrToDate'''(const S: String): TDateTime; <br />
| Converts a date string to a proper TDateTime value, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''IntToHex'''(Value: Integer; Digits: Integer): String; <br />
| Converts an integer to its hexadecimal representation. Here are samples:<br />
<div style="font-family: monospace"><br />
* IntToHex(1234, 1) = '4D2'<br />
* IntToHex(1234, 8) = '000004D2'<br />
</div><br />
|-<br />
| function '''HexToInt'''(const HexNum: String): Integer; <br />
| Converts a hexadecimal value to its decimal representation.<br/>'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''HexToIntDef'''(const HexNum: String; Default: Integer): Integer; <br />
| Behaves like '''HexToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''IntToRoman'''(Value: Integer): String;<br />
| Convert a decimal number to Roman numerals.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToInt'''(const S: String): Integer;<br />
| Convert Roman numerals to a decimal number.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToIntDef'''(const S: String; Default: Integer): Integer;<br />
| Convert Roman numerals to a decimal number. Returns the '''Default''' value in the conversion fails.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''TryRomanToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Try to convert Roman numerals to a decimal number. Does not throw an error on failure, instead it returns ''False''.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''Ord'''(X: Char): Byte; <br />
| Return an ordinal value (byte representation) of a character.<br />
|-<br />
| function '''Chr'''(X: Byte): Char; <br />
| Return a character by its ordinal value (byte representation).<br />
|}<br />
<br />
=== Floating point format specifiers ===<br />
<br />
{| class="wikitable"<br />
! Specifier<br />
! Represents<br />
|-<br />
| <tt>0</tt>&nbsp;(zero)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "0" appears in the format string, then that digit is copied to the output string. Otherwise, a "0" is stored in that position in the output string.<br />
|-<br />
| <tt>#</tt>&nbsp;(hash)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "#" appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string.<br />
|-<br />
| <tt>.</tt>&nbsp;(dot)<br />
| Decimal point. The first "." character in the format string determines the location of the decimal separator in the formatted value, any additional "." characters are ignored.<br />
|-<br />
| <tt>,</tt>&nbsp;(comma)<br />
| Thousand separator. If the format string contains one or more "," characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of "," characters in the format string does not affect the output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Date and Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''Date''': TDateTime; <br />
| Returns the current system date.<br />
|-<br />
| function '''Time''': TDateTime; <br />
| Returns the current system time.<br />
|-<br />
| function '''Now''': TDateTime; <br />
| Returns the current system date and time.<br />
|-<br />
| function '''EncodeDate'''(Year, Month, Day: Word): TDateTime; <br />
| Generates date value for the specified '''Year''', '''Month''', '''Day'''. Parameters must be within a valid date range: Year = 0..9999, Month = 1..12, Day = 1..31 (depending on month/year). An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeTime'''(Hour, Min, Sec, MSec: Word): TDateTime; <br />
| Generates time value for the specified '''Hour''', '''Min''', '''Sec''', '''MSec'''. Parameters must be within a valid time range: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word): TDateTime;<br />
| Generates date-time value for the specified components of date and time. Similar to '''EncodeDate''' and '''EncodeTime'''.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''TryEncodeDate'''(Year, Month, Day: Word; var Date: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeDate''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date value will be written in the '''Date''' variable.<br />
|-<br />
| function '''TryEncodeTime'''(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated time value will be written in the '''Time''' variable.<br />
|-<br />
| function '''TryEncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''EncodeDateTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date-time value will be written in the '''ADateTime''' variable.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| procedure '''DecodeDate'''(const DateTime: TDateTime; var Year, Month, Day: Word); <br />
| Extracts '''Year''', '''Month''' and '''Day''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeTime'''(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word); <br />
| Extracts '''Hour''', '''Min''', '''Sec''' and '''MSec''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeDateTime'''(const DateTime: TDateTime; out Year, Month, Day, Hour, Minute, Second, MilliSecond: Word);<br />
| Similar to '''DecodeDate''' and '''DecodeTime''' but extracts both date and time components at once.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''ComposeDateTime'''(const Date, Time: TDateTime): TDateTime;<br />
| Combine date and time components into a single date-time value.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DateTimeToUnix'''(D: TDateTime): Int64;<br />
| Converts '''D''' value of type '''TDateTime''' to a Unix timestamp.<br />
|-<br />
| function '''UnixToDateTime'''(U: Int64): TDateTime; <br />
| Converts a Unix timestamp to a value of '''TDateTime''' type.<br />
|-<br />
| function '''FormatDateTime'''(const Format: String; DateTime: TDateTime): String;<br />
| Convert date and time value to a string using [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Format''' parameter. <br />
|-<br />
| function '''ScanDateTime'''(const Pattern, Subject: String): TDateTime;<br />
| Convert '''Subject''' string to a date and time value by parsing it according to the [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Pattern''' parameter.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''TryScanDateTime'''(const Pattern, Subject: String; out DateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''ScanDateTime''' function, except it suppresses errors and returns either ''TRUE'' or ''FALSE'' depending on the success of the operation.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''IncYear'''(const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of years (plus or minus).<br />
|-<br />
| function '''IncMonth'''(const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of months (plus or minus).<br />
|-<br />
| function '''IncWeek'''(const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of weeks (plus or minus).<br />
|-<br />
| function '''IncDay'''(const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of days (plus or minus).<br />
|-<br />
| function '''IncHour'''(const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of hours (plus or minus).<br />
|-<br />
| function '''IncMinute'''(const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of minutes (plus or minus).<br />
|-<br />
| function '''IncSecond'''(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of seconds (plus or minus).<br />
|-<br />
| function '''IncMilliSecond'''(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of milliseconds (plus or minus).<br />
|-<br />
| function '''SecondSpan'''(const ANow, AThen: TDateTime): Double;<br />
| Calculate the approximate number of seconds between two date-time values.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DayOfWeek'''(const DateTime: TDateTime): Word; <br />
| Returns the day number of the week. Returned values: 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday.<br/>''Before v6.1 this function used to return 1=Sunday to 7=Saturday.''<br />
|-<br />
| function '''DayOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''DayOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the year.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the year.<br/>''Added in v6.1.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideFileSize'''(const FileName: WideString): Int64; <br />
| Returns the size of the file in bytes. If file does not exist "-1" is returned. The return value is of type ''Int64'' which can store the maximum file size of 9,223,372,036,854,775,807 bytes.<br />
|-<br />
| function '''WideFileExists'''(const FileName: WideString): Boolean; <br />
| Check whether specified file exists. Returns TRUE if file exists, otherwise FALSE.<br />
|-<br />
| function '''WideDirectoryExists'''(const Directory: WideString): Boolean; <br />
| Check whether specified directory exists. Returns TRUE if directory exists, otherwise FALSE.<br />
|-<br />
| function '''WideForceDirectories'''(const Dir: WideString): Boolean; <br />
| Makes sure that that all directories in the path exist. If they don't, function will try to create them, recursively. Returns TRUE if all folders exist or have been successfully created.<br />
|-<br />
| function '''WideCreateDir'''(const Dir: WideString): Boolean; <br />
| Create specified directory (non-recursive). Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideRemoveDir'''(const Dir: WideString): Boolean;<br />
| Remove a directory, if it is empty. Returns TRUE on success, otherwise FALSE.<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideDeleteFile'''(const FileName: WideString): Boolean; <br />
| Delete physical file from the disk. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideDeleteToRecycleBin'''(const FileName: WideString): Boolean;<br />
| Delete file or folder by placing it into the Recycle Bin. Returns TRUE on success, otherwise FALSE.<br />
<br />
'''Note:''' You must provide a full path to delete the file to the Recycle Bin (a quirk of Windows API).<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideRenameFile'''(const OldName, NewName: WideString): Boolean; <br />
| Rename file from '''OldName''' to '''NewName'''. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideCopyFile'''(const FromFile, ToFile: WideString; FailIfExists: Boolean): Boolean;<br />
| Rename file from '''FromFile''' to '''ToFile'''. If '''FailIfExists''' flag is TRUE, file will not be copied when destination file already exists, otherwise, destination file will be overwritten. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideFileSearch'''(const Name, DirList: WideString): WideString; <br />
| Search through the directories passed in '''DirList''' for a file named '''Name'''. DirList is a list of path names delimited by semicolons. If file matching Name is located, function returns a string specifying a path name for that file. If no matching file exists, function returns an empty string.<br />
|-<br />
| procedure '''WideScanDirForFiles'''(const Dir: WideString; var Files: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString); <br />
| You can get a list of the files inside a folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Files''': Where the list of files is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden files?<br />
*'''IncludeSystem''': Do you want to list the system files?<br />
*'''Mask''': List only the files which match a [[ReNamer:Masks|wildcard mask]], or specify an empty string to list all files.<br />
|-<br />
| procedure '''WideScanDirForFolders'''(const Dir: WideString; var Folders: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean); <br />
| You can get a list of the folders inside other folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Folders''': Where the list of folders is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden folders?<br />
*'''IncludeSystem''': Do you want to list the system folders?<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Name Utilities ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideExtractFilePath'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", including the trailing path delimiter, e.g. "C:\Folder\".<br />
|-<br />
| function '''WideExtractFileDir'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", excluding the trailing path delimiter, e.g. "C:\Folder".<br />
|-<br />
| function '''WideExtractFileDrive'''(const FileName: WideString): WideString; <br />
| Returns the drive letter, e.g. "C:".<br />
|-<br />
| function '''WideExtractFileName'''(const FileName: WideString): WideString; <br />
| Returns the filename with extension, e.g. "FileName.txt".<br />
|-<br />
| function '''WideExtractBaseName'''(const FileName: WideString): WideString; <br />
| Returns the base name of the file, i.e. file name without extension and path components.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| Document<br />
|}<br />
<br />
|-<br />
| function '''WideExtractFileExt'''(const FileName: WideString): WideString; <br />
| Returns the file's extension with the dot, e.g. ".txt".<br />
|-<br />
| function '''WideChangeFileExt'''(const FileName, Extension: WideString): WideString; <br />
| Replaces the original extension, and returns the new filename with extension, e.g. "FineName.txt" -&gt; "FineName.pdf".<br />
|-<br />
| function '''WideStripExtension'''(const FileName: WideString): WideString; <br />
| Strips off the extension from the filename, maintaining the path component unaffected.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| C:\Folder\Document<br />
|}<br />
<br />
|-<br />
| function '''WideExpandFileName'''(const FileName: WideString): WideString; <br />
| Converts the relative file name into a fully qualified path. This function does not verify that the resulting path refers to an existing file.<br />
|-<br />
| function '''WideExtractRelativePath'''(const BaseName, DestName: WideString): WideString; <br />
| Creates a relative path to go from '''BaseName''' to '''DestName'''. For example:<br />
<br />
{|<br />
| '''BaseName:'''<br />
| <nowiki>C:\Folder\FileName.txt</nowiki><br />
|-<br />
| '''DestName:'''<br />
| <nowiki>C:\Documents\Article.pdf</nowiki><br />
|-<br />
| '''Result:'''<br />
| <nowiki>..\Documents\Article.pdf</nowiki><br />
|}<br />
<br />
|-<br />
| function '''WideExtractShortPathName'''(const FileName: WideString): WideString; <br />
| It converts a path into it's representation in DOS format.<br />
|-<br />
| function '''WideIncludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a folder '''contains''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideExcludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a file does '''not contain''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideSameFileName'''(const FileName1, FileName2: WideString): Boolean;<br />
| Compares the filenames '''FileName1''' and '''FileName2''', and returns ''TRUE'' if they are considered to be same.<br />
<br />
Note that filenames on Windows platform are case insensitive for comparison purposes, but case preserving when creating new files.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMask'''(const FileName, Mask: WideString): Boolean;<br />
| Check if '''FileName''' matches a [[ReNamer:Masks|wildcard mask]] '''Mask'''. Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask <code>*.txt</code> matches files with a <code>.txt</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMaskList'''(const FileName, MaskList: WideString): Boolean;<br />
| Check if '''FileName''' matches any of the [[ReNamer:Masks|wildcard masks]] listed in '''MaskList'''. The list of masks is separated by semicolons (";"). Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask list <code>*.txt;*.doc</code> matches files with a <code>.txt</code> or <code>.doc</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Read/Write ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileReadFragment'''(const FileName: WideString; Start, Length: Integer): String; <br />
| Starting at position '''Start''', read '''Length''' number of characters of the file '''FileName''' and return them as a string. '''Start''' is 0-based, so in order to start the fragment at the beginning of the file, set this parameter to 0 (zero).<br />
|-<br />
| function '''FileReadLines'''(const FileName: WideString): TAnsiStringArray;<br />
| Read all lines from a file '''FileName'''.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''FileReadLine'''(const FileName: WideString; LineNum: Integer): String; <br />
| Read a line from a file '''FileName''' specified by a line index '''LineNum'''. '''LineNum''' is 1 based, so to get the first line set this parameter to 1 (one).<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileCountLines'''(const FileName: WideString): Integer; <br />
| Count number of lines in the file.<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileReadContent'''(const FileName: WideString): String; <br />
| Return the entire content of the file as a String.<br />
|-<br />
| procedure '''FileWriteContent'''(const FileName: WideString; const Content: String); <br />
| Write '''Content''' to the file. If target file already exists, it will be overwritten.<br />
|-<br />
| procedure '''FileAppendContent'''(const FileName: WideString; const Content: String); <br />
| Append '''Content''' to the end of the file. If target file does not exist, it will be created.<br />
|-<br />
| function '''FileReadText'''(const FileName: WideString): WideString;<br />
| Read text from a file, performing automatic text encoding handling.<br/>''Added in v6.6.0.6 Beta.''<br />
|-<br />
| function '''FileReadTextLines'''(const FileName: WideString): TWideStringArray;<br />
| Read lines of text from a file, performing automatic text encoding handling.<br/>''Added in v6.7.0.1 Beta.''<br />
|}<br />
<br />
Note: Automatic text encoding handling is based on [https://en.wikipedia.org/wiki/Byte_order_mark byte order mark] (BOM) and supports UTF-8, UTF-16BE and UTF-16LE. If no BOM found then text is interpreted as ANSI encoding.<br />
<br />
{{Top}}<br />
<br />
== File Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileTimeModified'''(const FileName: WideString): TDateTime; <br />
| Returns last modified time of the specified file.<br />
|-<br />
| function '''FileTimeCreated'''(const FileName: WideString): TDateTime; <br />
| Returns creation time of the specified file.<br />
|-<br />
| function '''SetFileTimeCreated'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets creation time for the specified file.<br />
|-<br />
| function '''SetFileTimeModified'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets last modified time for the specified file.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Meta Tags Extraction ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''CalculateMetaTag'''(const FilePath: WideString; const MetaTagName: String): WideString; <br />
| Extracts and returns the value of a meta tag specified by '''MetaTagName''' from the file specified by the complete absolute path '''FilePath'''.<br/>''Return type changed from String to WideString in v5.74.4 Beta.''<br />
|-<br />
| function '''CalculateMetaTagFormat'''(const FilePath: WideString; const MetaTagName, DateTimeFormat: String): WideString;<br />
| Same as '''CalculateMetaTag''' except an additional parameter '''DateTimeFormat''' is provided to specify custom Date/Time format to be used instead of the application's default setting.<br/>''Added in v5.74.4 Beta.''<br />
|}<br />
<br />
For example, to extract '''EXIF_Date''' tag from an image and set it to the filename using the default date/time formatting:<br />
<syntaxhighlight lang="pascal"><br />
begin<br />
FileName := CalculateMetaTag(FilePath, 'EXIF_Date');<br />
end.<br />
</syntaxhighlight><br />
<br />
The full list of meta tags can be found in [[ReNamer:Meta Tags|Meta Tags]] article. For help with date/time formatting refer to [[ReNamer:Date and Time format|Date and Time format]].<br />
<br />
{{Top}}<br />
<br />
== Regular Expressions ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsMatchingRegEx'''(const Input, Pattern: WideString; const CaseSensitive: Boolean): Boolean;<br />
| Check for a match against a RegEx pattern.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''ReplaceRegEx'''(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString; <br />
| Find and replace all RegEx pattern matches. Works like the [[ReNamer:Rules:RegEx|Regular Expressions rule]].<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''Replace''' - The replacement pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''UseSubstitution''' - Substitute [[ReNamer:Regular Expressions#Backreferences|backreferences]] in the replacement pattern.<br />
|-<br />
| function '''FindRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean; out Positions: TIntegerArray; out Matches: TWideStringArray): Integer;<br />
| Find matches and positions of a RegEx pattern. Returns the number of matches.<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''Positions''' - Receives a list of positions where the matches have been found.<br />
* '''Matches''' - Receives a list of matches.<br />
<br />
''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''MatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| Returns a list of RegEx matches as an array. Function returns an array of full matches, which matched the entire expression, not the sub-patterns.<br />
|-<br />
| function '''SubMatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| This function is very similar to '''MatchesRegEx''', but instead of returning full matches it will return an array of sub-expression matches for the '''first''' full match.<br />
<br />
In this way, it can easily be combined with '''MatchesRegEx''' function, to allow users to find all global matches, and then parse those matches through '''SubMatchesRegEx''' function to find individual sub-expression matches of each global match.<br />
|}<br />
<br />
Example input and matches for '''MatchesRegEx''' and '''SubMatchesRegEx''' functions:<br />
<br />
{| class="wikitable"<br />
|-<br />
! Input <br />
! Find<br />
! MatchesRegEx matches<br />
! SubMatchesRegEx matches<br />
|-<br />
| A1_B2_C3 <br />
| [A-Z]\d<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| ''(empty)''<br />
|-<br />
| A1_B2_C3 <br />
| ([A-Z])(\d)<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| <br />
* A<br />
* 1<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Process Execution ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''ShellOpenFile'''(const FileName: WideString): Boolean; <br />
| Run (open) a file specified by '''FileName'''. Works like "Start &gt; Run" command. Parameter does not have to be an executable file, it can by any file or protocol with assigned handler. For example, you can open a Word document or a web page, and associated application will be launched:<br />
* <tt><nowiki>ShellOpenFile('http://www.den4b.com/');</nowiki></tt><br />
* <tt><nowiki>ShellOpenFile('C:\Document.doc');</nowiki></tt><br />
<br />
'''Beware:''' This function will evaluate the command for the appropriate way of execution which may sometimes lead to unexpected results. For example when executing ''ShellOpenFile('notepad')'' it could actually run a ''Windows Notepad'' application normally located in "''C:\Windows\notepad.exe''", or some other "''notepad.exe''" file located on the search path (''%PATH%''), or even open "''notepad''" folder located in the current working directory.<br />
|-<br />
| function '''ExecuteProgram'''(const Command: String; WaitForProgram: Boolean): Cardinal; <br />
| Execute a command specified by '''Command''' parameter. Parameter '''WaitForProgram''' allows you to specify whether the code needs to wait until the command (launched program) has finished executing.<br />
|-<br />
| function '''ExecuteProgramShow'''(const Command: String; WaitForProgram: Boolean; ShowWindowFlag: Word): Cardinal;<br />
| Execute a command specified by '''Command''' parameter. '''WaitForProgram''' parameter allows you to specify whether the code needs to wait until the command (launched program) has finished executing. '''ShowWindowFlag''' parameter controls how the window is to be shown.<br />
<br />
Commonly used values for '''ShowWindowFlag''' parameter: <br />
* 0 = Hide the window.<br />
* 1 = Activate and display the window.<br />
* 2 = Activate the window and display it minimized.<br />
* 3 = Activate the window and display it maximized.<br />
* 4 = Display the window, but do not activate it.<br />
* 7 = Display the window minimized, but do not activate it.<br />
* More information: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx ShowWindow Windows API function].<br />
<br />
''Added in v5.75.3 Beta.''<br />
|-<br />
| function '''ExecConsoleApp'''(const CommandLine: String; out Output: String): Cardinal; <br />
| Execute a command line specified by '''CommandLine''' parameter and capture its standard output in the '''Output''' variable. This function should be used only for console style applications. Returns the exit code.<br />
<br />
Console application output uses OEM-defined character set by default, unless application itself changes its output code page. '''OemToAnsi''' and '''OemToWide''' functions can be used to convert OEM output.<br />
<br />
Prior to ''v6.6.0.2 Beta'', OEM to ANSI conversion was automatically applied to the console output. As of ''v6.6.0.2 Beta'', the console output is returned "as is" without any modifications, so to prevent corruption of binary or non-OEM encoded output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Dialogs ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''ShowMessage'''(const Msg: String); <br />
| Show a simple dialog with the message specified by '''Msg''' parameter.<br />
|-<br />
| procedure '''WideShowMessage'''(const Msg: WideString); <br />
| Same as '''ShowMessage''' function but parameter is Unicode text.<br />
|-<br />
| function '''DialogYesNo'''(const Msg: String): Boolean; <br />
| Show a simple prompt with the message specified by '''Msg''' parameter and two button: Yes and No. Returns TRUE if user clicks Yes button, otherwise FALSE.<br />
|-<br />
| function '''WideDialogYesNo'''(const Msg: WideString): Boolean; <br />
| Same as '''DialogYesNo''' function but parameter is WideString text.<br />
|-<br />
| function '''InputBox'''(const ACaption, APrompt, ADefault: String): String; <br />
| Displays a simple dialog box with the given '''ACaption''' and '''APrompt''' message. It asks the user to enter data in a text box on the dialog. A '''ADefault''' value is displayed in the text box initially. If the user presses OK, the value from the text box is returned, otherwise '''ADefault''' value is returned.<br />
|-<br />
| function '''InputQuery'''(const ACaption, APrompt: String; var Value: String): Boolean; <br />
| Operates similar to '''InputBox''' function. The default value and the value of the text box after the dialog is closed are transferred via the '''Value''' parameter. Function returns TRUE is user clicked OK, otherwise returns FALSE.<br />
|-<br />
| function '''WideInputBox'''(const ACaption, APrompt, ADefault: WideString): WideString; <br />
| Same as '''InputBox''' function but operates on WideString text.<br />
|-<br />
| function '''WideInputQuery'''(const ACaption, APrompt: WideString; var Value: WideString): Boolean; <br />
| Same as '''InputQuery''' function but operates on WideString text.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Application ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''GetApplicationPath''': WideString;<br />
| Return full path to the application, for example: "C:\Program Files\ReNamer\ReNamer.exe".<br />
|-<br />
| function '''GetApplicationParams''': TWideStringArray;<br />
| Return an array of command line parameters which were supplied to the application at launch.<br />
|-<br />
| function '''GetCurrentFileIndex''': Integer;<br />
| Get index of the current file. Index ranges from '''1''' to '''GetTotalNumberOfFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfFiles''': Integer;<br />
| Get total number of files in the application.<br />
|-<br />
| function '''GetCurrentMarkedFileIndex''': Integer;<br />
| Get index of the current file, counting only ''marked'' files. Index ranges from '''1''' to '''GetTotalNumberOfMarkedFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfMarkedFiles''': Integer;<br />
| Get total number of ''marked'' files in the application.<br />
|-<br />
| function '''GetAllFiles''': TWideStringArray;<br />
| Get file paths of all available files. ''Added in v5.74.2 Beta.''<br />
|-<br />
| function '''GetMarkedFiles''': TWideStringArray;<br />
| Get file paths of all marked files. ''Added in v5.74.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Global Variables ==<br />
<br />
Global variables allow for efficient storage and exchange of information between scripts.<br />
<br />
Variables do not get cleared automatically, so they exist until cleared manually or until the application terminates. If you wish to clear variables at each Preview, a good mechanism to do that is via the [[ReNamer:Pascal_Script:Initialization_of_variables|script initialization]].<br />
<br />
''Added in v7.4.0.2 Beta.''<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''SetGlobalVar'''(const Name: String; Value: Variant);<br />
| Set a global variable.<br />
|-<br />
| function '''GetGlobalVar'''(const Name: String): Variant;<br />
| Get a global variable. If variable does not exist, the function returns an ''Unassigned'' value.<br />
|-<br />
| function '''GetGlobalVarDef'''(const Name: String; Default: Variant): Variant;<br />
| Get a global variable. If variable does not exist, the function returns the ''Default'' value.<br />
|-<br />
| function '''HasGlobalVar'''(const Name: String): Boolean;<br />
| Check if a global variable exists.<br />
|-<br />
| function '''GetGlobalVarCount''': Integer;<br />
| Retrieve the total number of global variables.<br />
|-<br />
| function '''GetGlobalVarNames''': TAnsiStringArray;<br />
| Retrieve names of all global variables.<br />
|-<br />
| procedure '''ClearGlobalVar'''(const Name: String);<br />
| Clear a global variable.<br />
|-<br />
| procedure '''ClearGlobalVars''';<br />
| Clear all global variables.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== System ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideGetCurrentDir''': WideString; <br />
| Returns the current working directory.<br />
|-<br />
| function '''WideSetCurrentDir'''(const Dir: WideString): Boolean; <br />
| Sets the current working directory to the directory specified by parameter '''Dir'''.<br />
|-<br />
| function '''WideGetTempPath''': WideString;<br />
| Returns system defined temporary directory. If returned value is empty it means that temporary folder could not be determined.<br />
|-<br />
| function '''WideGetEnvironmentVar'''(const VarName: WideString): WideString; <br />
| Returns an environment variable by its name. For example:<br />
<syntaxhighlight lang="pascal"><br />
var<br />
UserName, ComputerName: WideString;<br />
begin<br />
UserName := WideGetEnvironmentVar('USERNAME');<br />
ComputerName := WideGetEnvironmentVar('COMPUTERNAME');<br />
end.<br />
</syntaxhighlight><br />
|}<br />
<br />
{{Top}}<br />
<br />
== Miscellaneous ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''Error'''(const Message: String);<br />
| Abruptly terminate the script with an error message.<br/>''Added in v7.2.0.7 Beta.''<br />
|-<br />
| procedure '''Sleep'''(Milliseconds: Cardinal); <br />
| Sleep (pause the execution) for specified number of '''Milliseconds'''.<br />
|-<br />
| procedure '''DivMod'''(Dividend: Integer; Divisor: Word; var Result, Remainder: Word); <br />
| Perform integer division and fetch the remainder as well, all in one operation. '''Dividend''' is the integer into which you are dividing. '''Divisor''' is the value by which to divide '''Dividend'''. '''Result''' returns the result of the integer division. '''Remainder''' returns the remainder (the difference between Result * Divisor and Dividend).<br />
|-<br />
| procedure '''Randomize'''; <br />
| Prepares the random number generator.<br />
'''Note:''' Should only be called once per application cycle, at the start of the process!<br />
|-<br />
| function '''RandomRange'''(const AFrom, ATo: Integer): Integer; <br />
| Return a random integer number within the specified range from '''AFrom''' (inclusive) to '''ATo''' (non-inclusive).<br />
|-<br />
| function '''RandomFloat''': Extended;<br />
| Return a random floating point value between 0.0 (including) and 1.0 (excluding).<br/>''Added in v6.2.0.8 Beta.''<br />
|- <br />
| function '''RandomBoolean''': Boolean;<br />
| Return a random boolean value, either ''True'' or ''False''.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''RandomString'''(Len: Integer; const Chars: String): String;<br />
| Generate a random string of length '''Len''' using characters selected at random from a string '''Chars'''.<br/>''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''MinInt'''(const A, B: Integer): Integer;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinInt64'''(const A, B: Int64): Int64;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinFloat'''(const A, B: Extended): Extended;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt'''(const A, B: Integer): Integer;<br />
| Return the largest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt64'''(const A, B: Int64): Int64;<br />
| Return the largest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxFloat'''(const A, B: Extended): Extended;<br />
| Return the largest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''GetClipboardText''': WideString; <br />
| Get the content of the the clipboard (text only).<br />
|-<br />
| procedure '''SetClipboardText'''(const S: WideString); <br />
| Set the content of the the clipboard (text only).<br />
|-<br />
| function '''Base64Encode'''(const S: String): String; <br />
| Encode string '''S''' into [http://en.wikipedia.org/wiki/Base64 Base64]. Useful for encoding binary data in order to minimize the likelihood of data being modified in transit through different systems, like email or internet.<br />
|-<br />
| function '''Base64Decode'''(const S: String): String; <br />
| Decode [http://en.wikipedia.org/wiki/Base64 Base64] encoded string.<br />
|-<br />
| function '''URLDecode'''(const Str: String; UsePlusAsSpace: Boolean): WideString;<br />
| Decode URL encoded string. All occurrences of ''%XX'' hex format are decoded, then entire string is decoded from UTF8.<br />
<br />
Optionally, plus signs ("+") can be interpreted as white space by enabling '''UsePlusAsSpace''' parameter, for compatibility with some encoders such as in [http://php.net/manual/en/function.urlencode.php PHP].<br />
<br />
''Added in v5.74.4 Beta. UsePlusAsSpace parameter added in v6.7.0.1 Beta.''<br />
|-<br />
| function '''URLEncode'''(const Str: WideString; UsePlusAsSpace: Boolean): String;<br />
| Encode string using URL encoding. Input string is encoded with UTF8, then all characters except digits and Latin letters are encoded in ''%XX'' hex format.<br />
<br />
Optionally, white spaces can be encoded as plus signs ("+") by enabling '''UsePlusAsSpace''' parameter, for compatibility with some decoders such as in [http://php.net/manual/en/function.urldecode.php PHP].<br />
<br />
''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''GetTickCount''': Cardinal; <br />
| Retrieves the number of milliseconds that have elapsed since the system was started (up to 49.7 days, then timer resets). The precision of this timer is very limited.<br />
|-<br />
| function '''SizeOf'''(X): Integer; <br />
| Pass a variable reference to determine the number of bytes used to represent the variable. Pass a type identifier to determine the number of bytes used to represent instances of that type.<br />
|}<br />
<br />
{{Top}}<br />
<br />
[[Category:ReNamer]]<br />
[[Category:Pascal Script]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script:Functions&diff=3507ReNamer:Pascal Script:Functions2022-12-23T10:54:00Z<p>Den4b: /* Unicode Conversion */ Automatic conversion in ReNamer 7.0 and later</p>
<hr />
<div>{{Go|up=ReNamer:Pascal Script|prev=ReNamer:Pascal Script:Types}}<br />
<br />
ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file, strings entered by the user, etc. This functionality is available for use via the [[ReNamer:Rules:PascalScript|PascalScript rule]].<br />
<br />
The difference between a "function" and a "procedure" is that while a function executes an algorithm and returns a value, a procedure just executes an algorithm without returning anything.<br />
<br />
A common "Wide" prefix in function names indicates that the function deals with '''WideString''' type rather than '''AnsiString''' or '''String''' type. For example, ''ShowMessage'' and ''WideShowMessage'' procedures. See the [[ReNamer:Pascal_Script:Types#String_types|String Types]] for more information.<br />
<br />
== Basic String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''Insert'''(Source: String; var S: String; Index: Integer); <br />
| Inserts the string '''S''' into string '''Source''' at position '''Index'''.<br />
|-<br />
| procedure '''Delete'''(var S: String; Index, Count: Integer); <br />
| Deletes '''Count''' characters from the string '''S''', starting from position '''Index'''.<br />
|-<br />
| function '''Copy'''(S: String; Index, Count: Integer): String; <br />
| Copies '''Count''' characters from string '''S''', starting at position '''Index''', and returns them as a new string.<br />
|-<br />
| function '''Pos'''(Substr: String; S: String): Integer; <br />
| Returns the position of a string '''Substr''' in another string '''S'''.<br />
|}<br />
<br />
'''Note:''' Indexes of characters in strings are 1 based, so first character in string S would be S[1].<br />
<br />
{{Top}}<br />
<br />
== Length Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''SetLength'''(var S: Array; NewLength: Integer); <br />
| Sets the length of array variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: String; NewLength: Integer); <br />
| Sets the length of string variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: WideString; NewLength: Integer); <br />
| Sets the length of widestring '''S''' to '''NewLength'''.<br />
|-<br />
| function '''Length'''(const S: Array): Integer; <br />
| Returns the length of array '''S ''' (number of elements).<br />
|-<br />
| function '''Length'''(const S: String): Integer; <br />
| Returns the length of string '''S''' (number of characters).<br />
|-<br />
| function '''Length'''(const S: WideString): Integer;<br />
| Returns the length of WideString '''S''' (number of characters).<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''WideInsert'''(const Substr: WideString; var Dest: WideString; Index: Integer); <br />
| Inserts '''Substr''' in '''Dest''' at position '''Index'''.<br />
|-<br />
| procedure '''WideDelete'''(var S: WideString; Index, Count: Integer); <br />
| Deletes '''Count''' characters from '''S''', starting from the '''Index''' position.<br />
|-<br />
| procedure '''WideDeleteRight'''(var S: WideString; Index, Count: Integer);<br />
| Delete '''Count''' characters from '''S''', starting from the '''Index''' position from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| procedure '''WideSetLength'''(var S: WideString; NewLength: Integer); <br />
| Change the length of string '''S''' to a new length specified by '''NewLength'''. If new length is smaller than original, the string is truncated. If new length is greater than original, the string will be expanded but additional characters will not be initialized and can be anything.<br />
|-<br />
| function '''WideLength'''(const S: WideString): Integer; <br />
| Returns the length of WideString '''S'''.<br />
|-<br />
| function '''WideCopy'''(const S: WideString; Index, Count: Integer): WideString; <br />
| Returns '''Count''' characters from '''S''', starting at position '''Index'''.<br />
|-<br />
| function '''WideCopyRight'''(const S: WideString; Index, Count: Integer): WideString;<br />
| Returns '''Count''' characters from '''S''', starting at position '''Index''' from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WidePos'''(const SubStr, S: WideString): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WidePosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S''' but start searching from position specified by '''Offset'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WideUpperCase'''(const S: WideString): WideString; <br />
| Returns the ALLCAPS version of the WideString '''S'''<br />
|-<br />
| function '''WideLowerCase'''(const S: WideString): WideString; <br />
| Returns the lowercase version of the WideString '''S'''<br />
|-<br />
| function '''WideCompareStr'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-sensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideCompareText'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideSameText'''(const S1, S2: WideString): Boolean; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive. Returns TRUE if both are identical, otherwise returns FALSE.<br />
|-<br />
| function '''WideTextPos'''(const SubStr, S: WideString): Integer; <br />
| Behaves like '''WidePos''' function, except text if processed in case-insensitive manner.<br />
|-<br />
| function '''WideTextPosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer;<br />
| Behaves like '''WidePosEx''' function, except text if processed in case-insensitive manner.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideTrim'''(const S: WideString): WideString; <br />
| Removes leading and trailing spaces and control characters from the given string '''S'''.<br />
|-<br />
| function '''WideTrimChars'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning and the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsLeft'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsRight'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideReverseString'''(const S: WideString): WideString;<br />
| Return a reversed version of string '''S''', i.e. reverse the order of characters.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideRepeatString'''(const S: WideString; Count: Integer): WideString;<br />
| Repeat a string a number of times.<br/>''Added in v6.9.0.3 Beta.''<br />
<br />
|-<br />
| function '''WideReplaceStr'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-sensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
<br />
|-<br />
| function '''WideReplaceText'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-insensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
|-<br />
| function '''WideSplitString'''(const Input, Delimiter: WideString): TWideStringArray; <br />
| <br />
Splits the '''Input''' wherever '''Delimiter''' occurs and returns an array that contains the split parts. <br />
<br />
*The '''Delimiter''' itself can be a multi-character WideString. <br>(Unlike the usual comma, hyphen or space that are used for this purpose) <br />
*The split parts (returned as elements of the array) do not contain the '''Delimiter'''.<br />
<br />
|-<br />
|-<br />
| function '''WideJoinStrings'''(const Strings: TWideStringArray; const Delimiter: WideString): WideString;<br />
| Joins all individual items from '''Strings''' into a single WideString, with '''Delimiter''' inserted between the joined items.<br />
<br />
|-<br />
| function '''WideCaseSentence'''(const S: WideString): WideString; <br />
| Returns a ''Sentence case'' version of parameter '''S'''. <br />
<br />
Only the first alphabetic character is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
''Added in v6.0.0.3 Alpha''.<br />
|-<br />
| function '''WideCaseCapitalize'''(const S: WideString): WideString; <br />
| <br />
Returns the ''Title case'' version of parameter '''S'''. <br />
<br />
First letter of every word is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
|-<br />
| function '''WideCaseInvert'''(const S: WideString): WideString; <br />
| Inverts case of all characters in '''S''' and returns it.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide Character Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsWideCharUpper'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in upper case.<br />
|-<br />
| function '''IsWideCharLower'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in lower case.<br />
|-<br />
| function '''IsWideCharDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a digit (numeric character 0-9). <br />
|-<br />
| function '''IsWideCharSpace'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a white-space character, such as: space, form-feed, newline, carriage-return, tab and vertical-tab (characters classified as C1_SPACE).<br />
|-<br />
| function '''IsWideCharPunct'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a punctuation mark (characters classified as C1_PUNCT).<br />
|-<br />
| function '''IsWideCharCntrl'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a control character (characters classified as C1_CNTRL).<br />
|-<br />
| function '''IsWideCharBlank'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a blank, such as: space and tab (characters classified as C1_BLANK).<br />
|-<br />
| function '''IsWideCharXDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a hexadecimal digit (0-9 or A-F).<br />
|-<br />
| function '''IsWideCharAlpha'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character (a-z or A-Z).<br />
|-<br />
| function '''IsWideCharAlphaNumeric'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character or a numeric character (a-z, A-Z or 0-9).<br />
|-<br />
| function '''IsWideWordBoundaryLeft'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the left.<br />
<br />
Conditions that qualify as word boundaries to the left of character:<br />
# If first character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.'' <br />
|-<br />
| function '''IsWideWordBoundaryRight'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the right.<br />
<br />
Conditions that qualify as word boundaries to the right of character:<br />
# If last character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideCharUpper'''(const WC: WideChar): WideChar; <br />
| Returns an upper case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideCharLower'''(const WC: WideChar): WideChar; <br />
| Returns a lower case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideChr'''(Code: Word): WideChar;<br />
| Create a character from a code point.<br/>''Added in v6.9.0.3 Beta.''<br />
|}<br />
<br />
'''Note:''' Character classifications, such as C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT, C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA - are part of Unicode definitions. More information regarding classification can be found on the internet. For example: [http://www.fileformat.info/info/unicode/ http://www.fileformat.info/info/unicode/].<br />
<br />
{{Top}}<br />
<br />
== Unicode Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideToAnsi'''(const WS: WideString): String; <br />
| Convert WideString type to AnsiString type.<br/>In ReNamer 7.0 and later, this conversion is performed automatically on assignment.<br />
|-<br />
| function '''AnsiToWide'''(const S: String): WideString; <br />
| Convert AnsiString type to WideString type.<br/>In ReNamer 7.0 and later, this conversion is performed automatically on assignment.<br />
|-<br />
| function '''UTF8Encode'''(const WS: WideString): String; <br />
| Convert WideString type to UTF-8 encoded string.<br />
|-<br />
| function '''UTF8Decode'''(const S: String): WideString;<br />
| Convert UTF-8 encoded string to WideString type.<br />
|}<br />
<br />
See [[ReNamer:Pascal_Script:Types#String_types|String types]] for additional information on the default encoding and conversion procedures.<br />
<br />
== Console Output Conversion ==<br />
<br />
OEM-defined character set is commonly used in the output of console applications.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''OemToAnsi'''(const S: String): String;<br />
| Convert OEM string into an ANSI string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''OemToWide'''(const S: String): WideString;<br />
| Convert OEM string into a WideString.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''AnsiToOem'''(const S: String): String;<br />
| Convert ANSI string into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''WideToOem'''(const S: WideString): String; <br />
| Convert WideString into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Basic Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''BoolToStr'''(B: Boolean): String;<br />
| Convert boolean variable into a string. Returns "''True''" or "''False''" string value.<br />
|-<br />
| function '''IntToStr'''(Value: Integer): String; <br />
| Converts an integer to a string. The following assumptions are correct:<br />
<div style="font-family: monospace"><br />
* IntToStr(123) = '123'<br />
* IntToStr(0123) = '123'<br />
* IntToStr(123) <> '0123'<br />
</div><br />
<b>Note:</b> Be cautious of supplying ''Int64'' type as a parameter as it will be type casted to ''Integer'', which significantly reduces the range of possible values (refer to [[ReNamer:Pascal Script:Types|Types]] for more information). You can use '''FormatFloat''' function to convert ''Int64'' values to a string without a loss of range.<br />
|-<br />
| function '''Int64ToStr'''(Value: Int64): String;<br />
| Same as '''IntToStr''' but takes in ''Int64'' typed parameter.<br />
|-<br />
| function '''StrToInt'''(const S: String): Integer; <br />
| Converts a string to an integer. The following equalities are correct:<br />
<div style="font-family: monospace"><br />
* StrToInt('123') = 123<br />
* StrToInt('123') = 0123<br />
* StrToInt('0123') = 123<br />
</div><br />
'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''StrToInt64'''(const S: String): Int64;<br />
| Same as '''StrToInt''' but returns ''Int64'' typed result.<br />
|-<br />
| function '''StrToIntDef'''(const S: String; const Default: Integer): Integer; <br />
| Behaves like '''StrToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''StrToInt64Def'''(const S: String; Default: Int64): Int64;<br />
| Same as '''StrToIntDef''' but operates with ''Int64'' type.<br />
|-<br />
| function '''TryStrToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Converts a string to an integer, but does not throw an error when invalid string is supplied, unlike '''StrToInt'''. Returns ''False'' if conversion operation has failed.<br />
|-<br />
| function '''FloatToStr'''(Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using default system format.<br />
|-<br />
| function '''StrToFloat'''(const S: string): Extended;<br />
| Converts supplied string to a floating point value.<br>'''Warning:''' An error will occur if the parameter to this function cannot be converted to a floating point value!<br />
|-<br />
| function '''StrToFloatDef'''(const S: string; const Default: Extended): Extended;<br />
| Behaves like '''StrToFloat''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to a floating point value.<br />
|-<br />
| function '''FormatFloat'''(const Format: string; Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using user specific '''Format'''.<br/>Check [[#Floating point format specifiers|floating point format specifiers]] below for more information.<br />
|-<br />
| function '''DateToStr'''(D: TDateTime): String; <br />
| Converts a date to a string, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''StrToDate'''(const S: String): TDateTime; <br />
| Converts a date string to a proper TDateTime value, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''IntToHex'''(Value: Integer; Digits: Integer): String; <br />
| Converts an integer to its hexadecimal representation. Here are samples:<br />
<div style="font-family: monospace"><br />
* IntToHex(1234, 1) = '4D2'<br />
* IntToHex(1234, 8) = '000004D2'<br />
</div><br />
|-<br />
| function '''HexToInt'''(const HexNum: String): Integer; <br />
| Converts a hexadecimal value to its decimal representation.<br/>'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''HexToIntDef'''(const HexNum: String; Default: Integer): Integer; <br />
| Behaves like '''HexToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''IntToRoman'''(Value: Integer): String;<br />
| Convert a decimal number to Roman numerals.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToInt'''(const S: String): Integer;<br />
| Convert Roman numerals to a decimal number.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToIntDef'''(const S: String; Default: Integer): Integer;<br />
| Convert Roman numerals to a decimal number. Returns the '''Default''' value in the conversion fails.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''TryRomanToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Try to convert Roman numerals to a decimal number. Does not throw an error on failure, instead it returns ''False''.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''Ord'''(X: Char): Byte; <br />
| Return an ordinal value (byte representation) of a character.<br />
|-<br />
| function '''Chr'''(X: Byte): Char; <br />
| Return a character by its ordinal value (byte representation).<br />
|}<br />
<br />
=== Floating point format specifiers ===<br />
<br />
{| class="wikitable"<br />
! Specifier<br />
! Represents<br />
|-<br />
| <tt>0</tt>&nbsp;(zero)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "0" appears in the format string, then that digit is copied to the output string. Otherwise, a "0" is stored in that position in the output string.<br />
|-<br />
| <tt>#</tt>&nbsp;(hash)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "#" appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string.<br />
|-<br />
| <tt>.</tt>&nbsp;(dot)<br />
| Decimal point. The first "." character in the format string determines the location of the decimal separator in the formatted value, any additional "." characters are ignored.<br />
|-<br />
| <tt>,</tt>&nbsp;(comma)<br />
| Thousand separator. If the format string contains one or more "," characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of "," characters in the format string does not affect the output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Date and Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''Date''': TDateTime; <br />
| Returns the current system date.<br />
|-<br />
| function '''Time''': TDateTime; <br />
| Returns the current system time.<br />
|-<br />
| function '''Now''': TDateTime; <br />
| Returns the current system date and time.<br />
|-<br />
| function '''EncodeDate'''(Year, Month, Day: Word): TDateTime; <br />
| Generates date value for the specified '''Year''', '''Month''', '''Day'''. Parameters must be within a valid date range: Year = 0..9999, Month = 1..12, Day = 1..31 (depending on month/year). An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeTime'''(Hour, Min, Sec, MSec: Word): TDateTime; <br />
| Generates time value for the specified '''Hour''', '''Min''', '''Sec''', '''MSec'''. Parameters must be within a valid time range: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word): TDateTime;<br />
| Generates date-time value for the specified components of date and time. Similar to '''EncodeDate''' and '''EncodeTime'''.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''TryEncodeDate'''(Year, Month, Day: Word; var Date: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeDate''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date value will be written in the '''Date''' variable.<br />
|-<br />
| function '''TryEncodeTime'''(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated time value will be written in the '''Time''' variable.<br />
|-<br />
| function '''TryEncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''EncodeDateTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date-time value will be written in the '''ADateTime''' variable.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| procedure '''DecodeDate'''(const DateTime: TDateTime; var Year, Month, Day: Word); <br />
| Extracts '''Year''', '''Month''' and '''Day''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeTime'''(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word); <br />
| Extracts '''Hour''', '''Min''', '''Sec''' and '''MSec''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeDateTime'''(const DateTime: TDateTime; out Year, Month, Day, Hour, Minute, Second, MilliSecond: Word);<br />
| Similar to '''DecodeDate''' and '''DecodeTime''' but extracts both date and time components at once.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''ComposeDateTime'''(const Date, Time: TDateTime): TDateTime;<br />
| Combine date and time components into a single date-time value.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DateTimeToUnix'''(D: TDateTime): Int64;<br />
| Converts '''D''' value of type '''TDateTime''' to a Unix timestamp.<br />
|-<br />
| function '''UnixToDateTime'''(U: Int64): TDateTime; <br />
| Converts a Unix timestamp to a value of '''TDateTime''' type.<br />
|-<br />
| function '''FormatDateTime'''(const Format: String; DateTime: TDateTime): String;<br />
| Convert date and time value to a string using [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Format''' parameter. <br />
|-<br />
| function '''ScanDateTime'''(const Pattern, Subject: String): TDateTime;<br />
| Convert '''Subject''' string to a date and time value by parsing it according to the [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Pattern''' parameter.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''TryScanDateTime'''(const Pattern, Subject: String; out DateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''ScanDateTime''' function, except it suppresses errors and returns either ''TRUE'' or ''FALSE'' depending on the success of the operation.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''IncYear'''(const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of years (plus or minus).<br />
|-<br />
| function '''IncMonth'''(const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of months (plus or minus).<br />
|-<br />
| function '''IncWeek'''(const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of weeks (plus or minus).<br />
|-<br />
| function '''IncDay'''(const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of days (plus or minus).<br />
|-<br />
| function '''IncHour'''(const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of hours (plus or minus).<br />
|-<br />
| function '''IncMinute'''(const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of minutes (plus or minus).<br />
|-<br />
| function '''IncSecond'''(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of seconds (plus or minus).<br />
|-<br />
| function '''IncMilliSecond'''(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of milliseconds (plus or minus).<br />
|-<br />
| function '''SecondSpan'''(const ANow, AThen: TDateTime): Double;<br />
| Calculate the approximate number of seconds between two date-time values.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DayOfWeek'''(const DateTime: TDateTime): Word; <br />
| Returns the day number of the week. Returned values: 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday.<br/>''Before v6.1 this function used to return 1=Sunday to 7=Saturday.''<br />
|-<br />
| function '''DayOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''DayOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the year.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the year.<br/>''Added in v6.1.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideFileSize'''(const FileName: WideString): Int64; <br />
| Returns the size of the file in bytes. If file does not exist "-1" is returned. The return value is of type ''Int64'' which can store the maximum file size of 9,223,372,036,854,775,807 bytes.<br />
|-<br />
| function '''WideFileExists'''(const FileName: WideString): Boolean; <br />
| Check whether specified file exists. Returns TRUE if file exists, otherwise FALSE.<br />
|-<br />
| function '''WideDirectoryExists'''(const Directory: WideString): Boolean; <br />
| Check whether specified directory exists. Returns TRUE if directory exists, otherwise FALSE.<br />
|-<br />
| function '''WideForceDirectories'''(const Dir: WideString): Boolean; <br />
| Makes sure that that all directories in the path exist. If they don't, function will try to create them, recursively. Returns TRUE if all folders exist or have been successfully created.<br />
|-<br />
| function '''WideCreateDir'''(const Dir: WideString): Boolean; <br />
| Create specified directory (non-recursive). Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideRemoveDir'''(const Dir: WideString): Boolean;<br />
| Remove a directory, if it is empty. Returns TRUE on success, otherwise FALSE.<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideDeleteFile'''(const FileName: WideString): Boolean; <br />
| Delete physical file from the disk. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideDeleteToRecycleBin'''(const FileName: WideString): Boolean;<br />
| Delete file or folder by placing it into the Recycle Bin. Returns TRUE on success, otherwise FALSE.<br />
<br />
'''Note:''' You must provide a full path to delete the file to the Recycle Bin (a quirk of Windows API).<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideRenameFile'''(const OldName, NewName: WideString): Boolean; <br />
| Rename file from '''OldName''' to '''NewName'''. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideCopyFile'''(const FromFile, ToFile: WideString; FailIfExists: Boolean): Boolean;<br />
| Rename file from '''FromFile''' to '''ToFile'''. If '''FailIfExists''' flag is TRUE, file will not be copied when destination file already exists, otherwise, destination file will be overwritten. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideFileSearch'''(const Name, DirList: WideString): WideString; <br />
| Search through the directories passed in '''DirList''' for a file named '''Name'''. DirList is a list of path names delimited by semicolons. If file matching Name is located, function returns a string specifying a path name for that file. If no matching file exists, function returns an empty string.<br />
|-<br />
| procedure '''WideScanDirForFiles'''(const Dir: WideString; var Files: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString); <br />
| You can get a list of the files inside a folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Files''': Where the list of files is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden files?<br />
*'''IncludeSystem''': Do you want to list the system files?<br />
*'''Mask''': List only the files which match a [[ReNamer:Masks|wildcard mask]], or specify an empty string to list all files.<br />
|-<br />
| procedure '''WideScanDirForFolders'''(const Dir: WideString; var Folders: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean); <br />
| You can get a list of the folders inside other folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Folders''': Where the list of folders is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden folders?<br />
*'''IncludeSystem''': Do you want to list the system folders?<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Name Utilities ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideExtractFilePath'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", including the trailing path delimiter, e.g. "C:\Folder\".<br />
|-<br />
| function '''WideExtractFileDir'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", excluding the trailing path delimiter, e.g. "C:\Folder".<br />
|-<br />
| function '''WideExtractFileDrive'''(const FileName: WideString): WideString; <br />
| Returns the drive letter, e.g. "C:".<br />
|-<br />
| function '''WideExtractFileName'''(const FileName: WideString): WideString; <br />
| Returns the filename with extension, e.g. "FileName.txt".<br />
|-<br />
| function '''WideExtractBaseName'''(const FileName: WideString): WideString; <br />
| Returns the base name of the file, i.e. file name without extension and path components.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| Document<br />
|}<br />
<br />
|-<br />
| function '''WideExtractFileExt'''(const FileName: WideString): WideString; <br />
| Returns the file's extension with the dot, e.g. ".txt".<br />
|-<br />
| function '''WideChangeFileExt'''(const FileName, Extension: WideString): WideString; <br />
| Replaces the original extension, and returns the new filename with extension, e.g. "FineName.txt" -&gt; "FineName.pdf".<br />
|-<br />
| function '''WideStripExtension'''(const FileName: WideString): WideString; <br />
| Strips off the extension from the filename, maintaining the path component unaffected.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| C:\Folder\Document<br />
|}<br />
<br />
|-<br />
| function '''WideExpandFileName'''(const FileName: WideString): WideString; <br />
| Converts the relative file name into a fully qualified path. This function does not verify that the resulting path refers to an existing file.<br />
|-<br />
| function '''WideExtractRelativePath'''(const BaseName, DestName: WideString): WideString; <br />
| Creates a relative path to go from '''BaseName''' to '''DestName'''. For example:<br />
<br />
{|<br />
| '''BaseName:'''<br />
| <nowiki>C:\Folder\FileName.txt</nowiki><br />
|-<br />
| '''DestName:'''<br />
| <nowiki>C:\Documents\Article.pdf</nowiki><br />
|-<br />
| '''Result:'''<br />
| <nowiki>..\Documents\Article.pdf</nowiki><br />
|}<br />
<br />
|-<br />
| function '''WideExtractShortPathName'''(const FileName: WideString): WideString; <br />
| It converts a path into it's representation in DOS format.<br />
|-<br />
| function '''WideIncludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a folder '''contains''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideExcludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a file does '''not contain''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideSameFileName'''(const FileName1, FileName2: WideString): Boolean;<br />
| Compares the filenames '''FileName1''' and '''FileName2''', and returns ''TRUE'' if they are considered to be same.<br />
<br />
Note that filenames on Windows platform are case insensitive for comparison purposes, but case preserving when creating new files.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMask'''(const FileName, Mask: WideString): Boolean;<br />
| Check if '''FileName''' matches a [[ReNamer:Masks|wildcard mask]] '''Mask'''. Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask <code>*.txt</code> matches files with a <code>.txt</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMaskList'''(const FileName, MaskList: WideString): Boolean;<br />
| Check if '''FileName''' matches any of the [[ReNamer:Masks|wildcard masks]] listed in '''MaskList'''. The list of masks is separated by semicolons (";"). Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask list <code>*.txt;*.doc</code> matches files with a <code>.txt</code> or <code>.doc</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Read/Write ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileReadFragment'''(const FileName: WideString; Start, Length: Integer): String; <br />
| Starting at position '''Start''', read '''Length''' number of characters of the file '''FileName''' and return them as a string. '''Start''' is 0-based, so in order to start the fragment at the beginning of the file, set this parameter to 0 (zero).<br />
|-<br />
| function '''FileReadLines'''(const FileName: WideString): TAnsiStringArray;<br />
| Read all lines from a file '''FileName'''.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''FileReadLine'''(const FileName: WideString; LineNum: Integer): String; <br />
| Read a line from a file '''FileName''' specified by a line index '''LineNum'''. '''LineNum''' is 1 based, so to get the first line set this parameter to 1 (one).<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileCountLines'''(const FileName: WideString): Integer; <br />
| Count number of lines in the file.<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileReadContent'''(const FileName: WideString): String; <br />
| Return the entire content of the file as a String.<br />
|-<br />
| procedure '''FileWriteContent'''(const FileName: WideString; const Content: String); <br />
| Write '''Content''' to the file. If target file already exists, it will be overwritten.<br />
|-<br />
| procedure '''FileAppendContent'''(const FileName: WideString; const Content: String); <br />
| Append '''Content''' to the end of the file. If target file does not exist, it will be created.<br />
|-<br />
| function '''FileReadText'''(const FileName: WideString): WideString;<br />
| Read text from a file, performing automatic text encoding handling.<br/>''Added in v6.6.0.6 Beta.''<br />
|-<br />
| function '''FileReadTextLines'''(const FileName: WideString): TWideStringArray;<br />
| Read lines of text from a file, performing automatic text encoding handling.<br/>''Added in v6.7.0.1 Beta.''<br />
|}<br />
<br />
Note: Automatic text encoding handling is based on [https://en.wikipedia.org/wiki/Byte_order_mark byte order mark] (BOM) and supports UTF-8, UTF-16BE and UTF-16LE. If no BOM found then text is interpreted as ANSI encoding.<br />
<br />
{{Top}}<br />
<br />
== File Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileTimeModified'''(const FileName: WideString): TDateTime; <br />
| Returns last modified time of the specified file.<br />
|-<br />
| function '''FileTimeCreated'''(const FileName: WideString): TDateTime; <br />
| Returns creation time of the specified file.<br />
|-<br />
| function '''SetFileTimeCreated'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets creation time for the specified file.<br />
|-<br />
| function '''SetFileTimeModified'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets last modified time for the specified file.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Meta Tags Extraction ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''CalculateMetaTag'''(const FilePath: WideString; const MetaTagName: String): WideString; <br />
| Extracts and returns the value of a meta tag specified by '''MetaTagName''' from the file specified by the complete absolute path '''FilePath'''.<br/>''Return type changed from String to WideString in v5.74.4 Beta.''<br />
|-<br />
| function '''CalculateMetaTagFormat'''(const FilePath: WideString; const MetaTagName, DateTimeFormat: String): WideString;<br />
| Same as '''CalculateMetaTag''' except an additional parameter '''DateTimeFormat''' is provided to specify custom Date/Time format to be used instead of the application's default setting.<br/>''Added in v5.74.4 Beta.''<br />
|}<br />
<br />
For example, to extract '''EXIF_Date''' tag from an image and set it to the filename using the default date/time formatting:<br />
<syntaxhighlight lang="pascal"><br />
begin<br />
FileName := CalculateMetaTag(FilePath, 'EXIF_Date');<br />
end.<br />
</syntaxhighlight><br />
<br />
The full list of meta tags can be found in [[ReNamer:Meta Tags|Meta Tags]] article. For help with date/time formatting refer to [[ReNamer:Date and Time format|Date and Time format]].<br />
<br />
{{Top}}<br />
<br />
== Regular Expressions ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsMatchingRegEx'''(const Input, Pattern: WideString; const CaseSensitive: Boolean): Boolean;<br />
| Check for a match against a RegEx pattern.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''ReplaceRegEx'''(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString; <br />
| Find and replace all RegEx pattern matches. Works like the [[ReNamer:Rules:RegEx|Regular Expressions rule]].<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''Replace''' - The replacement pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''UseSubstitution''' - Substitute [[ReNamer:Regular Expressions#Backreferences|backreferences]] in the replacement pattern.<br />
|-<br />
| function '''FindRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean; out Positions: TIntegerArray; out Matches: TWideStringArray): Integer;<br />
| Find matches and positions of a RegEx pattern. Returns the number of matches.<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''Positions''' - Receives a list of positions where the matches have been found.<br />
* '''Matches''' - Receives a list of matches.<br />
<br />
''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''MatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| Returns a list of RegEx matches as an array. Function returns an array of full matches, which matched the entire expression, not the sub-patterns.<br />
|-<br />
| function '''SubMatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| This function is very similar to '''MatchesRegEx''', but instead of returning full matches it will return an array of sub-expression matches for the '''first''' full match.<br />
<br />
In this way, it can easily be combined with '''MatchesRegEx''' function, to allow users to find all global matches, and then parse those matches through '''SubMatchesRegEx''' function to find individual sub-expression matches of each global match.<br />
|}<br />
<br />
Example input and matches for '''MatchesRegEx''' and '''SubMatchesRegEx''' functions:<br />
<br />
{| class="wikitable"<br />
|-<br />
! Input <br />
! Find<br />
! MatchesRegEx matches<br />
! SubMatchesRegEx matches<br />
|-<br />
| A1_B2_C3 <br />
| [A-Z]\d<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| ''(empty)''<br />
|-<br />
| A1_B2_C3 <br />
| ([A-Z])(\d)<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| <br />
* A<br />
* 1<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Process Execution ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''ShellOpenFile'''(const FileName: WideString): Boolean; <br />
| Run (open) a file specified by '''FileName'''. Works like "Start &gt; Run" command. Parameter does not have to be an executable file, it can by any file or protocol with assigned handler. For example, you can open a Word document or a web page, and associated application will be launched:<br />
* <tt><nowiki>ShellOpenFile('http://www.den4b.com/');</nowiki></tt><br />
* <tt><nowiki>ShellOpenFile('C:\Document.doc');</nowiki></tt><br />
<br />
'''Beware:''' This function will evaluate the command for the appropriate way of execution which may sometimes lead to unexpected results. For example when executing ''ShellOpenFile('notepad')'' it could actually run a ''Windows Notepad'' application normally located in "''C:\Windows\notepad.exe''", or some other "''notepad.exe''" file located on the search path (''%PATH%''), or even open "''notepad''" folder located in the current working directory.<br />
|-<br />
| function '''ExecuteProgram'''(const Command: String; WaitForProgram: Boolean): Cardinal; <br />
| Execute a command specified by '''Command''' parameter. Parameter '''WaitForProgram''' allows you to specify whether the code needs to wait until the command (launched program) has finished executing.<br />
|-<br />
| function '''ExecuteProgramShow'''(const Command: String; WaitForProgram: Boolean; ShowWindowFlag: Word): Cardinal;<br />
| Execute a command specified by '''Command''' parameter. '''WaitForProgram''' parameter allows you to specify whether the code needs to wait until the command (launched program) has finished executing. '''ShowWindowFlag''' parameter controls how the window is to be shown.<br />
<br />
Commonly used values for '''ShowWindowFlag''' parameter: <br />
* 0 = Hide the window.<br />
* 1 = Activate and display the window.<br />
* 2 = Activate the window and display it minimized.<br />
* 3 = Activate the window and display it maximized.<br />
* 4 = Display the window, but do not activate it.<br />
* 7 = Display the window minimized, but do not activate it.<br />
* More information: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx ShowWindow Windows API function].<br />
<br />
''Added in v5.75.3 Beta.''<br />
|-<br />
| function '''ExecConsoleApp'''(const CommandLine: String; out Output: String): Cardinal; <br />
| Execute a command line specified by '''CommandLine''' parameter and capture its standard output in the '''Output''' variable. This function should be used only for console style applications. Returns the exit code.<br />
<br />
Console application output uses OEM-defined character set by default, unless application itself changes its output code page. '''OemToAnsi''' and '''OemToWide''' functions can be used to convert OEM output.<br />
<br />
Prior to ''v6.6.0.2 Beta'', OEM to ANSI conversion was automatically applied to the console output. As of ''v6.6.0.2 Beta'', the console output is returned "as is" without any modifications, so to prevent corruption of binary or non-OEM encoded output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Dialogs ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''ShowMessage'''(const Msg: String); <br />
| Show a simple dialog with the message specified by '''Msg''' parameter.<br />
|-<br />
| procedure '''WideShowMessage'''(const Msg: WideString); <br />
| Same as '''ShowMessage''' function but parameter is Unicode text.<br />
|-<br />
| function '''DialogYesNo'''(const Msg: String): Boolean; <br />
| Show a simple prompt with the message specified by '''Msg''' parameter and two button: Yes and No. Returns TRUE if user clicks Yes button, otherwise FALSE.<br />
|-<br />
| function '''WideDialogYesNo'''(const Msg: WideString): Boolean; <br />
| Same as '''DialogYesNo''' function but parameter is WideString text.<br />
|-<br />
| function '''InputBox'''(const ACaption, APrompt, ADefault: String): String; <br />
| Displays a simple dialog box with the given '''ACaption''' and '''APrompt''' message. It asks the user to enter data in a text box on the dialog. A '''ADefault''' value is displayed in the text box initially. If the user presses OK, the value from the text box is returned, otherwise '''ADefault''' value is returned.<br />
|-<br />
| function '''InputQuery'''(const ACaption, APrompt: String; var Value: String): Boolean; <br />
| Operates similar to '''InputBox''' function. The default value and the value of the text box after the dialog is closed are transferred via the '''Value''' parameter. Function returns TRUE is user clicked OK, otherwise returns FALSE.<br />
|-<br />
| function '''WideInputBox'''(const ACaption, APrompt, ADefault: WideString): WideString; <br />
| Same as '''InputBox''' function but operates on WideString text.<br />
|-<br />
| function '''WideInputQuery'''(const ACaption, APrompt: WideString; var Value: WideString): Boolean; <br />
| Same as '''InputQuery''' function but operates on WideString text.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Application ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''GetApplicationPath''': WideString;<br />
| Return full path to the application, for example: "C:\Program Files\ReNamer\ReNamer.exe".<br />
|-<br />
| function '''GetApplicationParams''': TWideStringArray;<br />
| Return an array of command line parameters which were supplied to the application at launch.<br />
|-<br />
| function '''GetCurrentFileIndex''': Integer;<br />
| Get index of the current file. Index ranges from '''1''' to '''GetTotalNumberOfFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfFiles''': Integer;<br />
| Get total number of files in the application.<br />
|-<br />
| function '''GetCurrentMarkedFileIndex''': Integer;<br />
| Get index of the current file, counting only ''marked'' files. Index ranges from '''1''' to '''GetTotalNumberOfMarkedFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfMarkedFiles''': Integer;<br />
| Get total number of ''marked'' files in the application.<br />
|-<br />
| function '''GetAllFiles''': TWideStringArray;<br />
| Get file paths of all available files. ''Added in v5.74.2 Beta.''<br />
|-<br />
| function '''GetMarkedFiles''': TWideStringArray;<br />
| Get file paths of all marked files. ''Added in v5.74.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Global Variables ==<br />
<br />
Global variables allow for efficient storage and exchange of information between scripts.<br />
<br />
Variables do not get cleared automatically, so they exist until cleared manually or until the application terminates. If you wish to clear variables at each Preview, a good mechanism to do that is via the [[ReNamer:Pascal_Script:Initialization_of_variables|script initialization]].<br />
<br />
''Added in v7.4.0.2 Beta.''<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''SetGlobalVar'''(const Name: String; Value: Variant);<br />
| Set a global variable.<br />
|-<br />
| function '''GetGlobalVar'''(const Name: String): Variant;<br />
| Get a global variable. If variable does not exist, the function returns an ''Unassigned'' value.<br />
|-<br />
| function '''GetGlobalVarDef'''(const Name: String; Default: Variant): Variant;<br />
| Get a global variable. If variable does not exist, the function returns the ''Default'' value.<br />
|-<br />
| function '''HasGlobalVar'''(const Name: String): Boolean;<br />
| Check if a global variable exists.<br />
|-<br />
| function '''GetGlobalVarCount''': Integer;<br />
| Retrieve the total number of global variables.<br />
|-<br />
| function '''GetGlobalVarNames''': TAnsiStringArray;<br />
| Retrieve names of all global variables.<br />
|-<br />
| procedure '''ClearGlobalVar'''(const Name: String);<br />
| Clear a global variable.<br />
|-<br />
| procedure '''ClearGlobalVars''';<br />
| Clear all global variables.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== System ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideGetCurrentDir''': WideString; <br />
| Returns the current working directory.<br />
|-<br />
| function '''WideSetCurrentDir'''(const Dir: WideString): Boolean; <br />
| Sets the current working directory to the directory specified by parameter '''Dir'''.<br />
|-<br />
| function '''WideGetTempPath''': WideString;<br />
| Returns system defined temporary directory. If returned value is empty it means that temporary folder could not be determined.<br />
|-<br />
| function '''WideGetEnvironmentVar'''(const VarName: WideString): WideString; <br />
| Returns an environment variable by its name. For example:<br />
<syntaxhighlight lang="pascal"><br />
var<br />
UserName, ComputerName: WideString;<br />
begin<br />
UserName := WideGetEnvironmentVar('USERNAME');<br />
ComputerName := WideGetEnvironmentVar('COMPUTERNAME');<br />
end.<br />
</syntaxhighlight><br />
|}<br />
<br />
{{Top}}<br />
<br />
== Miscellaneous ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''Error'''(const Message: String);<br />
| Abruptly terminate the script with an error message.<br/>''Added in v7.2.0.7 Beta.''<br />
|-<br />
| procedure '''Sleep'''(Milliseconds: Cardinal); <br />
| Sleep (pause the execution) for specified number of '''Milliseconds'''.<br />
|-<br />
| procedure '''DivMod'''(Dividend: Integer; Divisor: Word; var Result, Remainder: Word); <br />
| Perform integer division and fetch the remainder as well, all in one operation. '''Dividend''' is the integer into which you are dividing. '''Divisor''' is the value by which to divide '''Dividend'''. '''Result''' returns the result of the integer division. '''Remainder''' returns the remainder (the difference between Result * Divisor and Dividend).<br />
|-<br />
| procedure '''Randomize'''; <br />
| Prepares the random number generator.<br />
'''Note:''' Should only be called once per application cycle, at the start of the process!<br />
|-<br />
| function '''RandomRange'''(const AFrom, ATo: Integer): Integer; <br />
| Return a random integer number within the specified range from '''AFrom''' (inclusive) to '''ATo''' (non-inclusive).<br />
|-<br />
| function '''RandomFloat''': Extended;<br />
| Return a random floating point value between 0.0 (including) and 1.0 (excluding).<br/>''Added in v6.2.0.8 Beta.''<br />
|- <br />
| function '''RandomBoolean''': Boolean;<br />
| Return a random boolean value, either ''True'' or ''False''.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''RandomString'''(Len: Integer; const Chars: String): String;<br />
| Generate a random string of length '''Len''' using characters selected at random from a string '''Chars'''.<br/>''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''MinInt'''(const A, B: Integer): Integer;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinInt64'''(const A, B: Int64): Int64;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinFloat'''(const A, B: Extended): Extended;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt'''(const A, B: Integer): Integer;<br />
| Return the largest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt64'''(const A, B: Int64): Int64;<br />
| Return the largest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxFloat'''(const A, B: Extended): Extended;<br />
| Return the largest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''GetClipboardText''': WideString; <br />
| Get the content of the the clipboard (text only).<br />
|-<br />
| procedure '''SetClipboardText'''(const S: WideString); <br />
| Set the content of the the clipboard (text only).<br />
|-<br />
| function '''Base64Encode'''(const S: String): String; <br />
| Encode string '''S''' into [http://en.wikipedia.org/wiki/Base64 Base64]. Useful for encoding binary data in order to minimize the likelihood of data being modified in transit through different systems, like email or internet.<br />
|-<br />
| function '''Base64Decode'''(const S: String): String; <br />
| Decode [http://en.wikipedia.org/wiki/Base64 Base64] encoded string.<br />
|-<br />
| function '''URLDecode'''(const Str: String; UsePlusAsSpace: Boolean): WideString;<br />
| Decode URL encoded string. All occurrences of ''%XX'' hex format are decoded, then entire string is decoded from UTF8.<br />
<br />
Optionally, plus signs ("+") can be interpreted as white space by enabling '''UsePlusAsSpace''' parameter, for compatibility with some encoders such as in [http://php.net/manual/en/function.urlencode.php PHP].<br />
<br />
''Added in v5.74.4 Beta. UsePlusAsSpace parameter added in v6.7.0.1 Beta.''<br />
|-<br />
| function '''URLEncode'''(const Str: WideString; UsePlusAsSpace: Boolean): String;<br />
| Encode string using URL encoding. Input string is encoded with UTF8, then all characters except digits and Latin letters are encoded in ''%XX'' hex format.<br />
<br />
Optionally, white spaces can be encoded as plus signs ("+") by enabling '''UsePlusAsSpace''' parameter, for compatibility with some decoders such as in [http://php.net/manual/en/function.urldecode.php PHP].<br />
<br />
''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''GetTickCount''': Cardinal; <br />
| Retrieves the number of milliseconds that have elapsed since the system was started (up to 49.7 days, then timer resets). The precision of this timer is very limited.<br />
|-<br />
| function '''SizeOf'''(X): Integer; <br />
| Pass a variable reference to determine the number of bytes used to represent the variable. Pass a type identifier to determine the number of bytes used to represent instances of that type.<br />
|}<br />
<br />
{{Top}}<br />
<br />
[[Category:ReNamer]]<br />
[[Category:Pascal Script]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script:Types&diff=3506ReNamer:Pascal Script:Types2022-12-23T10:41:35Z<p>Den4b: /* String types */ Default encoding and type conversions</p>
<hr />
<div>{{Go|up=ReNamer:Pascal Script|next=ReNamer:Pascal Script:Functions}}<br />
<br />
This page lists and explains all supported types in [[ReNamer:Pascal Script|Pascal Script]] used within ReNamer.<br />
<br />
== Integer types ==<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Size<br />
! Lowest Value<br />
! Highest Value<br />
|-<br />
| '''Byte'''<br />
| 1 byte<br />
| align="center" | 0<br />
| align="center" | 255<br />
|-<br />
| '''ShortInt'''<br />
| 1 byte<br />
| align="center" | -128<br />
| align="center" | 127<br />
|-<br />
| '''Word'''<br />
| 2 bytes<br />
| align="center" | 0<br />
| align="center" | 65,535<br />
|-<br />
| '''SmallInt'''<br />
| 2 bytes<br />
| align="center" | -32,768<br />
| align="center" | 32,767<br />
|-<br />
| '''Cardinal'''<br />
| 4 bytes<br />
| align="center" | 0<br />
| align="center" | 4,294,967,295<br />
|-<br />
| '''Integer'''<br />
| 4 bytes<br />
| align="center" | -2,147,483,648<br />
| align="center" | 2,147,483,647<br />
|-<br />
| '''Int64'''<br />
| 8 bytes<br />
| align="center" | -9,223,372,036,854,775,808<br />
| align="center" | 9,223,372,036,854,775,807<br />
|}<br />
<br />
== Floating point types ==<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Size<br />
! Range<br />
|-<br />
| '''Single'''<br />
| 4 bytes<br />
| align="center" | 1.5 x 10<sup>-45</sup> .. 3.4 x 10<sup>38</sup><br />
|-<br />
| '''Double'''<br />
| 8 bytes<br />
| align="center" | 5.0 x 10<sup>-324</sup> .. 1.7 x 10<sup>308</sup><br />
|-<br />
| '''Extended'''<br />
| 10 bytes<br />
| align="center" | 3.6 x 10<sup>-4951</sup> .. 1.1 x 10<sup>4932</sup><br />
|}<br />
<br />
== String types ==<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| '''Char'''<br />
| Stores a single 8-bit character.<br />
|-<br />
| '''String'''<br />
| Holds a sequence of 8-bit characters. Commonly used for ANSI or UTF-8 encoded text.<br />
|-<br />
| '''AnsiChar'''<br />
| Alias for ''Char'' type.<br />
|-<br />
| '''AnsiString'''<br />
| Alias for ''String'' type.<br />
|-<br />
| '''WideChar'''<br />
| Stores a single 16-bit character.<br />
|-<br />
| '''WideString'''<br />
| Holds a sequence of 16-bit characters. Commonly used for UCS-2 or UTF-16 encoded text.<br />
|-<br />
| '''UnicodeChar'''<br />
| Alias for ''WideChar'' type.<br />
|-<br />
| '''UnicodeString'''<br />
| Alias for ''WideString'' type.<br />
|}<br />
<br />
The default encoding for String/AnsiString type and the conversion process to/from UnicodeString/WideString type differ between versions of ReNamer.<br />
<br />
{| class="wikitable"<br />
! ReNamer version<br />
! Default encoding for AnsiString type<br />
! Conversion between WideString and AnsiString types <br />
|-<br />
| 7.0 and later<br />
| UTF8<br />
| Automatic, on assignment<br />
|-<br />
| Prior to 7.0<br />
| Active [https://en.wikipedia.org/wiki/Windows_code_page system code page]<br />
| Manual, using conversion functions<br />
|}<br />
<br />
The [[Unicode]] article highlights the differences between various encodings.<br />
<br />
== Mixed types ==<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| '''Boolean'''<br />
| Provides an enumeration of the logical '''True''' and '''False''' values.<br />
|-<br />
| '''Array'''<br />
| Single and multi dimensional indexable sequences of data.<br />
|-<br />
| '''Record'''<br />
| Provides means of collecting together a set of different data types into one named structure.<br />
|-<br />
| '''Variant'''<br />
| Provides a flexible general purpose data type.<br />
|-<br />
| '''PChar'''<br />
| Pointer to a ''Char'' value, and can also be used to point to characters within a string.<br />
|}<br />
<br />
== Extra types ==<br />
<br />
Several extra types have been defined to simplify the use of some functions.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Declared as<br />
! Description<br />
|-<br />
| '''TDateTime'''<br />
| Double<br />
| Represents a date and time.<br />
|-<br />
| <strike>'''TStringsArray'''</strike><br />
| Array of WideString<br />
| Indexed list of ''WideString'' values.<br/>''Deprecated in v5.74.4 Beta. Please use TWideStringArray instead.''<br />
|-<br />
| '''TWideStringArray'''<br />
| Array of WideString<br />
| Indexed list of ''WideString'' values.<br/>''Added in v5.74.4 Beta. Replaces ambiguous TStringsArray type.''<br />
|-<br />
| '''TAnsiStringArray'''<br />
| Array of AnsiString<br />
| Indexed list of ''AnsiString'' values.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| '''TIntegerArray'''<br />
| Array of Integer<br />
| Indexed list of ''Integer'' values.<br/>''Added in v7.3.0.4 Beta.''<br />
|}<br />
<br />
== Enumerations and Sets ==<br />
<br />
An enumeration is simply a fixed range of named values.<br />
<br />
For example, the fundamental ''Boolean'' data type can be considered as an enumeration consisting of two values: ''True'' and ''False''.<br />
<br />
A variable of an enumeration type can be assigned a single value from the enumeration.<br />
<br />
<pre><br />
type<br />
TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);<br />
var<br />
Day: TDay;<br />
begin<br />
Day := Mon;<br />
if Day <> Tue then<br />
Day := Wed;<br />
end.<br />
</pre><br />
<br />
Sets allow you to defined variables which can hold multiple values out of the enumeration.<br />
<br />
<pre><br />
type<br />
TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);<br />
TDays = set of TDay;<br />
var<br />
Days: TDays;<br />
begin<br />
Days := [Mon, Tue, Wed];<br />
if Sun in Days then<br />
Days := Days - [Sun];<br />
end.<br />
</pre><br />
<br />
<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script:Functions&diff=3505ReNamer:Pascal Script:Functions2022-12-15T00:02:45Z<p>Den4b: /* Global Variables */ Clearing of variables</p>
<hr />
<div>{{Go|up=ReNamer:Pascal Script|prev=ReNamer:Pascal Script:Types}}<br />
<br />
ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file, strings entered by the user, etc. This functionality is available for use via the [[ReNamer:Rules:PascalScript|PascalScript rule]].<br />
<br />
The difference between a "function" and a "procedure" is that while a function executes an algorithm and returns a value, a procedure just executes an algorithm without returning anything.<br />
<br />
A common "Wide" prefix in function names indicates that the function deals with '''WideString''' type rather than '''AnsiString''' or '''String''' type. For example, ''ShowMessage'' and ''WideShowMessage'' procedures. See the [[ReNamer:Pascal_Script:Types#String_types|String Types]] for more information.<br />
<br />
== Basic String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''Insert'''(Source: String; var S: String; Index: Integer); <br />
| Inserts the string '''S''' into string '''Source''' at position '''Index'''.<br />
|-<br />
| procedure '''Delete'''(var S: String; Index, Count: Integer); <br />
| Deletes '''Count''' characters from the string '''S''', starting from position '''Index'''.<br />
|-<br />
| function '''Copy'''(S: String; Index, Count: Integer): String; <br />
| Copies '''Count''' characters from string '''S''', starting at position '''Index''', and returns them as a new string.<br />
|-<br />
| function '''Pos'''(Substr: String; S: String): Integer; <br />
| Returns the position of a string '''Substr''' in another string '''S'''.<br />
|}<br />
<br />
'''Note:''' Indexes of characters in strings are 1 based, so first character in string S would be S[1].<br />
<br />
{{Top}}<br />
<br />
== Length Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''SetLength'''(var S: Array; NewLength: Integer); <br />
| Sets the length of array variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: String; NewLength: Integer); <br />
| Sets the length of string variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: WideString; NewLength: Integer); <br />
| Sets the length of widestring '''S''' to '''NewLength'''.<br />
|-<br />
| function '''Length'''(const S: Array): Integer; <br />
| Returns the length of array '''S ''' (number of elements).<br />
|-<br />
| function '''Length'''(const S: String): Integer; <br />
| Returns the length of string '''S''' (number of characters).<br />
|-<br />
| function '''Length'''(const S: WideString): Integer;<br />
| Returns the length of WideString '''S''' (number of characters).<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''WideInsert'''(const Substr: WideString; var Dest: WideString; Index: Integer); <br />
| Inserts '''Substr''' in '''Dest''' at position '''Index'''.<br />
|-<br />
| procedure '''WideDelete'''(var S: WideString; Index, Count: Integer); <br />
| Deletes '''Count''' characters from '''S''', starting from the '''Index''' position.<br />
|-<br />
| procedure '''WideDeleteRight'''(var S: WideString; Index, Count: Integer);<br />
| Delete '''Count''' characters from '''S''', starting from the '''Index''' position from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| procedure '''WideSetLength'''(var S: WideString; NewLength: Integer); <br />
| Change the length of string '''S''' to a new length specified by '''NewLength'''. If new length is smaller than original, the string is truncated. If new length is greater than original, the string will be expanded but additional characters will not be initialized and can be anything.<br />
|-<br />
| function '''WideLength'''(const S: WideString): Integer; <br />
| Returns the length of WideString '''S'''.<br />
|-<br />
| function '''WideCopy'''(const S: WideString; Index, Count: Integer): WideString; <br />
| Returns '''Count''' characters from '''S''', starting at position '''Index'''.<br />
|-<br />
| function '''WideCopyRight'''(const S: WideString; Index, Count: Integer): WideString;<br />
| Returns '''Count''' characters from '''S''', starting at position '''Index''' from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WidePos'''(const SubStr, S: WideString): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WidePosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S''' but start searching from position specified by '''Offset'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WideUpperCase'''(const S: WideString): WideString; <br />
| Returns the ALLCAPS version of the WideString '''S'''<br />
|-<br />
| function '''WideLowerCase'''(const S: WideString): WideString; <br />
| Returns the lowercase version of the WideString '''S'''<br />
|-<br />
| function '''WideCompareStr'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-sensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideCompareText'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideSameText'''(const S1, S2: WideString): Boolean; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive. Returns TRUE if both are identical, otherwise returns FALSE.<br />
|-<br />
| function '''WideTextPos'''(const SubStr, S: WideString): Integer; <br />
| Behaves like '''WidePos''' function, except text if processed in case-insensitive manner.<br />
|-<br />
| function '''WideTextPosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer;<br />
| Behaves like '''WidePosEx''' function, except text if processed in case-insensitive manner.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideTrim'''(const S: WideString): WideString; <br />
| Removes leading and trailing spaces and control characters from the given string '''S'''.<br />
|-<br />
| function '''WideTrimChars'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning and the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsLeft'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsRight'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideReverseString'''(const S: WideString): WideString;<br />
| Return a reversed version of string '''S''', i.e. reverse the order of characters.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideRepeatString'''(const S: WideString; Count: Integer): WideString;<br />
| Repeat a string a number of times.<br/>''Added in v6.9.0.3 Beta.''<br />
<br />
|-<br />
| function '''WideReplaceStr'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-sensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
<br />
|-<br />
| function '''WideReplaceText'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-insensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
|-<br />
| function '''WideSplitString'''(const Input, Delimiter: WideString): TWideStringArray; <br />
| <br />
Splits the '''Input''' wherever '''Delimiter''' occurs and returns an array that contains the split parts. <br />
<br />
*The '''Delimiter''' itself can be a multi-character WideString. <br>(Unlike the usual comma, hyphen or space that are used for this purpose) <br />
*The split parts (returned as elements of the array) do not contain the '''Delimiter'''.<br />
<br />
|-<br />
|-<br />
| function '''WideJoinStrings'''(const Strings: TWideStringArray; const Delimiter: WideString): WideString;<br />
| Joins all individual items from '''Strings''' into a single WideString, with '''Delimiter''' inserted between the joined items.<br />
<br />
|-<br />
| function '''WideCaseSentence'''(const S: WideString): WideString; <br />
| Returns a ''Sentence case'' version of parameter '''S'''. <br />
<br />
Only the first alphabetic character is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
''Added in v6.0.0.3 Alpha''.<br />
|-<br />
| function '''WideCaseCapitalize'''(const S: WideString): WideString; <br />
| <br />
Returns the ''Title case'' version of parameter '''S'''. <br />
<br />
First letter of every word is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
|-<br />
| function '''WideCaseInvert'''(const S: WideString): WideString; <br />
| Inverts case of all characters in '''S''' and returns it.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide Character Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsWideCharUpper'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in upper case.<br />
|-<br />
| function '''IsWideCharLower'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in lower case.<br />
|-<br />
| function '''IsWideCharDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a digit (numeric character 0-9). <br />
|-<br />
| function '''IsWideCharSpace'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a white-space character, such as: space, form-feed, newline, carriage-return, tab and vertical-tab (characters classified as C1_SPACE).<br />
|-<br />
| function '''IsWideCharPunct'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a punctuation mark (characters classified as C1_PUNCT).<br />
|-<br />
| function '''IsWideCharCntrl'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a control character (characters classified as C1_CNTRL).<br />
|-<br />
| function '''IsWideCharBlank'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a blank, such as: space and tab (characters classified as C1_BLANK).<br />
|-<br />
| function '''IsWideCharXDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a hexadecimal digit (0-9 or A-F).<br />
|-<br />
| function '''IsWideCharAlpha'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character (a-z or A-Z).<br />
|-<br />
| function '''IsWideCharAlphaNumeric'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character or a numeric character (a-z, A-Z or 0-9).<br />
|-<br />
| function '''IsWideWordBoundaryLeft'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the left.<br />
<br />
Conditions that qualify as word boundaries to the left of character:<br />
# If first character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.'' <br />
|-<br />
| function '''IsWideWordBoundaryRight'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the right.<br />
<br />
Conditions that qualify as word boundaries to the right of character:<br />
# If last character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideCharUpper'''(const WC: WideChar): WideChar; <br />
| Returns an upper case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideCharLower'''(const WC: WideChar): WideChar; <br />
| Returns a lower case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideChr'''(Code: Word): WideChar;<br />
| Create a character from a code point.<br/>''Added in v6.9.0.3 Beta.''<br />
|}<br />
<br />
'''Note:''' Character classifications, such as C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT, C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA - are part of Unicode definitions. More information regarding classification can be found on the internet. For example: [http://www.fileformat.info/info/unicode/ http://www.fileformat.info/info/unicode/].<br />
<br />
{{Top}}<br />
<br />
== Unicode Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideToAnsi'''(const WS: WideString): String; <br />
| Converts [[Unicode]] string to [[ANSI]] string, according to the system locale.<br />
|-<br />
| function '''AnsiToWide'''(const S: String): WideString; <br />
| Converts [[ANSI]] string to [[Unicode]] string, according to the system locale.<br />
|-<br />
| function '''UTF8Encode'''(const WS: WideString): String; <br />
| Convert WideString type to UTF-8 encoded string.<br/>Useful for storing Unicode strings in files, sometimes for compatibility reasons and sometimes to reduce the size of the file.<br />
|-<br />
| function '''UTF8Decode'''(const S: String): WideString;<br />
| Convert UTF-8 encoded string to WideString type.<br />
|}<br />
<br />
== Console Output Conversion ==<br />
<br />
OEM-defined character set is commonly used in the output of console applications.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''OemToAnsi'''(const S: String): String;<br />
| Convert OEM string into an ANSI string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''OemToWide'''(const S: String): WideString;<br />
| Convert OEM string into a WideString.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''AnsiToOem'''(const S: String): String;<br />
| Convert ANSI string into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''WideToOem'''(const S: WideString): String; <br />
| Convert WideString into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Basic Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''BoolToStr'''(B: Boolean): String;<br />
| Convert boolean variable into a string. Returns "''True''" or "''False''" string value.<br />
|-<br />
| function '''IntToStr'''(Value: Integer): String; <br />
| Converts an integer to a string. The following assumptions are correct:<br />
<div style="font-family: monospace"><br />
* IntToStr(123) = '123'<br />
* IntToStr(0123) = '123'<br />
* IntToStr(123) <> '0123'<br />
</div><br />
<b>Note:</b> Be cautious of supplying ''Int64'' type as a parameter as it will be type casted to ''Integer'', which significantly reduces the range of possible values (refer to [[ReNamer:Pascal Script:Types|Types]] for more information). You can use '''FormatFloat''' function to convert ''Int64'' values to a string without a loss of range.<br />
|-<br />
| function '''Int64ToStr'''(Value: Int64): String;<br />
| Same as '''IntToStr''' but takes in ''Int64'' typed parameter.<br />
|-<br />
| function '''StrToInt'''(const S: String): Integer; <br />
| Converts a string to an integer. The following equalities are correct:<br />
<div style="font-family: monospace"><br />
* StrToInt('123') = 123<br />
* StrToInt('123') = 0123<br />
* StrToInt('0123') = 123<br />
</div><br />
'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''StrToInt64'''(const S: String): Int64;<br />
| Same as '''StrToInt''' but returns ''Int64'' typed result.<br />
|-<br />
| function '''StrToIntDef'''(const S: String; const Default: Integer): Integer; <br />
| Behaves like '''StrToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''StrToInt64Def'''(const S: String; Default: Int64): Int64;<br />
| Same as '''StrToIntDef''' but operates with ''Int64'' type.<br />
|-<br />
| function '''TryStrToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Converts a string to an integer, but does not throw an error when invalid string is supplied, unlike '''StrToInt'''. Returns ''False'' if conversion operation has failed.<br />
|-<br />
| function '''FloatToStr'''(Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using default system format.<br />
|-<br />
| function '''StrToFloat'''(const S: string): Extended;<br />
| Converts supplied string to a floating point value.<br>'''Warning:''' An error will occur if the parameter to this function cannot be converted to a floating point value!<br />
|-<br />
| function '''StrToFloatDef'''(const S: string; const Default: Extended): Extended;<br />
| Behaves like '''StrToFloat''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to a floating point value.<br />
|-<br />
| function '''FormatFloat'''(const Format: string; Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using user specific '''Format'''.<br/>Check [[#Floating point format specifiers|floating point format specifiers]] below for more information.<br />
|-<br />
| function '''DateToStr'''(D: TDateTime): String; <br />
| Converts a date to a string, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''StrToDate'''(const S: String): TDateTime; <br />
| Converts a date string to a proper TDateTime value, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''IntToHex'''(Value: Integer; Digits: Integer): String; <br />
| Converts an integer to its hexadecimal representation. Here are samples:<br />
<div style="font-family: monospace"><br />
* IntToHex(1234, 1) = '4D2'<br />
* IntToHex(1234, 8) = '000004D2'<br />
</div><br />
|-<br />
| function '''HexToInt'''(const HexNum: String): Integer; <br />
| Converts a hexadecimal value to its decimal representation.<br/>'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''HexToIntDef'''(const HexNum: String; Default: Integer): Integer; <br />
| Behaves like '''HexToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''IntToRoman'''(Value: Integer): String;<br />
| Convert a decimal number to Roman numerals.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToInt'''(const S: String): Integer;<br />
| Convert Roman numerals to a decimal number.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToIntDef'''(const S: String; Default: Integer): Integer;<br />
| Convert Roman numerals to a decimal number. Returns the '''Default''' value in the conversion fails.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''TryRomanToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Try to convert Roman numerals to a decimal number. Does not throw an error on failure, instead it returns ''False''.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''Ord'''(X: Char): Byte; <br />
| Return an ordinal value (byte representation) of a character.<br />
|-<br />
| function '''Chr'''(X: Byte): Char; <br />
| Return a character by its ordinal value (byte representation).<br />
|}<br />
<br />
=== Floating point format specifiers ===<br />
<br />
{| class="wikitable"<br />
! Specifier<br />
! Represents<br />
|-<br />
| <tt>0</tt>&nbsp;(zero)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "0" appears in the format string, then that digit is copied to the output string. Otherwise, a "0" is stored in that position in the output string.<br />
|-<br />
| <tt>#</tt>&nbsp;(hash)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "#" appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string.<br />
|-<br />
| <tt>.</tt>&nbsp;(dot)<br />
| Decimal point. The first "." character in the format string determines the location of the decimal separator in the formatted value, any additional "." characters are ignored.<br />
|-<br />
| <tt>,</tt>&nbsp;(comma)<br />
| Thousand separator. If the format string contains one or more "," characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of "," characters in the format string does not affect the output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Date and Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''Date''': TDateTime; <br />
| Returns the current system date.<br />
|-<br />
| function '''Time''': TDateTime; <br />
| Returns the current system time.<br />
|-<br />
| function '''Now''': TDateTime; <br />
| Returns the current system date and time.<br />
|-<br />
| function '''EncodeDate'''(Year, Month, Day: Word): TDateTime; <br />
| Generates date value for the specified '''Year''', '''Month''', '''Day'''. Parameters must be within a valid date range: Year = 0..9999, Month = 1..12, Day = 1..31 (depending on month/year). An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeTime'''(Hour, Min, Sec, MSec: Word): TDateTime; <br />
| Generates time value for the specified '''Hour''', '''Min''', '''Sec''', '''MSec'''. Parameters must be within a valid time range: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word): TDateTime;<br />
| Generates date-time value for the specified components of date and time. Similar to '''EncodeDate''' and '''EncodeTime'''.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''TryEncodeDate'''(Year, Month, Day: Word; var Date: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeDate''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date value will be written in the '''Date''' variable.<br />
|-<br />
| function '''TryEncodeTime'''(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated time value will be written in the '''Time''' variable.<br />
|-<br />
| function '''TryEncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''EncodeDateTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date-time value will be written in the '''ADateTime''' variable.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| procedure '''DecodeDate'''(const DateTime: TDateTime; var Year, Month, Day: Word); <br />
| Extracts '''Year''', '''Month''' and '''Day''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeTime'''(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word); <br />
| Extracts '''Hour''', '''Min''', '''Sec''' and '''MSec''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeDateTime'''(const DateTime: TDateTime; out Year, Month, Day, Hour, Minute, Second, MilliSecond: Word);<br />
| Similar to '''DecodeDate''' and '''DecodeTime''' but extracts both date and time components at once.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''ComposeDateTime'''(const Date, Time: TDateTime): TDateTime;<br />
| Combine date and time components into a single date-time value.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DateTimeToUnix'''(D: TDateTime): Int64;<br />
| Converts '''D''' value of type '''TDateTime''' to a Unix timestamp.<br />
|-<br />
| function '''UnixToDateTime'''(U: Int64): TDateTime; <br />
| Converts a Unix timestamp to a value of '''TDateTime''' type.<br />
|-<br />
| function '''FormatDateTime'''(const Format: String; DateTime: TDateTime): String;<br />
| Convert date and time value to a string using [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Format''' parameter. <br />
|-<br />
| function '''ScanDateTime'''(const Pattern, Subject: String): TDateTime;<br />
| Convert '''Subject''' string to a date and time value by parsing it according to the [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Pattern''' parameter.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''TryScanDateTime'''(const Pattern, Subject: String; out DateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''ScanDateTime''' function, except it suppresses errors and returns either ''TRUE'' or ''FALSE'' depending on the success of the operation.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''IncYear'''(const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of years (plus or minus).<br />
|-<br />
| function '''IncMonth'''(const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of months (plus or minus).<br />
|-<br />
| function '''IncWeek'''(const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of weeks (plus or minus).<br />
|-<br />
| function '''IncDay'''(const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of days (plus or minus).<br />
|-<br />
| function '''IncHour'''(const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of hours (plus or minus).<br />
|-<br />
| function '''IncMinute'''(const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of minutes (plus or minus).<br />
|-<br />
| function '''IncSecond'''(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of seconds (plus or minus).<br />
|-<br />
| function '''IncMilliSecond'''(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of milliseconds (plus or minus).<br />
|-<br />
| function '''SecondSpan'''(const ANow, AThen: TDateTime): Double;<br />
| Calculate the approximate number of seconds between two date-time values.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DayOfWeek'''(const DateTime: TDateTime): Word; <br />
| Returns the day number of the week. Returned values: 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday.<br/>''Before v6.1 this function used to return 1=Sunday to 7=Saturday.''<br />
|-<br />
| function '''DayOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''DayOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the year.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the year.<br/>''Added in v6.1.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideFileSize'''(const FileName: WideString): Int64; <br />
| Returns the size of the file in bytes. If file does not exist "-1" is returned. The return value is of type ''Int64'' which can store the maximum file size of 9,223,372,036,854,775,807 bytes.<br />
|-<br />
| function '''WideFileExists'''(const FileName: WideString): Boolean; <br />
| Check whether specified file exists. Returns TRUE if file exists, otherwise FALSE.<br />
|-<br />
| function '''WideDirectoryExists'''(const Directory: WideString): Boolean; <br />
| Check whether specified directory exists. Returns TRUE if directory exists, otherwise FALSE.<br />
|-<br />
| function '''WideForceDirectories'''(const Dir: WideString): Boolean; <br />
| Makes sure that that all directories in the path exist. If they don't, function will try to create them, recursively. Returns TRUE if all folders exist or have been successfully created.<br />
|-<br />
| function '''WideCreateDir'''(const Dir: WideString): Boolean; <br />
| Create specified directory (non-recursive). Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideRemoveDir'''(const Dir: WideString): Boolean;<br />
| Remove a directory, if it is empty. Returns TRUE on success, otherwise FALSE.<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideDeleteFile'''(const FileName: WideString): Boolean; <br />
| Delete physical file from the disk. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideDeleteToRecycleBin'''(const FileName: WideString): Boolean;<br />
| Delete file or folder by placing it into the Recycle Bin. Returns TRUE on success, otherwise FALSE.<br />
<br />
'''Note:''' You must provide a full path to delete the file to the Recycle Bin (a quirk of Windows API).<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideRenameFile'''(const OldName, NewName: WideString): Boolean; <br />
| Rename file from '''OldName''' to '''NewName'''. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideCopyFile'''(const FromFile, ToFile: WideString; FailIfExists: Boolean): Boolean;<br />
| Rename file from '''FromFile''' to '''ToFile'''. If '''FailIfExists''' flag is TRUE, file will not be copied when destination file already exists, otherwise, destination file will be overwritten. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideFileSearch'''(const Name, DirList: WideString): WideString; <br />
| Search through the directories passed in '''DirList''' for a file named '''Name'''. DirList is a list of path names delimited by semicolons. If file matching Name is located, function returns a string specifying a path name for that file. If no matching file exists, function returns an empty string.<br />
|-<br />
| procedure '''WideScanDirForFiles'''(const Dir: WideString; var Files: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString); <br />
| You can get a list of the files inside a folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Files''': Where the list of files is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden files?<br />
*'''IncludeSystem''': Do you want to list the system files?<br />
*'''Mask''': List only the files which match a [[ReNamer:Masks|wildcard mask]], or specify an empty string to list all files.<br />
|-<br />
| procedure '''WideScanDirForFolders'''(const Dir: WideString; var Folders: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean); <br />
| You can get a list of the folders inside other folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Folders''': Where the list of folders is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden folders?<br />
*'''IncludeSystem''': Do you want to list the system folders?<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Name Utilities ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideExtractFilePath'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", including the trailing path delimiter, e.g. "C:\Folder\".<br />
|-<br />
| function '''WideExtractFileDir'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", excluding the trailing path delimiter, e.g. "C:\Folder".<br />
|-<br />
| function '''WideExtractFileDrive'''(const FileName: WideString): WideString; <br />
| Returns the drive letter, e.g. "C:".<br />
|-<br />
| function '''WideExtractFileName'''(const FileName: WideString): WideString; <br />
| Returns the filename with extension, e.g. "FileName.txt".<br />
|-<br />
| function '''WideExtractBaseName'''(const FileName: WideString): WideString; <br />
| Returns the base name of the file, i.e. file name without extension and path components.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| Document<br />
|}<br />
<br />
|-<br />
| function '''WideExtractFileExt'''(const FileName: WideString): WideString; <br />
| Returns the file's extension with the dot, e.g. ".txt".<br />
|-<br />
| function '''WideChangeFileExt'''(const FileName, Extension: WideString): WideString; <br />
| Replaces the original extension, and returns the new filename with extension, e.g. "FineName.txt" -&gt; "FineName.pdf".<br />
|-<br />
| function '''WideStripExtension'''(const FileName: WideString): WideString; <br />
| Strips off the extension from the filename, maintaining the path component unaffected.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| C:\Folder\Document<br />
|}<br />
<br />
|-<br />
| function '''WideExpandFileName'''(const FileName: WideString): WideString; <br />
| Converts the relative file name into a fully qualified path. This function does not verify that the resulting path refers to an existing file.<br />
|-<br />
| function '''WideExtractRelativePath'''(const BaseName, DestName: WideString): WideString; <br />
| Creates a relative path to go from '''BaseName''' to '''DestName'''. For example:<br />
<br />
{|<br />
| '''BaseName:'''<br />
| <nowiki>C:\Folder\FileName.txt</nowiki><br />
|-<br />
| '''DestName:'''<br />
| <nowiki>C:\Documents\Article.pdf</nowiki><br />
|-<br />
| '''Result:'''<br />
| <nowiki>..\Documents\Article.pdf</nowiki><br />
|}<br />
<br />
|-<br />
| function '''WideExtractShortPathName'''(const FileName: WideString): WideString; <br />
| It converts a path into it's representation in DOS format.<br />
|-<br />
| function '''WideIncludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a folder '''contains''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideExcludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a file does '''not contain''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideSameFileName'''(const FileName1, FileName2: WideString): Boolean;<br />
| Compares the filenames '''FileName1''' and '''FileName2''', and returns ''TRUE'' if they are considered to be same.<br />
<br />
Note that filenames on Windows platform are case insensitive for comparison purposes, but case preserving when creating new files.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMask'''(const FileName, Mask: WideString): Boolean;<br />
| Check if '''FileName''' matches a [[ReNamer:Masks|wildcard mask]] '''Mask'''. Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask <code>*.txt</code> matches files with a <code>.txt</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMaskList'''(const FileName, MaskList: WideString): Boolean;<br />
| Check if '''FileName''' matches any of the [[ReNamer:Masks|wildcard masks]] listed in '''MaskList'''. The list of masks is separated by semicolons (";"). Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask list <code>*.txt;*.doc</code> matches files with a <code>.txt</code> or <code>.doc</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Read/Write ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileReadFragment'''(const FileName: WideString; Start, Length: Integer): String; <br />
| Starting at position '''Start''', read '''Length''' number of characters of the file '''FileName''' and return them as a string. '''Start''' is 0-based, so in order to start the fragment at the beginning of the file, set this parameter to 0 (zero).<br />
|-<br />
| function '''FileReadLines'''(const FileName: WideString): TAnsiStringArray;<br />
| Read all lines from a file '''FileName'''.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''FileReadLine'''(const FileName: WideString; LineNum: Integer): String; <br />
| Read a line from a file '''FileName''' specified by a line index '''LineNum'''. '''LineNum''' is 1 based, so to get the first line set this parameter to 1 (one).<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileCountLines'''(const FileName: WideString): Integer; <br />
| Count number of lines in the file.<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileReadContent'''(const FileName: WideString): String; <br />
| Return the entire content of the file as a String.<br />
|-<br />
| procedure '''FileWriteContent'''(const FileName: WideString; const Content: String); <br />
| Write '''Content''' to the file. If target file already exists, it will be overwritten.<br />
|-<br />
| procedure '''FileAppendContent'''(const FileName: WideString; const Content: String); <br />
| Append '''Content''' to the end of the file. If target file does not exist, it will be created.<br />
|-<br />
| function '''FileReadText'''(const FileName: WideString): WideString;<br />
| Read text from a file, performing automatic text encoding handling.<br/>''Added in v6.6.0.6 Beta.''<br />
|-<br />
| function '''FileReadTextLines'''(const FileName: WideString): TWideStringArray;<br />
| Read lines of text from a file, performing automatic text encoding handling.<br/>''Added in v6.7.0.1 Beta.''<br />
|}<br />
<br />
Note: Automatic text encoding handling is based on [https://en.wikipedia.org/wiki/Byte_order_mark byte order mark] (BOM) and supports UTF-8, UTF-16BE and UTF-16LE. If no BOM found then text is interpreted as ANSI encoding.<br />
<br />
{{Top}}<br />
<br />
== File Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileTimeModified'''(const FileName: WideString): TDateTime; <br />
| Returns last modified time of the specified file.<br />
|-<br />
| function '''FileTimeCreated'''(const FileName: WideString): TDateTime; <br />
| Returns creation time of the specified file.<br />
|-<br />
| function '''SetFileTimeCreated'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets creation time for the specified file.<br />
|-<br />
| function '''SetFileTimeModified'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets last modified time for the specified file.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Meta Tags Extraction ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''CalculateMetaTag'''(const FilePath: WideString; const MetaTagName: String): WideString; <br />
| Extracts and returns the value of a meta tag specified by '''MetaTagName''' from the file specified by the complete absolute path '''FilePath'''.<br/>''Return type changed from String to WideString in v5.74.4 Beta.''<br />
|-<br />
| function '''CalculateMetaTagFormat'''(const FilePath: WideString; const MetaTagName, DateTimeFormat: String): WideString;<br />
| Same as '''CalculateMetaTag''' except an additional parameter '''DateTimeFormat''' is provided to specify custom Date/Time format to be used instead of the application's default setting.<br/>''Added in v5.74.4 Beta.''<br />
|}<br />
<br />
For example, to extract '''EXIF_Date''' tag from an image and set it to the filename using the default date/time formatting:<br />
<syntaxhighlight lang="pascal"><br />
begin<br />
FileName := CalculateMetaTag(FilePath, 'EXIF_Date');<br />
end.<br />
</syntaxhighlight><br />
<br />
The full list of meta tags can be found in [[ReNamer:Meta Tags|Meta Tags]] article. For help with date/time formatting refer to [[ReNamer:Date and Time format|Date and Time format]].<br />
<br />
{{Top}}<br />
<br />
== Regular Expressions ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsMatchingRegEx'''(const Input, Pattern: WideString; const CaseSensitive: Boolean): Boolean;<br />
| Check for a match against a RegEx pattern.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''ReplaceRegEx'''(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString; <br />
| Find and replace all RegEx pattern matches. Works like the [[ReNamer:Rules:RegEx|Regular Expressions rule]].<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''Replace''' - The replacement pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''UseSubstitution''' - Substitute [[ReNamer:Regular Expressions#Backreferences|backreferences]] in the replacement pattern.<br />
|-<br />
| function '''FindRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean; out Positions: TIntegerArray; out Matches: TWideStringArray): Integer;<br />
| Find matches and positions of a RegEx pattern. Returns the number of matches.<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''Positions''' - Receives a list of positions where the matches have been found.<br />
* '''Matches''' - Receives a list of matches.<br />
<br />
''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''MatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| Returns a list of RegEx matches as an array. Function returns an array of full matches, which matched the entire expression, not the sub-patterns.<br />
|-<br />
| function '''SubMatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| This function is very similar to '''MatchesRegEx''', but instead of returning full matches it will return an array of sub-expression matches for the '''first''' full match.<br />
<br />
In this way, it can easily be combined with '''MatchesRegEx''' function, to allow users to find all global matches, and then parse those matches through '''SubMatchesRegEx''' function to find individual sub-expression matches of each global match.<br />
|}<br />
<br />
Example input and matches for '''MatchesRegEx''' and '''SubMatchesRegEx''' functions:<br />
<br />
{| class="wikitable"<br />
|-<br />
! Input <br />
! Find<br />
! MatchesRegEx matches<br />
! SubMatchesRegEx matches<br />
|-<br />
| A1_B2_C3 <br />
| [A-Z]\d<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| ''(empty)''<br />
|-<br />
| A1_B2_C3 <br />
| ([A-Z])(\d)<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| <br />
* A<br />
* 1<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Process Execution ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''ShellOpenFile'''(const FileName: WideString): Boolean; <br />
| Run (open) a file specified by '''FileName'''. Works like "Start &gt; Run" command. Parameter does not have to be an executable file, it can by any file or protocol with assigned handler. For example, you can open a Word document or a web page, and associated application will be launched:<br />
* <tt><nowiki>ShellOpenFile('http://www.den4b.com/');</nowiki></tt><br />
* <tt><nowiki>ShellOpenFile('C:\Document.doc');</nowiki></tt><br />
<br />
'''Beware:''' This function will evaluate the command for the appropriate way of execution which may sometimes lead to unexpected results. For example when executing ''ShellOpenFile('notepad')'' it could actually run a ''Windows Notepad'' application normally located in "''C:\Windows\notepad.exe''", or some other "''notepad.exe''" file located on the search path (''%PATH%''), or even open "''notepad''" folder located in the current working directory.<br />
|-<br />
| function '''ExecuteProgram'''(const Command: String; WaitForProgram: Boolean): Cardinal; <br />
| Execute a command specified by '''Command''' parameter. Parameter '''WaitForProgram''' allows you to specify whether the code needs to wait until the command (launched program) has finished executing.<br />
|-<br />
| function '''ExecuteProgramShow'''(const Command: String; WaitForProgram: Boolean; ShowWindowFlag: Word): Cardinal;<br />
| Execute a command specified by '''Command''' parameter. '''WaitForProgram''' parameter allows you to specify whether the code needs to wait until the command (launched program) has finished executing. '''ShowWindowFlag''' parameter controls how the window is to be shown.<br />
<br />
Commonly used values for '''ShowWindowFlag''' parameter: <br />
* 0 = Hide the window.<br />
* 1 = Activate and display the window.<br />
* 2 = Activate the window and display it minimized.<br />
* 3 = Activate the window and display it maximized.<br />
* 4 = Display the window, but do not activate it.<br />
* 7 = Display the window minimized, but do not activate it.<br />
* More information: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx ShowWindow Windows API function].<br />
<br />
''Added in v5.75.3 Beta.''<br />
|-<br />
| function '''ExecConsoleApp'''(const CommandLine: String; out Output: String): Cardinal; <br />
| Execute a command line specified by '''CommandLine''' parameter and capture its standard output in the '''Output''' variable. This function should be used only for console style applications. Returns the exit code.<br />
<br />
Console application output uses OEM-defined character set by default, unless application itself changes its output code page. '''OemToAnsi''' and '''OemToWide''' functions can be used to convert OEM output.<br />
<br />
Prior to ''v6.6.0.2 Beta'', OEM to ANSI conversion was automatically applied to the console output. As of ''v6.6.0.2 Beta'', the console output is returned "as is" without any modifications, so to prevent corruption of binary or non-OEM encoded output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Dialogs ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''ShowMessage'''(const Msg: String); <br />
| Show a simple dialog with the message specified by '''Msg''' parameter.<br />
|-<br />
| procedure '''WideShowMessage'''(const Msg: WideString); <br />
| Same as '''ShowMessage''' function but parameter is Unicode text.<br />
|-<br />
| function '''DialogYesNo'''(const Msg: String): Boolean; <br />
| Show a simple prompt with the message specified by '''Msg''' parameter and two button: Yes and No. Returns TRUE if user clicks Yes button, otherwise FALSE.<br />
|-<br />
| function '''WideDialogYesNo'''(const Msg: WideString): Boolean; <br />
| Same as '''DialogYesNo''' function but parameter is WideString text.<br />
|-<br />
| function '''InputBox'''(const ACaption, APrompt, ADefault: String): String; <br />
| Displays a simple dialog box with the given '''ACaption''' and '''APrompt''' message. It asks the user to enter data in a text box on the dialog. A '''ADefault''' value is displayed in the text box initially. If the user presses OK, the value from the text box is returned, otherwise '''ADefault''' value is returned.<br />
|-<br />
| function '''InputQuery'''(const ACaption, APrompt: String; var Value: String): Boolean; <br />
| Operates similar to '''InputBox''' function. The default value and the value of the text box after the dialog is closed are transferred via the '''Value''' parameter. Function returns TRUE is user clicked OK, otherwise returns FALSE.<br />
|-<br />
| function '''WideInputBox'''(const ACaption, APrompt, ADefault: WideString): WideString; <br />
| Same as '''InputBox''' function but operates on WideString text.<br />
|-<br />
| function '''WideInputQuery'''(const ACaption, APrompt: WideString; var Value: WideString): Boolean; <br />
| Same as '''InputQuery''' function but operates on WideString text.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Application ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''GetApplicationPath''': WideString;<br />
| Return full path to the application, for example: "C:\Program Files\ReNamer\ReNamer.exe".<br />
|-<br />
| function '''GetApplicationParams''': TWideStringArray;<br />
| Return an array of command line parameters which were supplied to the application at launch.<br />
|-<br />
| function '''GetCurrentFileIndex''': Integer;<br />
| Get index of the current file. Index ranges from '''1''' to '''GetTotalNumberOfFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfFiles''': Integer;<br />
| Get total number of files in the application.<br />
|-<br />
| function '''GetCurrentMarkedFileIndex''': Integer;<br />
| Get index of the current file, counting only ''marked'' files. Index ranges from '''1''' to '''GetTotalNumberOfMarkedFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfMarkedFiles''': Integer;<br />
| Get total number of ''marked'' files in the application.<br />
|-<br />
| function '''GetAllFiles''': TWideStringArray;<br />
| Get file paths of all available files. ''Added in v5.74.2 Beta.''<br />
|-<br />
| function '''GetMarkedFiles''': TWideStringArray;<br />
| Get file paths of all marked files. ''Added in v5.74.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Global Variables ==<br />
<br />
Global variables allow for efficient storage and exchange of information between scripts.<br />
<br />
Variables do not get cleared automatically, so they exist until cleared manually or until the application terminates. If you wish to clear variables at each Preview, a good mechanism to do that is via the [[ReNamer:Pascal_Script:Initialization_of_variables|script initialization]].<br />
<br />
''Added in v7.4.0.2 Beta.''<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''SetGlobalVar'''(const Name: String; Value: Variant);<br />
| Set a global variable.<br />
|-<br />
| function '''GetGlobalVar'''(const Name: String): Variant;<br />
| Get a global variable. If variable does not exist, the function returns an ''Unassigned'' value.<br />
|-<br />
| function '''GetGlobalVarDef'''(const Name: String; Default: Variant): Variant;<br />
| Get a global variable. If variable does not exist, the function returns the ''Default'' value.<br />
|-<br />
| function '''HasGlobalVar'''(const Name: String): Boolean;<br />
| Check if a global variable exists.<br />
|-<br />
| function '''GetGlobalVarCount''': Integer;<br />
| Retrieve the total number of global variables.<br />
|-<br />
| function '''GetGlobalVarNames''': TAnsiStringArray;<br />
| Retrieve names of all global variables.<br />
|-<br />
| procedure '''ClearGlobalVar'''(const Name: String);<br />
| Clear a global variable.<br />
|-<br />
| procedure '''ClearGlobalVars''';<br />
| Clear all global variables.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== System ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideGetCurrentDir''': WideString; <br />
| Returns the current working directory.<br />
|-<br />
| function '''WideSetCurrentDir'''(const Dir: WideString): Boolean; <br />
| Sets the current working directory to the directory specified by parameter '''Dir'''.<br />
|-<br />
| function '''WideGetTempPath''': WideString;<br />
| Returns system defined temporary directory. If returned value is empty it means that temporary folder could not be determined.<br />
|-<br />
| function '''WideGetEnvironmentVar'''(const VarName: WideString): WideString; <br />
| Returns an environment variable by its name. For example:<br />
<syntaxhighlight lang="pascal"><br />
var<br />
UserName, ComputerName: WideString;<br />
begin<br />
UserName := WideGetEnvironmentVar('USERNAME');<br />
ComputerName := WideGetEnvironmentVar('COMPUTERNAME');<br />
end.<br />
</syntaxhighlight><br />
|}<br />
<br />
{{Top}}<br />
<br />
== Miscellaneous ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''Error'''(const Message: String);<br />
| Abruptly terminate the script with an error message.<br/>''Added in v7.2.0.7 Beta.''<br />
|-<br />
| procedure '''Sleep'''(Milliseconds: Cardinal); <br />
| Sleep (pause the execution) for specified number of '''Milliseconds'''.<br />
|-<br />
| procedure '''DivMod'''(Dividend: Integer; Divisor: Word; var Result, Remainder: Word); <br />
| Perform integer division and fetch the remainder as well, all in one operation. '''Dividend''' is the integer into which you are dividing. '''Divisor''' is the value by which to divide '''Dividend'''. '''Result''' returns the result of the integer division. '''Remainder''' returns the remainder (the difference between Result * Divisor and Dividend).<br />
|-<br />
| procedure '''Randomize'''; <br />
| Prepares the random number generator.<br />
'''Note:''' Should only be called once per application cycle, at the start of the process!<br />
|-<br />
| function '''RandomRange'''(const AFrom, ATo: Integer): Integer; <br />
| Return a random integer number within the specified range from '''AFrom''' (inclusive) to '''ATo''' (non-inclusive).<br />
|-<br />
| function '''RandomFloat''': Extended;<br />
| Return a random floating point value between 0.0 (including) and 1.0 (excluding).<br/>''Added in v6.2.0.8 Beta.''<br />
|- <br />
| function '''RandomBoolean''': Boolean;<br />
| Return a random boolean value, either ''True'' or ''False''.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''RandomString'''(Len: Integer; const Chars: String): String;<br />
| Generate a random string of length '''Len''' using characters selected at random from a string '''Chars'''.<br/>''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''MinInt'''(const A, B: Integer): Integer;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinInt64'''(const A, B: Int64): Int64;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinFloat'''(const A, B: Extended): Extended;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt'''(const A, B: Integer): Integer;<br />
| Return the largest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt64'''(const A, B: Int64): Int64;<br />
| Return the largest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxFloat'''(const A, B: Extended): Extended;<br />
| Return the largest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''GetClipboardText''': WideString; <br />
| Get the content of the the clipboard (text only).<br />
|-<br />
| procedure '''SetClipboardText'''(const S: WideString); <br />
| Set the content of the the clipboard (text only).<br />
|-<br />
| function '''Base64Encode'''(const S: String): String; <br />
| Encode string '''S''' into [http://en.wikipedia.org/wiki/Base64 Base64]. Useful for encoding binary data in order to minimize the likelihood of data being modified in transit through different systems, like email or internet.<br />
|-<br />
| function '''Base64Decode'''(const S: String): String; <br />
| Decode [http://en.wikipedia.org/wiki/Base64 Base64] encoded string.<br />
|-<br />
| function '''URLDecode'''(const Str: String; UsePlusAsSpace: Boolean): WideString;<br />
| Decode URL encoded string. All occurrences of ''%XX'' hex format are decoded, then entire string is decoded from UTF8.<br />
<br />
Optionally, plus signs ("+") can be interpreted as white space by enabling '''UsePlusAsSpace''' parameter, for compatibility with some encoders such as in [http://php.net/manual/en/function.urlencode.php PHP].<br />
<br />
''Added in v5.74.4 Beta. UsePlusAsSpace parameter added in v6.7.0.1 Beta.''<br />
|-<br />
| function '''URLEncode'''(const Str: WideString; UsePlusAsSpace: Boolean): String;<br />
| Encode string using URL encoding. Input string is encoded with UTF8, then all characters except digits and Latin letters are encoded in ''%XX'' hex format.<br />
<br />
Optionally, white spaces can be encoded as plus signs ("+") by enabling '''UsePlusAsSpace''' parameter, for compatibility with some decoders such as in [http://php.net/manual/en/function.urldecode.php PHP].<br />
<br />
''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''GetTickCount''': Cardinal; <br />
| Retrieves the number of milliseconds that have elapsed since the system was started (up to 49.7 days, then timer resets). The precision of this timer is very limited.<br />
|-<br />
| function '''SizeOf'''(X): Integer; <br />
| Pass a variable reference to determine the number of bytes used to represent the variable. Pass a type identifier to determine the number of bytes used to represent instances of that type.<br />
|}<br />
<br />
{{Top}}<br />
<br />
[[Category:ReNamer]]<br />
[[Category:Pascal Script]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Scripts:ExifTool&diff=3504ReNamer:Scripts:ExifTool2022-12-12T21:07:32Z<p>Den4b: /* Script */ UTF8 filename handling</p>
<hr />
<div>{{Up|ReNamer:Scripts}}<br />
<br />
This script integrates [https://exiftool.org/ ExifTool] command tool in order to extract EXIF/IPTC/XMP tags from many types of images. CRW, CR2, RAW, HEIF/HEVC images are also supported.<br />
<br />
== Requirements ==<br />
<br />
* <code>exiftool.exe</code> in ReNamer's folder.<br />
<br />
Download and extract the ExifTool package into ReNamer's folder.<br />
<br />
Note that the ExifTool for Windows package contains a file named <code>exiftool(-k).exe</code>, which must be renamed to <code>exiftool.exe</code> before using in ReNamer. Otherwise, the command line tool interprets the <code>(-k)</code> text as a trigger to wait for the user to press the ENTER key at the end of the output, which ReNamer won't be able to do and the application will just freeze.<br />
<br />
== Script ==<br />
<br />
Replace the filename with the "Date/Time Original" meta tag.<br />
<br />
The meta tag output is used "as is" and it often contains invalid filename characters, so you may need to use additional rules to clean up the filename afterwards.<br />
<br />
You can check the full list of available meta tags by running <code>exiftool.exe &lt;file&gt;</code> command and then you can modify the <code>TAG</code> constant to work with any of the listed tags.<br />
<br />
* Tested with ReNamer 7.4 and ExifTool 12.52.<br />
<br />
<syntaxhighlight lang="pascal"><br />
const<br />
EXE = 'exiftool.exe -t -charset filename=utf8';<br />
TAG = 'Date/Time Original' + '\t(.*?)[\r\n]';<br />
<br />
var<br />
Command, Output: String;<br />
Matches: TWideStringArray;<br />
<br />
begin<br />
Command := EXE + ' "' + FilePath + '"';<br />
if ExecConsoleApp(Command, Output) = 0 then<br />
begin<br />
Matches := SubMatchesRegEx(Output, TAG, False);<br />
if Length(Matches) > 0 then<br />
FileName := Matches[0] + WideExtractFileExt(FileName);<br />
end;<br />
end.<br />
</syntaxhighlight></div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script:Functions&diff=3503ReNamer:Pascal Script:Functions2022-12-10T10:42:34Z<p>Den4b: Global Variables</p>
<hr />
<div>{{Go|up=ReNamer:Pascal Script|prev=ReNamer:Pascal Script:Types}}<br />
<br />
ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file, strings entered by the user, etc. This functionality is available for use via the [[ReNamer:Rules:PascalScript|PascalScript rule]].<br />
<br />
The difference between a "function" and a "procedure" is that while a function executes an algorithm and returns a value, a procedure just executes an algorithm without returning anything.<br />
<br />
A common "Wide" prefix in function names indicates that the function deals with '''WideString''' type rather than '''AnsiString''' or '''String''' type. For example, ''ShowMessage'' and ''WideShowMessage'' procedures. See the [[ReNamer:Pascal_Script:Types#String_types|String Types]] for more information.<br />
<br />
== Basic String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''Insert'''(Source: String; var S: String; Index: Integer); <br />
| Inserts the string '''S''' into string '''Source''' at position '''Index'''.<br />
|-<br />
| procedure '''Delete'''(var S: String; Index, Count: Integer); <br />
| Deletes '''Count''' characters from the string '''S''', starting from position '''Index'''.<br />
|-<br />
| function '''Copy'''(S: String; Index, Count: Integer): String; <br />
| Copies '''Count''' characters from string '''S''', starting at position '''Index''', and returns them as a new string.<br />
|-<br />
| function '''Pos'''(Substr: String; S: String): Integer; <br />
| Returns the position of a string '''Substr''' in another string '''S'''.<br />
|}<br />
<br />
'''Note:''' Indexes of characters in strings are 1 based, so first character in string S would be S[1].<br />
<br />
{{Top}}<br />
<br />
== Length Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''SetLength'''(var S: Array; NewLength: Integer); <br />
| Sets the length of array variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: String; NewLength: Integer); <br />
| Sets the length of string variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: WideString; NewLength: Integer); <br />
| Sets the length of widestring '''S''' to '''NewLength'''.<br />
|-<br />
| function '''Length'''(const S: Array): Integer; <br />
| Returns the length of array '''S ''' (number of elements).<br />
|-<br />
| function '''Length'''(const S: String): Integer; <br />
| Returns the length of string '''S''' (number of characters).<br />
|-<br />
| function '''Length'''(const S: WideString): Integer;<br />
| Returns the length of WideString '''S''' (number of characters).<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''WideInsert'''(const Substr: WideString; var Dest: WideString; Index: Integer); <br />
| Inserts '''Substr''' in '''Dest''' at position '''Index'''.<br />
|-<br />
| procedure '''WideDelete'''(var S: WideString; Index, Count: Integer); <br />
| Deletes '''Count''' characters from '''S''', starting from the '''Index''' position.<br />
|-<br />
| procedure '''WideDeleteRight'''(var S: WideString; Index, Count: Integer);<br />
| Delete '''Count''' characters from '''S''', starting from the '''Index''' position from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| procedure '''WideSetLength'''(var S: WideString; NewLength: Integer); <br />
| Change the length of string '''S''' to a new length specified by '''NewLength'''. If new length is smaller than original, the string is truncated. If new length is greater than original, the string will be expanded but additional characters will not be initialized and can be anything.<br />
|-<br />
| function '''WideLength'''(const S: WideString): Integer; <br />
| Returns the length of WideString '''S'''.<br />
|-<br />
| function '''WideCopy'''(const S: WideString; Index, Count: Integer): WideString; <br />
| Returns '''Count''' characters from '''S''', starting at position '''Index'''.<br />
|-<br />
| function '''WideCopyRight'''(const S: WideString; Index, Count: Integer): WideString;<br />
| Returns '''Count''' characters from '''S''', starting at position '''Index''' from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WidePos'''(const SubStr, S: WideString): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WidePosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S''' but start searching from position specified by '''Offset'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WideUpperCase'''(const S: WideString): WideString; <br />
| Returns the ALLCAPS version of the WideString '''S'''<br />
|-<br />
| function '''WideLowerCase'''(const S: WideString): WideString; <br />
| Returns the lowercase version of the WideString '''S'''<br />
|-<br />
| function '''WideCompareStr'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-sensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideCompareText'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideSameText'''(const S1, S2: WideString): Boolean; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive. Returns TRUE if both are identical, otherwise returns FALSE.<br />
|-<br />
| function '''WideTextPos'''(const SubStr, S: WideString): Integer; <br />
| Behaves like '''WidePos''' function, except text if processed in case-insensitive manner.<br />
|-<br />
| function '''WideTextPosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer;<br />
| Behaves like '''WidePosEx''' function, except text if processed in case-insensitive manner.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideTrim'''(const S: WideString): WideString; <br />
| Removes leading and trailing spaces and control characters from the given string '''S'''.<br />
|-<br />
| function '''WideTrimChars'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning and the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsLeft'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsRight'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideReverseString'''(const S: WideString): WideString;<br />
| Return a reversed version of string '''S''', i.e. reverse the order of characters.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideRepeatString'''(const S: WideString; Count: Integer): WideString;<br />
| Repeat a string a number of times.<br/>''Added in v6.9.0.3 Beta.''<br />
<br />
|-<br />
| function '''WideReplaceStr'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-sensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
<br />
|-<br />
| function '''WideReplaceText'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-insensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
|-<br />
| function '''WideSplitString'''(const Input, Delimiter: WideString): TWideStringArray; <br />
| <br />
Splits the '''Input''' wherever '''Delimiter''' occurs and returns an array that contains the split parts. <br />
<br />
*The '''Delimiter''' itself can be a multi-character WideString. <br>(Unlike the usual comma, hyphen or space that are used for this purpose) <br />
*The split parts (returned as elements of the array) do not contain the '''Delimiter'''.<br />
<br />
|-<br />
|-<br />
| function '''WideJoinStrings'''(const Strings: TWideStringArray; const Delimiter: WideString): WideString;<br />
| Joins all individual items from '''Strings''' into a single WideString, with '''Delimiter''' inserted between the joined items.<br />
<br />
|-<br />
| function '''WideCaseSentence'''(const S: WideString): WideString; <br />
| Returns a ''Sentence case'' version of parameter '''S'''. <br />
<br />
Only the first alphabetic character is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
''Added in v6.0.0.3 Alpha''.<br />
|-<br />
| function '''WideCaseCapitalize'''(const S: WideString): WideString; <br />
| <br />
Returns the ''Title case'' version of parameter '''S'''. <br />
<br />
First letter of every word is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
|-<br />
| function '''WideCaseInvert'''(const S: WideString): WideString; <br />
| Inverts case of all characters in '''S''' and returns it.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide Character Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsWideCharUpper'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in upper case.<br />
|-<br />
| function '''IsWideCharLower'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in lower case.<br />
|-<br />
| function '''IsWideCharDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a digit (numeric character 0-9). <br />
|-<br />
| function '''IsWideCharSpace'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a white-space character, such as: space, form-feed, newline, carriage-return, tab and vertical-tab (characters classified as C1_SPACE).<br />
|-<br />
| function '''IsWideCharPunct'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a punctuation mark (characters classified as C1_PUNCT).<br />
|-<br />
| function '''IsWideCharCntrl'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a control character (characters classified as C1_CNTRL).<br />
|-<br />
| function '''IsWideCharBlank'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a blank, such as: space and tab (characters classified as C1_BLANK).<br />
|-<br />
| function '''IsWideCharXDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a hexadecimal digit (0-9 or A-F).<br />
|-<br />
| function '''IsWideCharAlpha'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character (a-z or A-Z).<br />
|-<br />
| function '''IsWideCharAlphaNumeric'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character or a numeric character (a-z, A-Z or 0-9).<br />
|-<br />
| function '''IsWideWordBoundaryLeft'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the left.<br />
<br />
Conditions that qualify as word boundaries to the left of character:<br />
# If first character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.'' <br />
|-<br />
| function '''IsWideWordBoundaryRight'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the right.<br />
<br />
Conditions that qualify as word boundaries to the right of character:<br />
# If last character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideCharUpper'''(const WC: WideChar): WideChar; <br />
| Returns an upper case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideCharLower'''(const WC: WideChar): WideChar; <br />
| Returns a lower case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideChr'''(Code: Word): WideChar;<br />
| Create a character from a code point.<br/>''Added in v6.9.0.3 Beta.''<br />
|}<br />
<br />
'''Note:''' Character classifications, such as C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT, C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA - are part of Unicode definitions. More information regarding classification can be found on the internet. For example: [http://www.fileformat.info/info/unicode/ http://www.fileformat.info/info/unicode/].<br />
<br />
{{Top}}<br />
<br />
== Unicode Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideToAnsi'''(const WS: WideString): String; <br />
| Converts [[Unicode]] string to [[ANSI]] string, according to the system locale.<br />
|-<br />
| function '''AnsiToWide'''(const S: String): WideString; <br />
| Converts [[ANSI]] string to [[Unicode]] string, according to the system locale.<br />
|-<br />
| function '''UTF8Encode'''(const WS: WideString): String; <br />
| Convert WideString type to UTF-8 encoded string.<br/>Useful for storing Unicode strings in files, sometimes for compatibility reasons and sometimes to reduce the size of the file.<br />
|-<br />
| function '''UTF8Decode'''(const S: String): WideString;<br />
| Convert UTF-8 encoded string to WideString type.<br />
|}<br />
<br />
== Console Output Conversion ==<br />
<br />
OEM-defined character set is commonly used in the output of console applications.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''OemToAnsi'''(const S: String): String;<br />
| Convert OEM string into an ANSI string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''OemToWide'''(const S: String): WideString;<br />
| Convert OEM string into a WideString.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''AnsiToOem'''(const S: String): String;<br />
| Convert ANSI string into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''WideToOem'''(const S: WideString): String; <br />
| Convert WideString into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Basic Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''BoolToStr'''(B: Boolean): String;<br />
| Convert boolean variable into a string. Returns "''True''" or "''False''" string value.<br />
|-<br />
| function '''IntToStr'''(Value: Integer): String; <br />
| Converts an integer to a string. The following assumptions are correct:<br />
<div style="font-family: monospace"><br />
* IntToStr(123) = '123'<br />
* IntToStr(0123) = '123'<br />
* IntToStr(123) <> '0123'<br />
</div><br />
<b>Note:</b> Be cautious of supplying ''Int64'' type as a parameter as it will be type casted to ''Integer'', which significantly reduces the range of possible values (refer to [[ReNamer:Pascal Script:Types|Types]] for more information). You can use '''FormatFloat''' function to convert ''Int64'' values to a string without a loss of range.<br />
|-<br />
| function '''Int64ToStr'''(Value: Int64): String;<br />
| Same as '''IntToStr''' but takes in ''Int64'' typed parameter.<br />
|-<br />
| function '''StrToInt'''(const S: String): Integer; <br />
| Converts a string to an integer. The following equalities are correct:<br />
<div style="font-family: monospace"><br />
* StrToInt('123') = 123<br />
* StrToInt('123') = 0123<br />
* StrToInt('0123') = 123<br />
</div><br />
'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''StrToInt64'''(const S: String): Int64;<br />
| Same as '''StrToInt''' but returns ''Int64'' typed result.<br />
|-<br />
| function '''StrToIntDef'''(const S: String; const Default: Integer): Integer; <br />
| Behaves like '''StrToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''StrToInt64Def'''(const S: String; Default: Int64): Int64;<br />
| Same as '''StrToIntDef''' but operates with ''Int64'' type.<br />
|-<br />
| function '''TryStrToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Converts a string to an integer, but does not throw an error when invalid string is supplied, unlike '''StrToInt'''. Returns ''False'' if conversion operation has failed.<br />
|-<br />
| function '''FloatToStr'''(Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using default system format.<br />
|-<br />
| function '''StrToFloat'''(const S: string): Extended;<br />
| Converts supplied string to a floating point value.<br>'''Warning:''' An error will occur if the parameter to this function cannot be converted to a floating point value!<br />
|-<br />
| function '''StrToFloatDef'''(const S: string; const Default: Extended): Extended;<br />
| Behaves like '''StrToFloat''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to a floating point value.<br />
|-<br />
| function '''FormatFloat'''(const Format: string; Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using user specific '''Format'''.<br/>Check [[#Floating point format specifiers|floating point format specifiers]] below for more information.<br />
|-<br />
| function '''DateToStr'''(D: TDateTime): String; <br />
| Converts a date to a string, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''StrToDate'''(const S: String): TDateTime; <br />
| Converts a date string to a proper TDateTime value, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''IntToHex'''(Value: Integer; Digits: Integer): String; <br />
| Converts an integer to its hexadecimal representation. Here are samples:<br />
<div style="font-family: monospace"><br />
* IntToHex(1234, 1) = '4D2'<br />
* IntToHex(1234, 8) = '000004D2'<br />
</div><br />
|-<br />
| function '''HexToInt'''(const HexNum: String): Integer; <br />
| Converts a hexadecimal value to its decimal representation.<br/>'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''HexToIntDef'''(const HexNum: String; Default: Integer): Integer; <br />
| Behaves like '''HexToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''IntToRoman'''(Value: Integer): String;<br />
| Convert a decimal number to Roman numerals.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToInt'''(const S: String): Integer;<br />
| Convert Roman numerals to a decimal number.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToIntDef'''(const S: String; Default: Integer): Integer;<br />
| Convert Roman numerals to a decimal number. Returns the '''Default''' value in the conversion fails.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''TryRomanToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Try to convert Roman numerals to a decimal number. Does not throw an error on failure, instead it returns ''False''.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''Ord'''(X: Char): Byte; <br />
| Return an ordinal value (byte representation) of a character.<br />
|-<br />
| function '''Chr'''(X: Byte): Char; <br />
| Return a character by its ordinal value (byte representation).<br />
|}<br />
<br />
=== Floating point format specifiers ===<br />
<br />
{| class="wikitable"<br />
! Specifier<br />
! Represents<br />
|-<br />
| <tt>0</tt>&nbsp;(zero)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "0" appears in the format string, then that digit is copied to the output string. Otherwise, a "0" is stored in that position in the output string.<br />
|-<br />
| <tt>#</tt>&nbsp;(hash)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "#" appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string.<br />
|-<br />
| <tt>.</tt>&nbsp;(dot)<br />
| Decimal point. The first "." character in the format string determines the location of the decimal separator in the formatted value, any additional "." characters are ignored.<br />
|-<br />
| <tt>,</tt>&nbsp;(comma)<br />
| Thousand separator. If the format string contains one or more "," characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of "," characters in the format string does not affect the output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Date and Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''Date''': TDateTime; <br />
| Returns the current system date.<br />
|-<br />
| function '''Time''': TDateTime; <br />
| Returns the current system time.<br />
|-<br />
| function '''Now''': TDateTime; <br />
| Returns the current system date and time.<br />
|-<br />
| function '''EncodeDate'''(Year, Month, Day: Word): TDateTime; <br />
| Generates date value for the specified '''Year''', '''Month''', '''Day'''. Parameters must be within a valid date range: Year = 0..9999, Month = 1..12, Day = 1..31 (depending on month/year). An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeTime'''(Hour, Min, Sec, MSec: Word): TDateTime; <br />
| Generates time value for the specified '''Hour''', '''Min''', '''Sec''', '''MSec'''. Parameters must be within a valid time range: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word): TDateTime;<br />
| Generates date-time value for the specified components of date and time. Similar to '''EncodeDate''' and '''EncodeTime'''.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''TryEncodeDate'''(Year, Month, Day: Word; var Date: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeDate''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date value will be written in the '''Date''' variable.<br />
|-<br />
| function '''TryEncodeTime'''(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated time value will be written in the '''Time''' variable.<br />
|-<br />
| function '''TryEncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''EncodeDateTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date-time value will be written in the '''ADateTime''' variable.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| procedure '''DecodeDate'''(const DateTime: TDateTime; var Year, Month, Day: Word); <br />
| Extracts '''Year''', '''Month''' and '''Day''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeTime'''(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word); <br />
| Extracts '''Hour''', '''Min''', '''Sec''' and '''MSec''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeDateTime'''(const DateTime: TDateTime; out Year, Month, Day, Hour, Minute, Second, MilliSecond: Word);<br />
| Similar to '''DecodeDate''' and '''DecodeTime''' but extracts both date and time components at once.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''ComposeDateTime'''(const Date, Time: TDateTime): TDateTime;<br />
| Combine date and time components into a single date-time value.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DateTimeToUnix'''(D: TDateTime): Int64;<br />
| Converts '''D''' value of type '''TDateTime''' to a Unix timestamp.<br />
|-<br />
| function '''UnixToDateTime'''(U: Int64): TDateTime; <br />
| Converts a Unix timestamp to a value of '''TDateTime''' type.<br />
|-<br />
| function '''FormatDateTime'''(const Format: String; DateTime: TDateTime): String;<br />
| Convert date and time value to a string using [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Format''' parameter. <br />
|-<br />
| function '''ScanDateTime'''(const Pattern, Subject: String): TDateTime;<br />
| Convert '''Subject''' string to a date and time value by parsing it according to the [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Pattern''' parameter.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''TryScanDateTime'''(const Pattern, Subject: String; out DateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''ScanDateTime''' function, except it suppresses errors and returns either ''TRUE'' or ''FALSE'' depending on the success of the operation.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''IncYear'''(const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of years (plus or minus).<br />
|-<br />
| function '''IncMonth'''(const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of months (plus or minus).<br />
|-<br />
| function '''IncWeek'''(const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of weeks (plus or minus).<br />
|-<br />
| function '''IncDay'''(const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of days (plus or minus).<br />
|-<br />
| function '''IncHour'''(const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of hours (plus or minus).<br />
|-<br />
| function '''IncMinute'''(const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of minutes (plus or minus).<br />
|-<br />
| function '''IncSecond'''(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of seconds (plus or minus).<br />
|-<br />
| function '''IncMilliSecond'''(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of milliseconds (plus or minus).<br />
|-<br />
| function '''SecondSpan'''(const ANow, AThen: TDateTime): Double;<br />
| Calculate the approximate number of seconds between two date-time values.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DayOfWeek'''(const DateTime: TDateTime): Word; <br />
| Returns the day number of the week. Returned values: 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday.<br/>''Before v6.1 this function used to return 1=Sunday to 7=Saturday.''<br />
|-<br />
| function '''DayOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''DayOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the year.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the year.<br/>''Added in v6.1.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideFileSize'''(const FileName: WideString): Int64; <br />
| Returns the size of the file in bytes. If file does not exist "-1" is returned. The return value is of type ''Int64'' which can store the maximum file size of 9,223,372,036,854,775,807 bytes.<br />
|-<br />
| function '''WideFileExists'''(const FileName: WideString): Boolean; <br />
| Check whether specified file exists. Returns TRUE if file exists, otherwise FALSE.<br />
|-<br />
| function '''WideDirectoryExists'''(const Directory: WideString): Boolean; <br />
| Check whether specified directory exists. Returns TRUE if directory exists, otherwise FALSE.<br />
|-<br />
| function '''WideForceDirectories'''(const Dir: WideString): Boolean; <br />
| Makes sure that that all directories in the path exist. If they don't, function will try to create them, recursively. Returns TRUE if all folders exist or have been successfully created.<br />
|-<br />
| function '''WideCreateDir'''(const Dir: WideString): Boolean; <br />
| Create specified directory (non-recursive). Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideRemoveDir'''(const Dir: WideString): Boolean;<br />
| Remove a directory, if it is empty. Returns TRUE on success, otherwise FALSE.<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideDeleteFile'''(const FileName: WideString): Boolean; <br />
| Delete physical file from the disk. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideDeleteToRecycleBin'''(const FileName: WideString): Boolean;<br />
| Delete file or folder by placing it into the Recycle Bin. Returns TRUE on success, otherwise FALSE.<br />
<br />
'''Note:''' You must provide a full path to delete the file to the Recycle Bin (a quirk of Windows API).<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideRenameFile'''(const OldName, NewName: WideString): Boolean; <br />
| Rename file from '''OldName''' to '''NewName'''. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideCopyFile'''(const FromFile, ToFile: WideString; FailIfExists: Boolean): Boolean;<br />
| Rename file from '''FromFile''' to '''ToFile'''. If '''FailIfExists''' flag is TRUE, file will not be copied when destination file already exists, otherwise, destination file will be overwritten. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideFileSearch'''(const Name, DirList: WideString): WideString; <br />
| Search through the directories passed in '''DirList''' for a file named '''Name'''. DirList is a list of path names delimited by semicolons. If file matching Name is located, function returns a string specifying a path name for that file. If no matching file exists, function returns an empty string.<br />
|-<br />
| procedure '''WideScanDirForFiles'''(const Dir: WideString; var Files: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString); <br />
| You can get a list of the files inside a folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Files''': Where the list of files is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden files?<br />
*'''IncludeSystem''': Do you want to list the system files?<br />
*'''Mask''': List only the files which match a [[ReNamer:Masks|wildcard mask]], or specify an empty string to list all files.<br />
|-<br />
| procedure '''WideScanDirForFolders'''(const Dir: WideString; var Folders: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean); <br />
| You can get a list of the folders inside other folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Folders''': Where the list of folders is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden folders?<br />
*'''IncludeSystem''': Do you want to list the system folders?<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Name Utilities ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideExtractFilePath'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", including the trailing path delimiter, e.g. "C:\Folder\".<br />
|-<br />
| function '''WideExtractFileDir'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", excluding the trailing path delimiter, e.g. "C:\Folder".<br />
|-<br />
| function '''WideExtractFileDrive'''(const FileName: WideString): WideString; <br />
| Returns the drive letter, e.g. "C:".<br />
|-<br />
| function '''WideExtractFileName'''(const FileName: WideString): WideString; <br />
| Returns the filename with extension, e.g. "FileName.txt".<br />
|-<br />
| function '''WideExtractBaseName'''(const FileName: WideString): WideString; <br />
| Returns the base name of the file, i.e. file name without extension and path components.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| Document<br />
|}<br />
<br />
|-<br />
| function '''WideExtractFileExt'''(const FileName: WideString): WideString; <br />
| Returns the file's extension with the dot, e.g. ".txt".<br />
|-<br />
| function '''WideChangeFileExt'''(const FileName, Extension: WideString): WideString; <br />
| Replaces the original extension, and returns the new filename with extension, e.g. "FineName.txt" -&gt; "FineName.pdf".<br />
|-<br />
| function '''WideStripExtension'''(const FileName: WideString): WideString; <br />
| Strips off the extension from the filename, maintaining the path component unaffected.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| C:\Folder\Document<br />
|}<br />
<br />
|-<br />
| function '''WideExpandFileName'''(const FileName: WideString): WideString; <br />
| Converts the relative file name into a fully qualified path. This function does not verify that the resulting path refers to an existing file.<br />
|-<br />
| function '''WideExtractRelativePath'''(const BaseName, DestName: WideString): WideString; <br />
| Creates a relative path to go from '''BaseName''' to '''DestName'''. For example:<br />
<br />
{|<br />
| '''BaseName:'''<br />
| <nowiki>C:\Folder\FileName.txt</nowiki><br />
|-<br />
| '''DestName:'''<br />
| <nowiki>C:\Documents\Article.pdf</nowiki><br />
|-<br />
| '''Result:'''<br />
| <nowiki>..\Documents\Article.pdf</nowiki><br />
|}<br />
<br />
|-<br />
| function '''WideExtractShortPathName'''(const FileName: WideString): WideString; <br />
| It converts a path into it's representation in DOS format.<br />
|-<br />
| function '''WideIncludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a folder '''contains''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideExcludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a file does '''not contain''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideSameFileName'''(const FileName1, FileName2: WideString): Boolean;<br />
| Compares the filenames '''FileName1''' and '''FileName2''', and returns ''TRUE'' if they are considered to be same.<br />
<br />
Note that filenames on Windows platform are case insensitive for comparison purposes, but case preserving when creating new files.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMask'''(const FileName, Mask: WideString): Boolean;<br />
| Check if '''FileName''' matches a [[ReNamer:Masks|wildcard mask]] '''Mask'''. Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask <code>*.txt</code> matches files with a <code>.txt</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMaskList'''(const FileName, MaskList: WideString): Boolean;<br />
| Check if '''FileName''' matches any of the [[ReNamer:Masks|wildcard masks]] listed in '''MaskList'''. The list of masks is separated by semicolons (";"). Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask list <code>*.txt;*.doc</code> matches files with a <code>.txt</code> or <code>.doc</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Read/Write ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileReadFragment'''(const FileName: WideString; Start, Length: Integer): String; <br />
| Starting at position '''Start''', read '''Length''' number of characters of the file '''FileName''' and return them as a string. '''Start''' is 0-based, so in order to start the fragment at the beginning of the file, set this parameter to 0 (zero).<br />
|-<br />
| function '''FileReadLines'''(const FileName: WideString): TAnsiStringArray;<br />
| Read all lines from a file '''FileName'''.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''FileReadLine'''(const FileName: WideString; LineNum: Integer): String; <br />
| Read a line from a file '''FileName''' specified by a line index '''LineNum'''. '''LineNum''' is 1 based, so to get the first line set this parameter to 1 (one).<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileCountLines'''(const FileName: WideString): Integer; <br />
| Count number of lines in the file.<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileReadContent'''(const FileName: WideString): String; <br />
| Return the entire content of the file as a String.<br />
|-<br />
| procedure '''FileWriteContent'''(const FileName: WideString; const Content: String); <br />
| Write '''Content''' to the file. If target file already exists, it will be overwritten.<br />
|-<br />
| procedure '''FileAppendContent'''(const FileName: WideString; const Content: String); <br />
| Append '''Content''' to the end of the file. If target file does not exist, it will be created.<br />
|-<br />
| function '''FileReadText'''(const FileName: WideString): WideString;<br />
| Read text from a file, performing automatic text encoding handling.<br/>''Added in v6.6.0.6 Beta.''<br />
|-<br />
| function '''FileReadTextLines'''(const FileName: WideString): TWideStringArray;<br />
| Read lines of text from a file, performing automatic text encoding handling.<br/>''Added in v6.7.0.1 Beta.''<br />
|}<br />
<br />
Note: Automatic text encoding handling is based on [https://en.wikipedia.org/wiki/Byte_order_mark byte order mark] (BOM) and supports UTF-8, UTF-16BE and UTF-16LE. If no BOM found then text is interpreted as ANSI encoding.<br />
<br />
{{Top}}<br />
<br />
== File Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileTimeModified'''(const FileName: WideString): TDateTime; <br />
| Returns last modified time of the specified file.<br />
|-<br />
| function '''FileTimeCreated'''(const FileName: WideString): TDateTime; <br />
| Returns creation time of the specified file.<br />
|-<br />
| function '''SetFileTimeCreated'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets creation time for the specified file.<br />
|-<br />
| function '''SetFileTimeModified'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets last modified time for the specified file.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Meta Tags Extraction ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''CalculateMetaTag'''(const FilePath: WideString; const MetaTagName: String): WideString; <br />
| Extracts and returns the value of a meta tag specified by '''MetaTagName''' from the file specified by the complete absolute path '''FilePath'''.<br/>''Return type changed from String to WideString in v5.74.4 Beta.''<br />
|-<br />
| function '''CalculateMetaTagFormat'''(const FilePath: WideString; const MetaTagName, DateTimeFormat: String): WideString;<br />
| Same as '''CalculateMetaTag''' except an additional parameter '''DateTimeFormat''' is provided to specify custom Date/Time format to be used instead of the application's default setting.<br/>''Added in v5.74.4 Beta.''<br />
|}<br />
<br />
For example, to extract '''EXIF_Date''' tag from an image and set it to the filename using the default date/time formatting:<br />
<syntaxhighlight lang="pascal"><br />
begin<br />
FileName := CalculateMetaTag(FilePath, 'EXIF_Date');<br />
end.<br />
</syntaxhighlight><br />
<br />
The full list of meta tags can be found in [[ReNamer:Meta Tags|Meta Tags]] article. For help with date/time formatting refer to [[ReNamer:Date and Time format|Date and Time format]].<br />
<br />
{{Top}}<br />
<br />
== Regular Expressions ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsMatchingRegEx'''(const Input, Pattern: WideString; const CaseSensitive: Boolean): Boolean;<br />
| Check for a match against a RegEx pattern.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''ReplaceRegEx'''(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString; <br />
| Find and replace all RegEx pattern matches. Works like the [[ReNamer:Rules:RegEx|Regular Expressions rule]].<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''Replace''' - The replacement pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''UseSubstitution''' - Substitute [[ReNamer:Regular Expressions#Backreferences|backreferences]] in the replacement pattern.<br />
|-<br />
| function '''FindRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean; out Positions: TIntegerArray; out Matches: TWideStringArray): Integer;<br />
| Find matches and positions of a RegEx pattern. Returns the number of matches.<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''Positions''' - Receives a list of positions where the matches have been found.<br />
* '''Matches''' - Receives a list of matches.<br />
<br />
''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''MatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| Returns a list of RegEx matches as an array. Function returns an array of full matches, which matched the entire expression, not the sub-patterns.<br />
|-<br />
| function '''SubMatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| This function is very similar to '''MatchesRegEx''', but instead of returning full matches it will return an array of sub-expression matches for the '''first''' full match.<br />
<br />
In this way, it can easily be combined with '''MatchesRegEx''' function, to allow users to find all global matches, and then parse those matches through '''SubMatchesRegEx''' function to find individual sub-expression matches of each global match.<br />
|}<br />
<br />
Example input and matches for '''MatchesRegEx''' and '''SubMatchesRegEx''' functions:<br />
<br />
{| class="wikitable"<br />
|-<br />
! Input <br />
! Find<br />
! MatchesRegEx matches<br />
! SubMatchesRegEx matches<br />
|-<br />
| A1_B2_C3 <br />
| [A-Z]\d<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| ''(empty)''<br />
|-<br />
| A1_B2_C3 <br />
| ([A-Z])(\d)<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| <br />
* A<br />
* 1<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Process Execution ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''ShellOpenFile'''(const FileName: WideString): Boolean; <br />
| Run (open) a file specified by '''FileName'''. Works like "Start &gt; Run" command. Parameter does not have to be an executable file, it can by any file or protocol with assigned handler. For example, you can open a Word document or a web page, and associated application will be launched:<br />
* <tt><nowiki>ShellOpenFile('http://www.den4b.com/');</nowiki></tt><br />
* <tt><nowiki>ShellOpenFile('C:\Document.doc');</nowiki></tt><br />
<br />
'''Beware:''' This function will evaluate the command for the appropriate way of execution which may sometimes lead to unexpected results. For example when executing ''ShellOpenFile('notepad')'' it could actually run a ''Windows Notepad'' application normally located in "''C:\Windows\notepad.exe''", or some other "''notepad.exe''" file located on the search path (''%PATH%''), or even open "''notepad''" folder located in the current working directory.<br />
|-<br />
| function '''ExecuteProgram'''(const Command: String; WaitForProgram: Boolean): Cardinal; <br />
| Execute a command specified by '''Command''' parameter. Parameter '''WaitForProgram''' allows you to specify whether the code needs to wait until the command (launched program) has finished executing.<br />
|-<br />
| function '''ExecuteProgramShow'''(const Command: String; WaitForProgram: Boolean; ShowWindowFlag: Word): Cardinal;<br />
| Execute a command specified by '''Command''' parameter. '''WaitForProgram''' parameter allows you to specify whether the code needs to wait until the command (launched program) has finished executing. '''ShowWindowFlag''' parameter controls how the window is to be shown.<br />
<br />
Commonly used values for '''ShowWindowFlag''' parameter: <br />
* 0 = Hide the window.<br />
* 1 = Activate and display the window.<br />
* 2 = Activate the window and display it minimized.<br />
* 3 = Activate the window and display it maximized.<br />
* 4 = Display the window, but do not activate it.<br />
* 7 = Display the window minimized, but do not activate it.<br />
* More information: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx ShowWindow Windows API function].<br />
<br />
''Added in v5.75.3 Beta.''<br />
|-<br />
| function '''ExecConsoleApp'''(const CommandLine: String; out Output: String): Cardinal; <br />
| Execute a command line specified by '''CommandLine''' parameter and capture its standard output in the '''Output''' variable. This function should be used only for console style applications. Returns the exit code.<br />
<br />
Console application output uses OEM-defined character set by default, unless application itself changes its output code page. '''OemToAnsi''' and '''OemToWide''' functions can be used to convert OEM output.<br />
<br />
Prior to ''v6.6.0.2 Beta'', OEM to ANSI conversion was automatically applied to the console output. As of ''v6.6.0.2 Beta'', the console output is returned "as is" without any modifications, so to prevent corruption of binary or non-OEM encoded output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Dialogs ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''ShowMessage'''(const Msg: String); <br />
| Show a simple dialog with the message specified by '''Msg''' parameter.<br />
|-<br />
| procedure '''WideShowMessage'''(const Msg: WideString); <br />
| Same as '''ShowMessage''' function but parameter is Unicode text.<br />
|-<br />
| function '''DialogYesNo'''(const Msg: String): Boolean; <br />
| Show a simple prompt with the message specified by '''Msg''' parameter and two button: Yes and No. Returns TRUE if user clicks Yes button, otherwise FALSE.<br />
|-<br />
| function '''WideDialogYesNo'''(const Msg: WideString): Boolean; <br />
| Same as '''DialogYesNo''' function but parameter is WideString text.<br />
|-<br />
| function '''InputBox'''(const ACaption, APrompt, ADefault: String): String; <br />
| Displays a simple dialog box with the given '''ACaption''' and '''APrompt''' message. It asks the user to enter data in a text box on the dialog. A '''ADefault''' value is displayed in the text box initially. If the user presses OK, the value from the text box is returned, otherwise '''ADefault''' value is returned.<br />
|-<br />
| function '''InputQuery'''(const ACaption, APrompt: String; var Value: String): Boolean; <br />
| Operates similar to '''InputBox''' function. The default value and the value of the text box after the dialog is closed are transferred via the '''Value''' parameter. Function returns TRUE is user clicked OK, otherwise returns FALSE.<br />
|-<br />
| function '''WideInputBox'''(const ACaption, APrompt, ADefault: WideString): WideString; <br />
| Same as '''InputBox''' function but operates on WideString text.<br />
|-<br />
| function '''WideInputQuery'''(const ACaption, APrompt: WideString; var Value: WideString): Boolean; <br />
| Same as '''InputQuery''' function but operates on WideString text.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Application ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''GetApplicationPath''': WideString;<br />
| Return full path to the application, for example: "C:\Program Files\ReNamer\ReNamer.exe".<br />
|-<br />
| function '''GetApplicationParams''': TWideStringArray;<br />
| Return an array of command line parameters which were supplied to the application at launch.<br />
|-<br />
| function '''GetCurrentFileIndex''': Integer;<br />
| Get index of the current file. Index ranges from '''1''' to '''GetTotalNumberOfFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfFiles''': Integer;<br />
| Get total number of files in the application.<br />
|-<br />
| function '''GetCurrentMarkedFileIndex''': Integer;<br />
| Get index of the current file, counting only ''marked'' files. Index ranges from '''1''' to '''GetTotalNumberOfMarkedFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfMarkedFiles''': Integer;<br />
| Get total number of ''marked'' files in the application.<br />
|-<br />
| function '''GetAllFiles''': TWideStringArray;<br />
| Get file paths of all available files. ''Added in v5.74.2 Beta.''<br />
|-<br />
| function '''GetMarkedFiles''': TWideStringArray;<br />
| Get file paths of all marked files. ''Added in v5.74.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Global Variables ==<br />
<br />
Global variables allow for efficient storage and exchange of information between scripts.<br />
<br />
''Added in v7.4.0.2 Beta.''<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''SetGlobalVar'''(const Name: String; Value: Variant);<br />
| Set a global variable.<br />
|-<br />
| function '''GetGlobalVar'''(const Name: String): Variant;<br />
| Get a global variable. If variable does not exist, the function returns an ''Unassigned'' value.<br />
|-<br />
| function '''GetGlobalVarDef'''(const Name: String; Default: Variant): Variant;<br />
| Get a global variable. If variable does not exist, the function returns the ''Default'' value.<br />
|-<br />
| function '''HasGlobalVar'''(const Name: String): Boolean;<br />
| Check if a global variable exists.<br />
|-<br />
| function '''GetGlobalVarCount''': Integer;<br />
| Retrieve the total number of global variables.<br />
|-<br />
| function '''GetGlobalVarNames''': TAnsiStringArray;<br />
| Retrieve names of all global variables.<br />
|-<br />
| procedure '''ClearGlobalVar'''(const Name: String);<br />
| Clear a global variable.<br />
|-<br />
| procedure '''ClearGlobalVars''';<br />
| Clear all global variables.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== System ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideGetCurrentDir''': WideString; <br />
| Returns the current working directory.<br />
|-<br />
| function '''WideSetCurrentDir'''(const Dir: WideString): Boolean; <br />
| Sets the current working directory to the directory specified by parameter '''Dir'''.<br />
|-<br />
| function '''WideGetTempPath''': WideString;<br />
| Returns system defined temporary directory. If returned value is empty it means that temporary folder could not be determined.<br />
|-<br />
| function '''WideGetEnvironmentVar'''(const VarName: WideString): WideString; <br />
| Returns an environment variable by its name. For example:<br />
<syntaxhighlight lang="pascal"><br />
var<br />
UserName, ComputerName: WideString;<br />
begin<br />
UserName := WideGetEnvironmentVar('USERNAME');<br />
ComputerName := WideGetEnvironmentVar('COMPUTERNAME');<br />
end.<br />
</syntaxhighlight><br />
|}<br />
<br />
{{Top}}<br />
<br />
== Miscellaneous ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''Error'''(const Message: String);<br />
| Abruptly terminate the script with an error message.<br/>''Added in v7.2.0.7 Beta.''<br />
|-<br />
| procedure '''Sleep'''(Milliseconds: Cardinal); <br />
| Sleep (pause the execution) for specified number of '''Milliseconds'''.<br />
|-<br />
| procedure '''DivMod'''(Dividend: Integer; Divisor: Word; var Result, Remainder: Word); <br />
| Perform integer division and fetch the remainder as well, all in one operation. '''Dividend''' is the integer into which you are dividing. '''Divisor''' is the value by which to divide '''Dividend'''. '''Result''' returns the result of the integer division. '''Remainder''' returns the remainder (the difference between Result * Divisor and Dividend).<br />
|-<br />
| procedure '''Randomize'''; <br />
| Prepares the random number generator.<br />
'''Note:''' Should only be called once per application cycle, at the start of the process!<br />
|-<br />
| function '''RandomRange'''(const AFrom, ATo: Integer): Integer; <br />
| Return a random integer number within the specified range from '''AFrom''' (inclusive) to '''ATo''' (non-inclusive).<br />
|-<br />
| function '''RandomFloat''': Extended;<br />
| Return a random floating point value between 0.0 (including) and 1.0 (excluding).<br/>''Added in v6.2.0.8 Beta.''<br />
|- <br />
| function '''RandomBoolean''': Boolean;<br />
| Return a random boolean value, either ''True'' or ''False''.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''RandomString'''(Len: Integer; const Chars: String): String;<br />
| Generate a random string of length '''Len''' using characters selected at random from a string '''Chars'''.<br/>''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''MinInt'''(const A, B: Integer): Integer;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinInt64'''(const A, B: Int64): Int64;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinFloat'''(const A, B: Extended): Extended;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt'''(const A, B: Integer): Integer;<br />
| Return the largest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt64'''(const A, B: Int64): Int64;<br />
| Return the largest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxFloat'''(const A, B: Extended): Extended;<br />
| Return the largest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''GetClipboardText''': WideString; <br />
| Get the content of the the clipboard (text only).<br />
|-<br />
| procedure '''SetClipboardText'''(const S: WideString); <br />
| Set the content of the the clipboard (text only).<br />
|-<br />
| function '''Base64Encode'''(const S: String): String; <br />
| Encode string '''S''' into [http://en.wikipedia.org/wiki/Base64 Base64]. Useful for encoding binary data in order to minimize the likelihood of data being modified in transit through different systems, like email or internet.<br />
|-<br />
| function '''Base64Decode'''(const S: String): String; <br />
| Decode [http://en.wikipedia.org/wiki/Base64 Base64] encoded string.<br />
|-<br />
| function '''URLDecode'''(const Str: String; UsePlusAsSpace: Boolean): WideString;<br />
| Decode URL encoded string. All occurrences of ''%XX'' hex format are decoded, then entire string is decoded from UTF8.<br />
<br />
Optionally, plus signs ("+") can be interpreted as white space by enabling '''UsePlusAsSpace''' parameter, for compatibility with some encoders such as in [http://php.net/manual/en/function.urlencode.php PHP].<br />
<br />
''Added in v5.74.4 Beta. UsePlusAsSpace parameter added in v6.7.0.1 Beta.''<br />
|-<br />
| function '''URLEncode'''(const Str: WideString; UsePlusAsSpace: Boolean): String;<br />
| Encode string using URL encoding. Input string is encoded with UTF8, then all characters except digits and Latin letters are encoded in ''%XX'' hex format.<br />
<br />
Optionally, white spaces can be encoded as plus signs ("+") by enabling '''UsePlusAsSpace''' parameter, for compatibility with some decoders such as in [http://php.net/manual/en/function.urldecode.php PHP].<br />
<br />
''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''GetTickCount''': Cardinal; <br />
| Retrieves the number of milliseconds that have elapsed since the system was started (up to 49.7 days, then timer resets). The precision of this timer is very limited.<br />
|-<br />
| function '''SizeOf'''(X): Integer; <br />
| Pass a variable reference to determine the number of bytes used to represent the variable. Pass a type identifier to determine the number of bytes used to represent instances of that type.<br />
|}<br />
<br />
{{Top}}<br />
<br />
[[Category:ReNamer]]<br />
[[Category:Pascal Script]]</div>Den4bhttp://www.den4b.com/w/index.php?title=Shutter:Actions&diff=3502Shutter:Actions2022-11-06T09:15:12Z<p>Den4b: Run Preset action added</p>
<hr />
<div>{{Up|Shutter}} <br />
<br />
Below is the list of all available actions. <br />
<br />
{| class="wikitable"<br />
! Action<br />
! Description<br />
|-<br />
| Shutdown <span style="color: red;"><sup>(T)</sup></span> <br />
| Shutdown computer.<br />
|-<br />
| Reboot <span style="color: red;"><sup>(T)</sup></span> <br />
| Reboot computer.<br />
|-<br />
| Logoff <span style="color: red;"><sup>(T)</sup></span> <br />
| Log out currently logged in user.<br />
|-<br />
| Lock Workstation <br />
| Lock workstation.<br />
|-<br />
| Sleep <span style="color: red;"></span> <br />
| Put computer into the suspended state.<br />
<br />
|-<br />
| Hibernate <span style="color: red;"></span> <br />
| Put computer into the hibernated state.<br />
<br />
'''Tip:''' First, check if the ''hibernate'' option is enabled in your PC: '''Control Panel''' &gt; '''Power Options''' &gt; '''Hibernate''' tab.<br />
<br />
|-<br />
| Turn Off Monitor <br />
| Switch off the monitor.<br />
|-<br />
| Screen Saver <br />
| <br />
Turn on the screen saver. <br />
<br />
'''Tip:''' You can set a password to turn off your screensaver and start working on the PC again. This effectively makes your PC secure from intruders.<br />
<br />
|-<br />
| Volume <br />
| Mute or unmute the master volume. <br />
<br />
|-<br />
| Hang Up <br />
| Drop connection of the modem device.<br />
|-<br />
| Alarm <br />
| Show a simple dialog displaying the current time and play an alarm sound.<br />
|-<br />
| Message <br />
| Show message for the specified period time with option to stop execution of the rest of actions and option to restart the events.<br />
|-<br />
| Play Sound <br />
| Play specified sound file with ability to wait for the sound file to finish before continuing with the rest of actions.<br />
|-<br />
| Run Program <br />
| Run specified executable and optionally wait for it to finish executing before continuing with the rest of actions.<br />
|-<br />
| Open File <br />
| Open a specified file using shell. This can be either of the following: <br />
*URL, for example: http://www.den4b.com/ <br />
*Executable, for example: "notepad" <br />
*Normal file, for example: "Document.doc" or "Song.mp3"<br />
<br />
|-<br />
| Close Window <br />
| Close all windows that match the specified window title.<br />
|-<br />
| Kill Process <br />
| Terminate all processes that match the specified executable filename.<br />
|-<br />
| Utilities <br />
| <br />
This is a special type of action to control the workflow of Shutter. <br />
<br />
The options are: <br />
<br />
* '''Close application<span style="color: red;"><sup>(T)</sup></span>''' - Close Shutter itself, typically, after executing all of the listed actions.<br>Effectively, Shutter runs just <u>once</u>: It waits for the events, executes the actions and then closes.<br />
<br />
* '''Restart events <span style="color: red;"><sup>(T)</sup></span>''' - Shutter "arms" itself once again, and waits for the entire set of events once again.<br>Effectively, Shutter runs the (''wait for events and then execute all actions'') cycle <u>endlessly</u>.<br />
<br />
* '''Pause execution''' - This can be used to introduce a waiting period before the next action is taken.<br>For example, if one Action closes an application, wait till it closes gracefully; and only then execute the next Action.<br />
<br />
|-<br />
| Run Preset <span style="color: red;"><sup>(T)</sup></span> <br />
| Start another preset in the current instance or in a new instance.<br>This action enables a more complex execution flow by running multiple sets of events and actions in sequence.<br />
<br />
|}<br />
<br />
'''<span style="color: red;"><sup>(T)</sup></span>''' Mark shows that this action is a <u>terminal action</u>, meaning that it may cause Shutter to terminate or otherwise stop the rest of actions from executing. You can use <u>only one</u> terminal action in the '''Actions''' pane, and it <u>must</u> be the last in the list of actions.<br />
<br />
[[Category:Shutter]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Filter_settings&diff=3501ReNamer:Filter settings2022-10-01T14:29:21Z<p>Den4b: Moved a note to the top.</p>
<hr />
<div>{{Up|ReNamer}}<br />
<br />
Filter settings give you a finer control over which files and folders get added to ReNamer, which can be accessed via the [[Image:FiltersButton.png]] button, or the [[ReNamer:Main menu|Main menu]].<br />
<br />
You can use a range of methods for [[ReNamer:Adding files and folders|adding new files and folders]] and the selected filter settings will be applied consistently in all cases.<br />
<br />
'''Note:''' Filter settings are applied only to the newly added files/folders and do not affect files/folders that are already listed in ReNamer.<br />
<br />
[[Image:FilterSettingsDialog.png|frame|none]]<br />
<br />
The options work as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Option<br />
! Effect<br />
|-<br />
| Add files within folders <br />
| When this option is selected, ReNamer scans the selected folders iteratively (including its subfolders), and loads all the files for renaming. If you want to rename only the folders (and not their contents), untick this option, and select the '''Add folders as files''' checkbox.<br />
|-<br />
| Add folders as files <br />
| If this option is selected, ReNamer treats a folder just like a file (not as a container that holds files and subfolders). So only the folder is loaded, and not the files in it. This is useful for renaming the folder itself. <br />
|-<br />
| Include subfolders <br />
| Loads contents from all subfolders recursively. If this option is unselected, when you add a folder, its subfolders will be ignored.<br />
|-<br />
| Include hidden items<br />
| Include or exclude hidden items when adding the content of folders folders.<br />
|-<br />
| Include system items <br />
| Include or exclude system protected items when adding the content of folders folders.<br />
|-<br />
| Skip root folders when added as files <br />
| Works when the ''Add folders as files'' and ''Include subfolders'' options are selected. When it's on, ReNamer adds all the subfolders but not the root folder itself.<br />
|-<br />
| Masks<br />
| All added files (or folders as files) must match specified [[ReNamer:Masks|masks]]. For example, if you enter '''*.jpg;*.gif;*.png''' as an ''Include'' mask, ReNamer will add only files with these extensions. Everything else will be filtered ''out'', i.e. not added to ReNamer. The ''Exclude'' mask will do the opposite, it will filter out everything that matches the mask.<br />
|-<br />
| Apply only to the file name <br />
| Changes how the masks (see above) are applied. <br />
For example, suppose you have file '''''C:\Folder\File.ext'''''. If ''this'' option is ON, only the filename part '''''File.ext''''' will be checked against the masks. But if ''this'' option is OFF, the entire path '''''C:\Folder\File.ext''''' will be checked against the masks. <br />
|-<br />
| Save as default for future sessions<br />
| Changes to filter settings effect only the current session. If you would like your filter settings to be remembered across sessions (after restarting the application), then tick this option before saving the settings.<br />
<br />
|}<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script:Types&diff=3500ReNamer:Pascal Script:Types2022-09-15T13:29:26Z<p>Den4b: /* Extra types */ TIntegerArray added</p>
<hr />
<div>{{Go|up=ReNamer:Pascal Script|next=ReNamer:Pascal Script:Functions}}<br />
<br />
This page lists and explains all supported types in [[ReNamer:Pascal Script|Pascal Script]] used within ReNamer.<br />
<br />
== Integer types ==<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Size<br />
! Lowest Value<br />
! Highest Value<br />
|-<br />
| '''Byte'''<br />
| 1 byte<br />
| align="center" | 0<br />
| align="center" | 255<br />
|-<br />
| '''ShortInt'''<br />
| 1 byte<br />
| align="center" | -128<br />
| align="center" | 127<br />
|-<br />
| '''Word'''<br />
| 2 bytes<br />
| align="center" | 0<br />
| align="center" | 65,535<br />
|-<br />
| '''SmallInt'''<br />
| 2 bytes<br />
| align="center" | -32,768<br />
| align="center" | 32,767<br />
|-<br />
| '''Cardinal'''<br />
| 4 bytes<br />
| align="center" | 0<br />
| align="center" | 4,294,967,295<br />
|-<br />
| '''Integer'''<br />
| 4 bytes<br />
| align="center" | -2,147,483,648<br />
| align="center" | 2,147,483,647<br />
|-<br />
| '''Int64'''<br />
| 8 bytes<br />
| align="center" | -9,223,372,036,854,775,808<br />
| align="center" | 9,223,372,036,854,775,807<br />
|}<br />
<br />
== Floating point types ==<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Size<br />
! Range<br />
|-<br />
| '''Single'''<br />
| 4 bytes<br />
| align="center" | 1.5 x 10<sup>-45</sup> .. 3.4 x 10<sup>38</sup><br />
|-<br />
| '''Double'''<br />
| 8 bytes<br />
| align="center" | 5.0 x 10<sup>-324</sup> .. 1.7 x 10<sup>308</sup><br />
|-<br />
| '''Extended'''<br />
| 10 bytes<br />
| align="center" | 3.6 x 10<sup>-4951</sup> .. 1.1 x 10<sup>4932</sup><br />
|}<br />
<br />
== String types ==<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| '''Char'''<br />
| Stores a single 8-bit character.<br />
|-<br />
| '''String'''<br />
| Holds a sequence of 8-bit characters. Commonly used for ANSI or UTF-8 encoded text.<br />
|-<br />
| '''AnsiChar'''<br />
| Alias for ''Char'' type.<br />
|-<br />
| '''AnsiString'''<br />
| Alias for ''String'' type.<br />
|-<br />
| '''WideChar'''<br />
| Stores a single 16-bit character.<br />
|-<br />
| '''WideString'''<br />
| Holds a sequence of 16-bit characters. Commonly used for UCS-2 or UTF-16 encoded text.<br />
|-<br />
| '''UnicodeChar'''<br />
| Alias for ''WideChar'' type.<br />
|-<br />
| '''UnicodeString'''<br />
| Alias for ''WideString'' type.<br />
|}<br />
<br />
'''Note:''' The [[Unicode]] article highlights the differences between various encodings.<br />
<br />
== Mixed types ==<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| '''Boolean'''<br />
| Provides an enumeration of the logical '''True''' and '''False''' values.<br />
|-<br />
| '''Array'''<br />
| Single and multi dimensional indexable sequences of data.<br />
|-<br />
| '''Record'''<br />
| Provides means of collecting together a set of different data types into one named structure.<br />
|-<br />
| '''Variant'''<br />
| Provides a flexible general purpose data type.<br />
|-<br />
| '''PChar'''<br />
| Pointer to a ''Char'' value, and can also be used to point to characters within a string.<br />
|}<br />
<br />
== Extra types ==<br />
<br />
Several extra types have been defined to simplify the use of some functions.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Declared as<br />
! Description<br />
|-<br />
| '''TDateTime'''<br />
| Double<br />
| Represents a date and time.<br />
|-<br />
| <strike>'''TStringsArray'''</strike><br />
| Array of WideString<br />
| Indexed list of ''WideString'' values.<br/>''Deprecated in v5.74.4 Beta. Please use TWideStringArray instead.''<br />
|-<br />
| '''TWideStringArray'''<br />
| Array of WideString<br />
| Indexed list of ''WideString'' values.<br/>''Added in v5.74.4 Beta. Replaces ambiguous TStringsArray type.''<br />
|-<br />
| '''TAnsiStringArray'''<br />
| Array of AnsiString<br />
| Indexed list of ''AnsiString'' values.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| '''TIntegerArray'''<br />
| Array of Integer<br />
| Indexed list of ''Integer'' values.<br/>''Added in v7.3.0.4 Beta.''<br />
|}<br />
<br />
== Enumerations and Sets ==<br />
<br />
An enumeration is simply a fixed range of named values.<br />
<br />
For example, the fundamental ''Boolean'' data type can be considered as an enumeration consisting of two values: ''True'' and ''False''.<br />
<br />
A variable of an enumeration type can be assigned a single value from the enumeration.<br />
<br />
<pre><br />
type<br />
TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);<br />
var<br />
Day: TDay;<br />
begin<br />
Day := Mon;<br />
if Day <> Tue then<br />
Day := Wed;<br />
end.<br />
</pre><br />
<br />
Sets allow you to defined variables which can hold multiple values out of the enumeration.<br />
<br />
<pre><br />
type<br />
TDay = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);<br />
TDays = set of TDay;<br />
var<br />
Days: TDays;<br />
begin<br />
Days := [Mon, Tue, Wed];<br />
if Sun in Days then<br />
Days := Days - [Sun];<br />
end.<br />
</pre><br />
<br />
<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script:Functions&diff=3499ReNamer:Pascal Script:Functions2022-09-15T13:24:39Z<p>Den4b: /* Basic Conversion */ Roman numerals conversion</p>
<hr />
<div>{{Go|up=ReNamer:Pascal Script|prev=ReNamer:Pascal Script:Types}}<br />
<br />
ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file, strings entered by the user, etc. This functionality is available for use via the [[ReNamer:Rules:PascalScript|PascalScript rule]].<br />
<br />
The difference between a "function" and a "procedure" is that while a function executes an algorithm and returns a value, a procedure just executes an algorithm without returning anything.<br />
<br />
A common "Wide" prefix in function names indicates that the function deals with '''WideString''' type rather than '''AnsiString''' or '''String''' type. For example, ''ShowMessage'' and ''WideShowMessage'' procedures. See the [[ReNamer:Pascal_Script:Types#String_types|String Types]] for more information.<br />
<br />
== Basic String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''Insert'''(Source: String; var S: String; Index: Integer); <br />
| Inserts the string '''S''' into string '''Source''' at position '''Index'''.<br />
|-<br />
| procedure '''Delete'''(var S: String; Index, Count: Integer); <br />
| Deletes '''Count''' characters from the string '''S''', starting from position '''Index'''.<br />
|-<br />
| function '''Copy'''(S: String; Index, Count: Integer): String; <br />
| Copies '''Count''' characters from string '''S''', starting at position '''Index''', and returns them as a new string.<br />
|-<br />
| function '''Pos'''(Substr: String; S: String): Integer; <br />
| Returns the position of a string '''Substr''' in another string '''S'''.<br />
|}<br />
<br />
'''Note:''' Indexes of characters in strings are 1 based, so first character in string S would be S[1].<br />
<br />
{{Top}}<br />
<br />
== Length Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''SetLength'''(var S: Array; NewLength: Integer); <br />
| Sets the length of array variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: String; NewLength: Integer); <br />
| Sets the length of string variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: WideString; NewLength: Integer); <br />
| Sets the length of widestring '''S''' to '''NewLength'''.<br />
|-<br />
| function '''Length'''(const S: Array): Integer; <br />
| Returns the length of array '''S ''' (number of elements).<br />
|-<br />
| function '''Length'''(const S: String): Integer; <br />
| Returns the length of string '''S''' (number of characters).<br />
|-<br />
| function '''Length'''(const S: WideString): Integer;<br />
| Returns the length of WideString '''S''' (number of characters).<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''WideInsert'''(const Substr: WideString; var Dest: WideString; Index: Integer); <br />
| Inserts '''Substr''' in '''Dest''' at position '''Index'''.<br />
|-<br />
| procedure '''WideDelete'''(var S: WideString; Index, Count: Integer); <br />
| Deletes '''Count''' characters from '''S''', starting from the '''Index''' position.<br />
|-<br />
| procedure '''WideDeleteRight'''(var S: WideString; Index, Count: Integer);<br />
| Delete '''Count''' characters from '''S''', starting from the '''Index''' position from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| procedure '''WideSetLength'''(var S: WideString; NewLength: Integer); <br />
| Change the length of string '''S''' to a new length specified by '''NewLength'''. If new length is smaller than original, the string is truncated. If new length is greater than original, the string will be expanded but additional characters will not be initialized and can be anything.<br />
|-<br />
| function '''WideLength'''(const S: WideString): Integer; <br />
| Returns the length of WideString '''S'''.<br />
|-<br />
| function '''WideCopy'''(const S: WideString; Index, Count: Integer): WideString; <br />
| Returns '''Count''' characters from '''S''', starting at position '''Index'''.<br />
|-<br />
| function '''WideCopyRight'''(const S: WideString; Index, Count: Integer): WideString;<br />
| Returns '''Count''' characters from '''S''', starting at position '''Index''' from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WidePos'''(const SubStr, S: WideString): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WidePosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S''' but start searching from position specified by '''Offset'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WideUpperCase'''(const S: WideString): WideString; <br />
| Returns the ALLCAPS version of the WideString '''S'''<br />
|-<br />
| function '''WideLowerCase'''(const S: WideString): WideString; <br />
| Returns the lowercase version of the WideString '''S'''<br />
|-<br />
| function '''WideCompareStr'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-sensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideCompareText'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideSameText'''(const S1, S2: WideString): Boolean; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive. Returns TRUE if both are identical, otherwise returns FALSE.<br />
|-<br />
| function '''WideTextPos'''(const SubStr, S: WideString): Integer; <br />
| Behaves like '''WidePos''' function, except text if processed in case-insensitive manner.<br />
|-<br />
| function '''WideTextPosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer;<br />
| Behaves like '''WidePosEx''' function, except text if processed in case-insensitive manner.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideTrim'''(const S: WideString): WideString; <br />
| Removes leading and trailing spaces and control characters from the given string '''S'''.<br />
|-<br />
| function '''WideTrimChars'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning and the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsLeft'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsRight'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideReverseString'''(const S: WideString): WideString;<br />
| Return a reversed version of string '''S''', i.e. reverse the order of characters.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideRepeatString'''(const S: WideString; Count: Integer): WideString;<br />
| Repeat a string a number of times.<br/>''Added in v6.9.0.3 Beta.''<br />
<br />
|-<br />
| function '''WideReplaceStr'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-sensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
<br />
|-<br />
| function '''WideReplaceText'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-insensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
|-<br />
| function '''WideSplitString'''(const Input, Delimiter: WideString): TWideStringArray; <br />
| <br />
Splits the '''Input''' wherever '''Delimiter''' occurs and returns an array that contains the split parts. <br />
<br />
*The '''Delimiter''' itself can be a multi-character WideString. <br>(Unlike the usual comma, hyphen or space that are used for this purpose) <br />
*The split parts (returned as elements of the array) do not contain the '''Delimiter'''.<br />
<br />
|-<br />
|-<br />
| function '''WideJoinStrings'''(const Strings: TWideStringArray; const Delimiter: WideString): WideString;<br />
| Joins all individual items from '''Strings''' into a single WideString, with '''Delimiter''' inserted between the joined items.<br />
<br />
|-<br />
| function '''WideCaseSentence'''(const S: WideString): WideString; <br />
| Returns a ''Sentence case'' version of parameter '''S'''. <br />
<br />
Only the first alphabetic character is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
''Added in v6.0.0.3 Alpha''.<br />
|-<br />
| function '''WideCaseCapitalize'''(const S: WideString): WideString; <br />
| <br />
Returns the ''Title case'' version of parameter '''S'''. <br />
<br />
First letter of every word is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
|-<br />
| function '''WideCaseInvert'''(const S: WideString): WideString; <br />
| Inverts case of all characters in '''S''' and returns it.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide Character Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsWideCharUpper'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in upper case.<br />
|-<br />
| function '''IsWideCharLower'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in lower case.<br />
|-<br />
| function '''IsWideCharDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a digit (numeric character 0-9). <br />
|-<br />
| function '''IsWideCharSpace'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a white-space character, such as: space, form-feed, newline, carriage-return, tab and vertical-tab (characters classified as C1_SPACE).<br />
|-<br />
| function '''IsWideCharPunct'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a punctuation mark (characters classified as C1_PUNCT).<br />
|-<br />
| function '''IsWideCharCntrl'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a control character (characters classified as C1_CNTRL).<br />
|-<br />
| function '''IsWideCharBlank'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a blank, such as: space and tab (characters classified as C1_BLANK).<br />
|-<br />
| function '''IsWideCharXDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a hexadecimal digit (0-9 or A-F).<br />
|-<br />
| function '''IsWideCharAlpha'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character (a-z or A-Z).<br />
|-<br />
| function '''IsWideCharAlphaNumeric'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character or a numeric character (a-z, A-Z or 0-9).<br />
|-<br />
| function '''IsWideWordBoundaryLeft'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the left.<br />
<br />
Conditions that qualify as word boundaries to the left of character:<br />
# If first character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.'' <br />
|-<br />
| function '''IsWideWordBoundaryRight'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the right.<br />
<br />
Conditions that qualify as word boundaries to the right of character:<br />
# If last character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideCharUpper'''(const WC: WideChar): WideChar; <br />
| Returns an upper case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideCharLower'''(const WC: WideChar): WideChar; <br />
| Returns a lower case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideChr'''(Code: Word): WideChar;<br />
| Create a character from a code point.<br/>''Added in v6.9.0.3 Beta.''<br />
|}<br />
<br />
'''Note:''' Character classifications, such as C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT, C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA - are part of Unicode definitions. More information regarding classification can be found on the internet. For example: [http://www.fileformat.info/info/unicode/ http://www.fileformat.info/info/unicode/].<br />
<br />
{{Top}}<br />
<br />
== Unicode Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideToAnsi'''(const WS: WideString): String; <br />
| Converts [[Unicode]] string to [[ANSI]] string, according to the system locale.<br />
|-<br />
| function '''AnsiToWide'''(const S: String): WideString; <br />
| Converts [[ANSI]] string to [[Unicode]] string, according to the system locale.<br />
|-<br />
| function '''UTF8Encode'''(const WS: WideString): String; <br />
| Convert WideString type to UTF-8 encoded string.<br/>Useful for storing Unicode strings in files, sometimes for compatibility reasons and sometimes to reduce the size of the file.<br />
|-<br />
| function '''UTF8Decode'''(const S: String): WideString;<br />
| Convert UTF-8 encoded string to WideString type.<br />
|}<br />
<br />
== Console Output Conversion ==<br />
<br />
OEM-defined character set is commonly used in the output of console applications.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''OemToAnsi'''(const S: String): String;<br />
| Convert OEM string into an ANSI string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''OemToWide'''(const S: String): WideString;<br />
| Convert OEM string into a WideString.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''AnsiToOem'''(const S: String): String;<br />
| Convert ANSI string into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''WideToOem'''(const S: WideString): String; <br />
| Convert WideString into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Basic Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''BoolToStr'''(B: Boolean): String;<br />
| Convert boolean variable into a string. Returns "''True''" or "''False''" string value.<br />
|-<br />
| function '''IntToStr'''(Value: Integer): String; <br />
| Converts an integer to a string. The following assumptions are correct:<br />
<div style="font-family: monospace"><br />
* IntToStr(123) = '123'<br />
* IntToStr(0123) = '123'<br />
* IntToStr(123) <> '0123'<br />
</div><br />
<b>Note:</b> Be cautious of supplying ''Int64'' type as a parameter as it will be type casted to ''Integer'', which significantly reduces the range of possible values (refer to [[ReNamer:Pascal Script:Types|Types]] for more information). You can use '''FormatFloat''' function to convert ''Int64'' values to a string without a loss of range.<br />
|-<br />
| function '''Int64ToStr'''(Value: Int64): String;<br />
| Same as '''IntToStr''' but takes in ''Int64'' typed parameter.<br />
|-<br />
| function '''StrToInt'''(const S: String): Integer; <br />
| Converts a string to an integer. The following equalities are correct:<br />
<div style="font-family: monospace"><br />
* StrToInt('123') = 123<br />
* StrToInt('123') = 0123<br />
* StrToInt('0123') = 123<br />
</div><br />
'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''StrToInt64'''(const S: String): Int64;<br />
| Same as '''StrToInt''' but returns ''Int64'' typed result.<br />
|-<br />
| function '''StrToIntDef'''(const S: String; const Default: Integer): Integer; <br />
| Behaves like '''StrToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''StrToInt64Def'''(const S: String; Default: Int64): Int64;<br />
| Same as '''StrToIntDef''' but operates with ''Int64'' type.<br />
|-<br />
| function '''TryStrToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Converts a string to an integer, but does not throw an error when invalid string is supplied, unlike '''StrToInt'''. Returns ''False'' if conversion operation has failed.<br />
|-<br />
| function '''FloatToStr'''(Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using default system format.<br />
|-<br />
| function '''StrToFloat'''(const S: string): Extended;<br />
| Converts supplied string to a floating point value.<br>'''Warning:''' An error will occur if the parameter to this function cannot be converted to a floating point value!<br />
|-<br />
| function '''StrToFloatDef'''(const S: string; const Default: Extended): Extended;<br />
| Behaves like '''StrToFloat''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to a floating point value.<br />
|-<br />
| function '''FormatFloat'''(const Format: string; Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using user specific '''Format'''.<br/>Check [[#Floating point format specifiers|floating point format specifiers]] below for more information.<br />
|-<br />
| function '''DateToStr'''(D: TDateTime): String; <br />
| Converts a date to a string, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''StrToDate'''(const S: String): TDateTime; <br />
| Converts a date string to a proper TDateTime value, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''IntToHex'''(Value: Integer; Digits: Integer): String; <br />
| Converts an integer to its hexadecimal representation. Here are samples:<br />
<div style="font-family: monospace"><br />
* IntToHex(1234, 1) = '4D2'<br />
* IntToHex(1234, 8) = '000004D2'<br />
</div><br />
|-<br />
| function '''HexToInt'''(const HexNum: String): Integer; <br />
| Converts a hexadecimal value to its decimal representation.<br/>'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''HexToIntDef'''(const HexNum: String; Default: Integer): Integer; <br />
| Behaves like '''HexToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''IntToRoman'''(Value: Integer): String;<br />
| Convert a decimal number to Roman numerals.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToInt'''(const S: String): Integer;<br />
| Convert Roman numerals to a decimal number.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''RomanToIntDef'''(const S: String; Default: Integer): Integer;<br />
| Convert Roman numerals to a decimal number. Returns the '''Default''' value in the conversion fails.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''TryRomanToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Try to convert Roman numerals to a decimal number. Does not throw an error on failure, instead it returns ''False''.<br/>''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''Ord'''(X: Char): Byte; <br />
| Return an ordinal value (byte representation) of a character.<br />
|-<br />
| function '''Chr'''(X: Byte): Char; <br />
| Return a character by its ordinal value (byte representation).<br />
|}<br />
<br />
=== Floating point format specifiers ===<br />
<br />
{| class="wikitable"<br />
! Specifier<br />
! Represents<br />
|-<br />
| <tt>0</tt>&nbsp;(zero)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "0" appears in the format string, then that digit is copied to the output string. Otherwise, a "0" is stored in that position in the output string.<br />
|-<br />
| <tt>#</tt>&nbsp;(hash)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "#" appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string.<br />
|-<br />
| <tt>.</tt>&nbsp;(dot)<br />
| Decimal point. The first "." character in the format string determines the location of the decimal separator in the formatted value, any additional "." characters are ignored.<br />
|-<br />
| <tt>,</tt>&nbsp;(comma)<br />
| Thousand separator. If the format string contains one or more "," characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of "," characters in the format string does not affect the output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Date and Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''Date''': TDateTime; <br />
| Returns the current system date.<br />
|-<br />
| function '''Time''': TDateTime; <br />
| Returns the current system time.<br />
|-<br />
| function '''Now''': TDateTime; <br />
| Returns the current system date and time.<br />
|-<br />
| function '''EncodeDate'''(Year, Month, Day: Word): TDateTime; <br />
| Generates date value for the specified '''Year''', '''Month''', '''Day'''. Parameters must be within a valid date range: Year = 0..9999, Month = 1..12, Day = 1..31 (depending on month/year). An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeTime'''(Hour, Min, Sec, MSec: Word): TDateTime; <br />
| Generates time value for the specified '''Hour''', '''Min''', '''Sec''', '''MSec'''. Parameters must be within a valid time range: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word): TDateTime;<br />
| Generates date-time value for the specified components of date and time. Similar to '''EncodeDate''' and '''EncodeTime'''.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''TryEncodeDate'''(Year, Month, Day: Word; var Date: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeDate''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date value will be written in the '''Date''' variable.<br />
|-<br />
| function '''TryEncodeTime'''(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated time value will be written in the '''Time''' variable.<br />
|-<br />
| function '''TryEncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''EncodeDateTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date-time value will be written in the '''ADateTime''' variable.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| procedure '''DecodeDate'''(const DateTime: TDateTime; var Year, Month, Day: Word); <br />
| Extracts '''Year''', '''Month''' and '''Day''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeTime'''(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word); <br />
| Extracts '''Hour''', '''Min''', '''Sec''' and '''MSec''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeDateTime'''(const DateTime: TDateTime; out Year, Month, Day, Hour, Minute, Second, MilliSecond: Word);<br />
| Similar to '''DecodeDate''' and '''DecodeTime''' but extracts both date and time components at once.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''ComposeDateTime'''(const Date, Time: TDateTime): TDateTime;<br />
| Combine date and time components into a single date-time value.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DateTimeToUnix'''(D: TDateTime): Int64;<br />
| Converts '''D''' value of type '''TDateTime''' to a Unix timestamp.<br />
|-<br />
| function '''UnixToDateTime'''(U: Int64): TDateTime; <br />
| Converts a Unix timestamp to a value of '''TDateTime''' type.<br />
|-<br />
| function '''FormatDateTime'''(const Format: String; DateTime: TDateTime): String;<br />
| Convert date and time value to a string using [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Format''' parameter. <br />
|-<br />
| function '''ScanDateTime'''(const Pattern, Subject: String): TDateTime;<br />
| Convert '''Subject''' string to a date and time value by parsing it according to the [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Pattern''' parameter.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''TryScanDateTime'''(const Pattern, Subject: String; out DateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''ScanDateTime''' function, except it suppresses errors and returns either ''TRUE'' or ''FALSE'' depending on the success of the operation.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''IncYear'''(const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of years (plus or minus).<br />
|-<br />
| function '''IncMonth'''(const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of months (plus or minus).<br />
|-<br />
| function '''IncWeek'''(const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of weeks (plus or minus).<br />
|-<br />
| function '''IncDay'''(const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of days (plus or minus).<br />
|-<br />
| function '''IncHour'''(const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of hours (plus or minus).<br />
|-<br />
| function '''IncMinute'''(const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of minutes (plus or minus).<br />
|-<br />
| function '''IncSecond'''(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of seconds (plus or minus).<br />
|-<br />
| function '''IncMilliSecond'''(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of milliseconds (plus or minus).<br />
|-<br />
| function '''SecondSpan'''(const ANow, AThen: TDateTime): Double;<br />
| Calculate the approximate number of seconds between two date-time values.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DayOfWeek'''(const DateTime: TDateTime): Word; <br />
| Returns the day number of the week. Returned values: 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday.<br/>''Before v6.1 this function used to return 1=Sunday to 7=Saturday.''<br />
|-<br />
| function '''DayOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''DayOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the year.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the year.<br/>''Added in v6.1.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideFileSize'''(const FileName: WideString): Int64; <br />
| Returns the size of the file in bytes. If file does not exist "-1" is returned. The return value is of type ''Int64'' which can store the maximum file size of 9,223,372,036,854,775,807 bytes.<br />
|-<br />
| function '''WideFileExists'''(const FileName: WideString): Boolean; <br />
| Check whether specified file exists. Returns TRUE if file exists, otherwise FALSE.<br />
|-<br />
| function '''WideDirectoryExists'''(const Directory: WideString): Boolean; <br />
| Check whether specified directory exists. Returns TRUE if directory exists, otherwise FALSE.<br />
|-<br />
| function '''WideForceDirectories'''(const Dir: WideString): Boolean; <br />
| Makes sure that that all directories in the path exist. If they don't, function will try to create them, recursively. Returns TRUE if all folders exist or have been successfully created.<br />
|-<br />
| function '''WideCreateDir'''(const Dir: WideString): Boolean; <br />
| Create specified directory (non-recursive). Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideRemoveDir'''(const Dir: WideString): Boolean;<br />
| Remove a directory, if it is empty. Returns TRUE on success, otherwise FALSE.<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideDeleteFile'''(const FileName: WideString): Boolean; <br />
| Delete physical file from the disk. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideDeleteToRecycleBin'''(const FileName: WideString): Boolean;<br />
| Delete file or folder by placing it into the Recycle Bin. Returns TRUE on success, otherwise FALSE.<br />
<br />
'''Note:''' You must provide a full path to delete the file to the Recycle Bin (a quirk of Windows API).<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideRenameFile'''(const OldName, NewName: WideString): Boolean; <br />
| Rename file from '''OldName''' to '''NewName'''. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideCopyFile'''(const FromFile, ToFile: WideString; FailIfExists: Boolean): Boolean;<br />
| Rename file from '''FromFile''' to '''ToFile'''. If '''FailIfExists''' flag is TRUE, file will not be copied when destination file already exists, otherwise, destination file will be overwritten. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideFileSearch'''(const Name, DirList: WideString): WideString; <br />
| Search through the directories passed in '''DirList''' for a file named '''Name'''. DirList is a list of path names delimited by semicolons. If file matching Name is located, function returns a string specifying a path name for that file. If no matching file exists, function returns an empty string.<br />
|-<br />
| procedure '''WideScanDirForFiles'''(const Dir: WideString; var Files: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString); <br />
| You can get a list of the files inside a folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Files''': Where the list of files is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden files?<br />
*'''IncludeSystem''': Do you want to list the system files?<br />
*'''Mask''': List only the files which match a [[ReNamer:Masks|wildcard mask]], or specify an empty string to list all files.<br />
|-<br />
| procedure '''WideScanDirForFolders'''(const Dir: WideString; var Folders: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean); <br />
| You can get a list of the folders inside other folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Folders''': Where the list of folders is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden folders?<br />
*'''IncludeSystem''': Do you want to list the system folders?<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Name Utilities ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideExtractFilePath'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", including the trailing path delimiter, e.g. "C:\Folder\".<br />
|-<br />
| function '''WideExtractFileDir'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", excluding the trailing path delimiter, e.g. "C:\Folder".<br />
|-<br />
| function '''WideExtractFileDrive'''(const FileName: WideString): WideString; <br />
| Returns the drive letter, e.g. "C:".<br />
|-<br />
| function '''WideExtractFileName'''(const FileName: WideString): WideString; <br />
| Returns the filename with extension, e.g. "FileName.txt".<br />
|-<br />
| function '''WideExtractBaseName'''(const FileName: WideString): WideString; <br />
| Returns the base name of the file, i.e. file name without extension and path components.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| Document<br />
|}<br />
<br />
|-<br />
| function '''WideExtractFileExt'''(const FileName: WideString): WideString; <br />
| Returns the file's extension with the dot, e.g. ".txt".<br />
|-<br />
| function '''WideChangeFileExt'''(const FileName, Extension: WideString): WideString; <br />
| Replaces the original extension, and returns the new filename with extension, e.g. "FineName.txt" -&gt; "FineName.pdf".<br />
|-<br />
| function '''WideStripExtension'''(const FileName: WideString): WideString; <br />
| Strips off the extension from the filename, maintaining the path component unaffected.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| C:\Folder\Document<br />
|}<br />
<br />
|-<br />
| function '''WideExpandFileName'''(const FileName: WideString): WideString; <br />
| Converts the relative file name into a fully qualified path. This function does not verify that the resulting path refers to an existing file.<br />
|-<br />
| function '''WideExtractRelativePath'''(const BaseName, DestName: WideString): WideString; <br />
| Creates a relative path to go from '''BaseName''' to '''DestName'''. For example:<br />
<br />
{|<br />
| '''BaseName:'''<br />
| <nowiki>C:\Folder\FileName.txt</nowiki><br />
|-<br />
| '''DestName:'''<br />
| <nowiki>C:\Documents\Article.pdf</nowiki><br />
|-<br />
| '''Result:'''<br />
| <nowiki>..\Documents\Article.pdf</nowiki><br />
|}<br />
<br />
|-<br />
| function '''WideExtractShortPathName'''(const FileName: WideString): WideString; <br />
| It converts a path into it's representation in DOS format.<br />
|-<br />
| function '''WideIncludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a folder '''contains''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideExcludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a file does '''not contain''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideSameFileName'''(const FileName1, FileName2: WideString): Boolean;<br />
| Compares the filenames '''FileName1''' and '''FileName2''', and returns ''TRUE'' if they are considered to be same.<br />
<br />
Note that filenames on Windows platform are case insensitive for comparison purposes, but case preserving when creating new files.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMask'''(const FileName, Mask: WideString): Boolean;<br />
| Check if '''FileName''' matches a [[ReNamer:Masks|wildcard mask]] '''Mask'''. Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask <code>*.txt</code> matches files with a <code>.txt</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMaskList'''(const FileName, MaskList: WideString): Boolean;<br />
| Check if '''FileName''' matches any of the [[ReNamer:Masks|wildcard masks]] listed in '''MaskList'''. The list of masks is separated by semicolons (";"). Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask list <code>*.txt;*.doc</code> matches files with a <code>.txt</code> or <code>.doc</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Read/Write ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileReadFragment'''(const FileName: WideString; Start, Length: Integer): String; <br />
| Starting at position '''Start''', read '''Length''' number of characters of the file '''FileName''' and return them as a string. '''Start''' is 0-based, so in order to start the fragment at the beginning of the file, set this parameter to 0 (zero).<br />
|-<br />
| function '''FileReadLines'''(const FileName: WideString): TAnsiStringArray;<br />
| Read all lines from a file '''FileName'''.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''FileReadLine'''(const FileName: WideString; LineNum: Integer): String; <br />
| Read a line from a file '''FileName''' specified by a line index '''LineNum'''. '''LineNum''' is 1 based, so to get the first line set this parameter to 1 (one).<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileCountLines'''(const FileName: WideString): Integer; <br />
| Count number of lines in the file.<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileReadContent'''(const FileName: WideString): String; <br />
| Return the entire content of the file as a String.<br />
|-<br />
| procedure '''FileWriteContent'''(const FileName: WideString; const Content: String); <br />
| Write '''Content''' to the file. If target file already exists, it will be overwritten.<br />
|-<br />
| procedure '''FileAppendContent'''(const FileName: WideString; const Content: String); <br />
| Append '''Content''' to the end of the file. If target file does not exist, it will be created.<br />
|-<br />
| function '''FileReadText'''(const FileName: WideString): WideString;<br />
| Read text from a file, performing automatic text encoding handling.<br/>''Added in v6.6.0.6 Beta.''<br />
|-<br />
| function '''FileReadTextLines'''(const FileName: WideString): TWideStringArray;<br />
| Read lines of text from a file, performing automatic text encoding handling.<br/>''Added in v6.7.0.1 Beta.''<br />
|}<br />
<br />
Note: Automatic text encoding handling is based on [https://en.wikipedia.org/wiki/Byte_order_mark byte order mark] (BOM) and supports UTF-8, UTF-16BE and UTF-16LE. If no BOM found then text is interpreted as ANSI encoding.<br />
<br />
{{Top}}<br />
<br />
== File Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileTimeModified'''(const FileName: WideString): TDateTime; <br />
| Returns last modified time of the specified file.<br />
|-<br />
| function '''FileTimeCreated'''(const FileName: WideString): TDateTime; <br />
| Returns creation time of the specified file.<br />
|-<br />
| function '''SetFileTimeCreated'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets creation time for the specified file.<br />
|-<br />
| function '''SetFileTimeModified'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets last modified time for the specified file.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Meta Tags Extraction ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''CalculateMetaTag'''(const FilePath: WideString; const MetaTagName: String): WideString; <br />
| Extracts and returns the value of a meta tag specified by '''MetaTagName''' from the file specified by the complete absolute path '''FilePath'''.<br/>''Return type changed from String to WideString in v5.74.4 Beta.''<br />
|-<br />
| function '''CalculateMetaTagFormat'''(const FilePath: WideString; const MetaTagName, DateTimeFormat: String): WideString;<br />
| Same as '''CalculateMetaTag''' except an additional parameter '''DateTimeFormat''' is provided to specify custom Date/Time format to be used instead of the application's default setting.<br/>''Added in v5.74.4 Beta.''<br />
|}<br />
<br />
For example, to extract '''EXIF_Date''' tag from an image and set it to the filename using the default date/time formatting:<br />
<syntaxhighlight lang="pascal"><br />
begin<br />
FileName := CalculateMetaTag(FilePath, 'EXIF_Date');<br />
end.<br />
</syntaxhighlight><br />
<br />
The full list of meta tags can be found in [[ReNamer:Meta Tags|Meta Tags]] article. For help with date/time formatting refer to [[ReNamer:Date and Time format|Date and Time format]].<br />
<br />
{{Top}}<br />
<br />
== Regular Expressions ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsMatchingRegEx'''(const Input, Pattern: WideString; const CaseSensitive: Boolean): Boolean;<br />
| Check for a match against a RegEx pattern.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''ReplaceRegEx'''(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString; <br />
| Find and replace all RegEx pattern matches. Works like the [[ReNamer:Rules:RegEx|Regular Expressions rule]].<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''Replace''' - The replacement pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''UseSubstitution''' - Substitute [[ReNamer:Regular Expressions#Backreferences|backreferences]] in the replacement pattern.<br />
|-<br />
| function '''FindRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean; out Positions: TIntegerArray; out Matches: TWideStringArray): Integer;<br />
| Find matches and positions of a RegEx pattern. Returns the number of matches.<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''Positions''' - Receives a list of positions where the matches have been found.<br />
* '''Matches''' - Receives a list of matches.<br />
<br />
''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''MatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| Returns a list of RegEx matches as an array. Function returns an array of full matches, which matched the entire expression, not the sub-patterns.<br />
|-<br />
| function '''SubMatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| This function is very similar to '''MatchesRegEx''', but instead of returning full matches it will return an array of sub-expression matches for the '''first''' full match.<br />
<br />
In this way, it can easily be combined with '''MatchesRegEx''' function, to allow users to find all global matches, and then parse those matches through '''SubMatchesRegEx''' function to find individual sub-expression matches of each global match.<br />
|}<br />
<br />
Example input and matches for '''MatchesRegEx''' and '''SubMatchesRegEx''' functions:<br />
<br />
{| class="wikitable"<br />
|-<br />
! Input <br />
! Find<br />
! MatchesRegEx matches<br />
! SubMatchesRegEx matches<br />
|-<br />
| A1_B2_C3 <br />
| [A-Z]\d<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| ''(empty)''<br />
|-<br />
| A1_B2_C3 <br />
| ([A-Z])(\d)<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| <br />
* A<br />
* 1<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Process Execution ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''ShellOpenFile'''(const FileName: WideString): Boolean; <br />
| Run (open) a file specified by '''FileName'''. Works like "Start &gt; Run" command. Parameter does not have to be an executable file, it can by any file or protocol with assigned handler. For example, you can open a Word document or a web page, and associated application will be launched:<br />
* <tt><nowiki>ShellOpenFile('http://www.den4b.com/');</nowiki></tt><br />
* <tt><nowiki>ShellOpenFile('C:\Document.doc');</nowiki></tt><br />
<br />
'''Beware:''' This function will evaluate the command for the appropriate way of execution which may sometimes lead to unexpected results. For example when executing ''ShellOpenFile('notepad')'' it could actually run a ''Windows Notepad'' application normally located in "''C:\Windows\notepad.exe''", or some other "''notepad.exe''" file located on the search path (''%PATH%''), or even open "''notepad''" folder located in the current working directory.<br />
|-<br />
| function '''ExecuteProgram'''(const Command: String; WaitForProgram: Boolean): Cardinal; <br />
| Execute a command specified by '''Command''' parameter. Parameter '''WaitForProgram''' allows you to specify whether the code needs to wait until the command (launched program) has finished executing.<br />
|-<br />
| function '''ExecuteProgramShow'''(const Command: String; WaitForProgram: Boolean; ShowWindowFlag: Word): Cardinal;<br />
| Execute a command specified by '''Command''' parameter. '''WaitForProgram''' parameter allows you to specify whether the code needs to wait until the command (launched program) has finished executing. '''ShowWindowFlag''' parameter controls how the window is to be shown.<br />
<br />
Commonly used values for '''ShowWindowFlag''' parameter: <br />
* 0 = Hide the window.<br />
* 1 = Activate and display the window.<br />
* 2 = Activate the window and display it minimized.<br />
* 3 = Activate the window and display it maximized.<br />
* 4 = Display the window, but do not activate it.<br />
* 7 = Display the window minimized, but do not activate it.<br />
* More information: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx ShowWindow Windows API function].<br />
<br />
''Added in v5.75.3 Beta.''<br />
|-<br />
| function '''ExecConsoleApp'''(const CommandLine: String; out Output: String): Cardinal; <br />
| Execute a command line specified by '''CommandLine''' parameter and capture its standard output in the '''Output''' variable. This function should be used only for console style applications. Returns the exit code.<br />
<br />
Console application output uses OEM-defined character set by default, unless application itself changes its output code page. '''OemToAnsi''' and '''OemToWide''' functions can be used to convert OEM output.<br />
<br />
Prior to ''v6.6.0.2 Beta'', OEM to ANSI conversion was automatically applied to the console output. As of ''v6.6.0.2 Beta'', the console output is returned "as is" without any modifications, so to prevent corruption of binary or non-OEM encoded output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Dialogs ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''ShowMessage'''(const Msg: String); <br />
| Show a simple dialog with the message specified by '''Msg''' parameter.<br />
|-<br />
| procedure '''WideShowMessage'''(const Msg: WideString); <br />
| Same as '''ShowMessage''' function but parameter is Unicode text.<br />
|-<br />
| function '''DialogYesNo'''(const Msg: String): Boolean; <br />
| Show a simple prompt with the message specified by '''Msg''' parameter and two button: Yes and No. Returns TRUE if user clicks Yes button, otherwise FALSE.<br />
|-<br />
| function '''WideDialogYesNo'''(const Msg: WideString): Boolean; <br />
| Same as '''DialogYesNo''' function but parameter is WideString text.<br />
|-<br />
| function '''InputBox'''(const ACaption, APrompt, ADefault: String): String; <br />
| Displays a simple dialog box with the given '''ACaption''' and '''APrompt''' message. It asks the user to enter data in a text box on the dialog. A '''ADefault''' value is displayed in the text box initially. If the user presses OK, the value from the text box is returned, otherwise '''ADefault''' value is returned.<br />
|-<br />
| function '''InputQuery'''(const ACaption, APrompt: String; var Value: String): Boolean; <br />
| Operates similar to '''InputBox''' function. The default value and the value of the text box after the dialog is closed are transferred via the '''Value''' parameter. Function returns TRUE is user clicked OK, otherwise returns FALSE.<br />
|-<br />
| function '''WideInputBox'''(const ACaption, APrompt, ADefault: WideString): WideString; <br />
| Same as '''InputBox''' function but operates on WideString text.<br />
|-<br />
| function '''WideInputQuery'''(const ACaption, APrompt: WideString; var Value: WideString): Boolean; <br />
| Same as '''InputQuery''' function but operates on WideString text.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Application ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''GetApplicationPath''': WideString;<br />
| Return full path to the application, for example: "C:\Program Files\ReNamer\ReNamer.exe".<br />
|-<br />
| function '''GetApplicationParams''': TWideStringArray;<br />
| Return an array of command line parameters which were supplied to the application at launch.<br />
|-<br />
| function '''GetCurrentFileIndex''': Integer;<br />
| Get index of the current file. Index ranges from '''1''' to '''GetTotalNumberOfFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfFiles''': Integer;<br />
| Get total number of files in the application.<br />
|-<br />
| function '''GetCurrentMarkedFileIndex''': Integer;<br />
| Get index of the current file, counting only ''marked'' files. Index ranges from '''1''' to '''GetTotalNumberOfMarkedFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfMarkedFiles''': Integer;<br />
| Get total number of ''marked'' files in the application.<br />
|-<br />
| function '''GetAllFiles''': TWideStringArray;<br />
| Get file paths of all available files. ''Added in v5.74.2 Beta.''<br />
|-<br />
| function '''GetMarkedFiles''': TWideStringArray;<br />
| Get file paths of all marked files. ''Added in v5.74.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== System ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideGetCurrentDir''': WideString; <br />
| Returns the current working directory.<br />
|-<br />
| function '''WideSetCurrentDir'''(const Dir: WideString): Boolean; <br />
| Sets the current working directory to the directory specified by parameter '''Dir'''.<br />
|-<br />
| function '''WideGetTempPath''': WideString;<br />
| Returns system defined temporary directory. If returned value is empty it means that temporary folder could not be determined.<br />
|-<br />
| function '''WideGetEnvironmentVar'''(const VarName: WideString): WideString; <br />
| Returns an environment variable by its name. For example:<br />
<syntaxhighlight lang="pascal"><br />
var<br />
UserName, ComputerName: WideString;<br />
begin<br />
UserName := WideGetEnvironmentVar('USERNAME');<br />
ComputerName := WideGetEnvironmentVar('COMPUTERNAME');<br />
end.<br />
</syntaxhighlight><br />
|}<br />
<br />
{{Top}}<br />
<br />
== Miscellaneous ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''Error'''(const Message: String);<br />
| Abruptly terminate the script with an error message.<br/>''Added in v7.2.0.7 Beta.''<br />
|-<br />
| procedure '''Sleep'''(Milliseconds: Cardinal); <br />
| Sleep (pause the execution) for specified number of '''Milliseconds'''.<br />
|-<br />
| procedure '''DivMod'''(Dividend: Integer; Divisor: Word; var Result, Remainder: Word); <br />
| Perform integer division and fetch the remainder as well, all in one operation. '''Dividend''' is the integer into which you are dividing. '''Divisor''' is the value by which to divide '''Dividend'''. '''Result''' returns the result of the integer division. '''Remainder''' returns the remainder (the difference between Result * Divisor and Dividend).<br />
|-<br />
| procedure '''Randomize'''; <br />
| Prepares the random number generator.<br />
'''Note:''' Should only be called once per application cycle, at the start of the process!<br />
|-<br />
| function '''RandomRange'''(const AFrom, ATo: Integer): Integer; <br />
| Return a random integer number within the specified range from '''AFrom''' (inclusive) to '''ATo''' (non-inclusive).<br />
|-<br />
| function '''RandomFloat''': Extended;<br />
| Return a random floating point value between 0.0 (including) and 1.0 (excluding).<br/>''Added in v6.2.0.8 Beta.''<br />
|- <br />
| function '''RandomBoolean''': Boolean;<br />
| Return a random boolean value, either ''True'' or ''False''.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''RandomString'''(Len: Integer; const Chars: String): String;<br />
| Generate a random string of length '''Len''' using characters selected at random from a string '''Chars'''.<br/>''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''MinInt'''(const A, B: Integer): Integer;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinInt64'''(const A, B: Int64): Int64;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinFloat'''(const A, B: Extended): Extended;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt'''(const A, B: Integer): Integer;<br />
| Return the largest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt64'''(const A, B: Int64): Int64;<br />
| Return the largest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxFloat'''(const A, B: Extended): Extended;<br />
| Return the largest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''GetClipboardText''': WideString; <br />
| Get the content of the the clipboard (text only).<br />
|-<br />
| procedure '''SetClipboardText'''(const S: WideString); <br />
| Set the content of the the clipboard (text only).<br />
|-<br />
| function '''Base64Encode'''(const S: String): String; <br />
| Encode string '''S''' into [http://en.wikipedia.org/wiki/Base64 Base64]. Useful for encoding binary data in order to minimize the likelihood of data being modified in transit through different systems, like email or internet.<br />
|-<br />
| function '''Base64Decode'''(const S: String): String; <br />
| Decode [http://en.wikipedia.org/wiki/Base64 Base64] encoded string.<br />
|-<br />
| function '''URLDecode'''(const Str: String; UsePlusAsSpace: Boolean): WideString;<br />
| Decode URL encoded string. All occurrences of ''%XX'' hex format are decoded, then entire string is decoded from UTF8.<br />
<br />
Optionally, plus signs ("+") can be interpreted as white space by enabling '''UsePlusAsSpace''' parameter, for compatibility with some encoders such as in [http://php.net/manual/en/function.urlencode.php PHP].<br />
<br />
''Added in v5.74.4 Beta. UsePlusAsSpace parameter added in v6.7.0.1 Beta.''<br />
|-<br />
| function '''URLEncode'''(const Str: WideString; UsePlusAsSpace: Boolean): String;<br />
| Encode string using URL encoding. Input string is encoded with UTF8, then all characters except digits and Latin letters are encoded in ''%XX'' hex format.<br />
<br />
Optionally, white spaces can be encoded as plus signs ("+") by enabling '''UsePlusAsSpace''' parameter, for compatibility with some decoders such as in [http://php.net/manual/en/function.urldecode.php PHP].<br />
<br />
''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''GetTickCount''': Cardinal; <br />
| Retrieves the number of milliseconds that have elapsed since the system was started (up to 49.7 days, then timer resets). The precision of this timer is very limited.<br />
|-<br />
| function '''SizeOf'''(X): Integer; <br />
| Pass a variable reference to determine the number of bytes used to represent the variable. Pass a type identifier to determine the number of bytes used to represent instances of that type.<br />
|}<br />
<br />
{{Top}}<br />
<br />
[[Category:ReNamer]]<br />
[[Category:Pascal Script]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script:Functions&diff=3498ReNamer:Pascal Script:Functions2022-09-15T13:13:56Z<p>Den4b: /* Regular Expressions */ FindRegEx added</p>
<hr />
<div>{{Go|up=ReNamer:Pascal Script|prev=ReNamer:Pascal Script:Types}}<br />
<br />
ReNamer has many functions to manipulate the entities related to file names and do some more complex tasks for individual files. These entities may be derived from the existing filename, path, system date, meta tags from the file, strings entered by the user, etc. This functionality is available for use via the [[ReNamer:Rules:PascalScript|PascalScript rule]].<br />
<br />
The difference between a "function" and a "procedure" is that while a function executes an algorithm and returns a value, a procedure just executes an algorithm without returning anything.<br />
<br />
A common "Wide" prefix in function names indicates that the function deals with '''WideString''' type rather than '''AnsiString''' or '''String''' type. For example, ''ShowMessage'' and ''WideShowMessage'' procedures. See the [[ReNamer:Pascal_Script:Types#String_types|String Types]] for more information.<br />
<br />
== Basic String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''Insert'''(Source: String; var S: String; Index: Integer); <br />
| Inserts the string '''S''' into string '''Source''' at position '''Index'''.<br />
|-<br />
| procedure '''Delete'''(var S: String; Index, Count: Integer); <br />
| Deletes '''Count''' characters from the string '''S''', starting from position '''Index'''.<br />
|-<br />
| function '''Copy'''(S: String; Index, Count: Integer): String; <br />
| Copies '''Count''' characters from string '''S''', starting at position '''Index''', and returns them as a new string.<br />
|-<br />
| function '''Pos'''(Substr: String; S: String): Integer; <br />
| Returns the position of a string '''Substr''' in another string '''S'''.<br />
|}<br />
<br />
'''Note:''' Indexes of characters in strings are 1 based, so first character in string S would be S[1].<br />
<br />
{{Top}}<br />
<br />
== Length Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''SetLength'''(var S: Array; NewLength: Integer); <br />
| Sets the length of array variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: String; NewLength: Integer); <br />
| Sets the length of string variable '''S''' to '''NewLength'''.<br />
|-<br />
| procedure '''SetLength'''(var S: WideString; NewLength: Integer); <br />
| Sets the length of widestring '''S''' to '''NewLength'''.<br />
|-<br />
| function '''Length'''(const S: Array): Integer; <br />
| Returns the length of array '''S ''' (number of elements).<br />
|-<br />
| function '''Length'''(const S: String): Integer; <br />
| Returns the length of string '''S''' (number of characters).<br />
|-<br />
| function '''Length'''(const S: WideString): Integer;<br />
| Returns the length of WideString '''S''' (number of characters).<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide String Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Routine<br />
! Remarks<br />
|-<br />
| procedure '''WideInsert'''(const Substr: WideString; var Dest: WideString; Index: Integer); <br />
| Inserts '''Substr''' in '''Dest''' at position '''Index'''.<br />
|-<br />
| procedure '''WideDelete'''(var S: WideString; Index, Count: Integer); <br />
| Deletes '''Count''' characters from '''S''', starting from the '''Index''' position.<br />
|-<br />
| procedure '''WideDeleteRight'''(var S: WideString; Index, Count: Integer);<br />
| Delete '''Count''' characters from '''S''', starting from the '''Index''' position from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| procedure '''WideSetLength'''(var S: WideString; NewLength: Integer); <br />
| Change the length of string '''S''' to a new length specified by '''NewLength'''. If new length is smaller than original, the string is truncated. If new length is greater than original, the string will be expanded but additional characters will not be initialized and can be anything.<br />
|-<br />
| function '''WideLength'''(const S: WideString): Integer; <br />
| Returns the length of WideString '''S'''.<br />
|-<br />
| function '''WideCopy'''(const S: WideString; Index, Count: Integer): WideString; <br />
| Returns '''Count''' characters from '''S''', starting at position '''Index'''.<br />
|-<br />
| function '''WideCopyRight'''(const S: WideString; Index, Count: Integer): WideString;<br />
| Returns '''Count''' characters from '''S''', starting at position '''Index''' from the end and counting towards the start.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WidePos'''(const SubStr, S: WideString): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WidePosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer; <br />
| Find and occurrence of '''SubStr''' in '''S''' but start searching from position specified by '''Offset'''. Returns the position of first occurrence, or '''0''' if nothing was found.<br />
|-<br />
| function '''WideUpperCase'''(const S: WideString): WideString; <br />
| Returns the ALLCAPS version of the WideString '''S'''<br />
|-<br />
| function '''WideLowerCase'''(const S: WideString): WideString; <br />
| Returns the lowercase version of the WideString '''S'''<br />
|-<br />
| function '''WideCompareStr'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-sensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideCompareText'''(const S1, S2: WideString): Integer; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive, and returns an integer based on the result. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2.<br />
|-<br />
| function '''WideSameText'''(const S1, S2: WideString): Boolean; <br />
| Compares two WideStrings '''S1''' and '''S2''', case-insensitive. Returns TRUE if both are identical, otherwise returns FALSE.<br />
|-<br />
| function '''WideTextPos'''(const SubStr, S: WideString): Integer; <br />
| Behaves like '''WidePos''' function, except text if processed in case-insensitive manner.<br />
|-<br />
| function '''WideTextPosEx'''(const SubStr, S: WideString; Offset: Cardinal): Integer;<br />
| Behaves like '''WidePosEx''' function, except text if processed in case-insensitive manner.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideTrim'''(const S: WideString): WideString; <br />
| Removes leading and trailing spaces and control characters from the given string '''S'''.<br />
|-<br />
| function '''WideTrimChars'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning and the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsLeft'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the beginning of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideTrimCharsRight'''(const S, CharsToTrim: WideString): WideString;<br />
| Remove characters that occur in '''CharsToTrim''' from the end of '''S'''.<br />
<br />
''Added in v6.0.0.9 Alpha.''<br />
|-<br />
| function '''WideReverseString'''(const S: WideString): WideString;<br />
| Return a reversed version of string '''S''', i.e. reverse the order of characters.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideRepeatString'''(const S: WideString; Count: Integer): WideString;<br />
| Repeat a string a number of times.<br/>''Added in v6.9.0.3 Beta.''<br />
<br />
|-<br />
| function '''WideReplaceStr'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-sensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
<br />
|-<br />
| function '''WideReplaceText'''(const S, OldPattern, NewPattern: WideString): WideString; <br />
| Return a result of a ''case-insensitive'' replacement of all occurrences of '''OldPattern''' with '''NewPattern''' in a string '''S'''.<br />
|-<br />
| function '''WideSplitString'''(const Input, Delimiter: WideString): TWideStringArray; <br />
| <br />
Splits the '''Input''' wherever '''Delimiter''' occurs and returns an array that contains the split parts. <br />
<br />
*The '''Delimiter''' itself can be a multi-character WideString. <br>(Unlike the usual comma, hyphen or space that are used for this purpose) <br />
*The split parts (returned as elements of the array) do not contain the '''Delimiter'''.<br />
<br />
|-<br />
|-<br />
| function '''WideJoinStrings'''(const Strings: TWideStringArray; const Delimiter: WideString): WideString;<br />
| Joins all individual items from '''Strings''' into a single WideString, with '''Delimiter''' inserted between the joined items.<br />
<br />
|-<br />
| function '''WideCaseSentence'''(const S: WideString): WideString; <br />
| Returns a ''Sentence case'' version of parameter '''S'''. <br />
<br />
Only the first alphabetic character is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
''Added in v6.0.0.3 Alpha''.<br />
|-<br />
| function '''WideCaseCapitalize'''(const S: WideString): WideString; <br />
| <br />
Returns the ''Title case'' version of parameter '''S'''. <br />
<br />
First letter of every word is capitalized. All other alphabetic characters are converted to lowercase.<br />
<br />
|-<br />
| function '''WideCaseInvert'''(const S: WideString): WideString; <br />
| Inverts case of all characters in '''S''' and returns it.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Wide Character Handling ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsWideCharUpper'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in upper case.<br />
|-<br />
| function '''IsWideCharLower'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is in lower case.<br />
|-<br />
| function '''IsWideCharDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a digit (numeric character 0-9). <br />
|-<br />
| function '''IsWideCharSpace'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a white-space character, such as: space, form-feed, newline, carriage-return, tab and vertical-tab (characters classified as C1_SPACE).<br />
|-<br />
| function '''IsWideCharPunct'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a punctuation mark (characters classified as C1_PUNCT).<br />
|-<br />
| function '''IsWideCharCntrl'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a control character (characters classified as C1_CNTRL).<br />
|-<br />
| function '''IsWideCharBlank'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a blank, such as: space and tab (characters classified as C1_BLANK).<br />
|-<br />
| function '''IsWideCharXDigit'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a hexadecimal digit (0-9 or A-F).<br />
|-<br />
| function '''IsWideCharAlpha'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character (a-z or A-Z).<br />
|-<br />
| function '''IsWideCharAlphaNumeric'''(WC: WideChar): Boolean; <br />
| Checks character '''WC''' and returns TRUE if it is a alphanumeric character or a numeric character (a-z, A-Z or 0-9).<br />
|-<br />
| function '''IsWideWordBoundaryLeft'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the left.<br />
<br />
Conditions that qualify as word boundaries to the left of character:<br />
# If first character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.'' <br />
|-<br />
| function '''IsWideWordBoundaryRight'''(const Subject: WideString; CharPosition: Integer): Boolean;<br />
| Check if a character at the specified position is on a word boundary to the right.<br />
<br />
Conditions that qualify as word boundaries to the right of character:<br />
# If last character and is a word character.<br />
# Between word and not a word character.<br />
<br />
''Added in v6.6.0.1 Beta.''<br />
|-<br />
| function '''WideCharUpper'''(const WC: WideChar): WideChar; <br />
| Returns an upper case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideCharLower'''(const WC: WideChar): WideChar; <br />
| Returns a lower case version of the input character. In case of non-alphabetic character, it returns the same character.<br />
|-<br />
| function '''WideChr'''(Code: Word): WideChar;<br />
| Create a character from a code point.<br/>''Added in v6.9.0.3 Beta.''<br />
|}<br />
<br />
'''Note:''' Character classifications, such as C1_UPPER, C1_LOWER, C1_DIGIT, C1_SPACE, C1_PUNCT, C1_CNTRL, C1_BLANK, C1_XDIGIT, C1_ALPHA - are part of Unicode definitions. More information regarding classification can be found on the internet. For example: [http://www.fileformat.info/info/unicode/ http://www.fileformat.info/info/unicode/].<br />
<br />
{{Top}}<br />
<br />
== Unicode Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideToAnsi'''(const WS: WideString): String; <br />
| Converts [[Unicode]] string to [[ANSI]] string, according to the system locale.<br />
|-<br />
| function '''AnsiToWide'''(const S: String): WideString; <br />
| Converts [[ANSI]] string to [[Unicode]] string, according to the system locale.<br />
|-<br />
| function '''UTF8Encode'''(const WS: WideString): String; <br />
| Convert WideString type to UTF-8 encoded string.<br/>Useful for storing Unicode strings in files, sometimes for compatibility reasons and sometimes to reduce the size of the file.<br />
|-<br />
| function '''UTF8Decode'''(const S: String): WideString;<br />
| Convert UTF-8 encoded string to WideString type.<br />
|}<br />
<br />
== Console Output Conversion ==<br />
<br />
OEM-defined character set is commonly used in the output of console applications.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''OemToAnsi'''(const S: String): String;<br />
| Convert OEM string into an ANSI string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''OemToWide'''(const S: String): WideString;<br />
| Convert OEM string into a WideString.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''AnsiToOem'''(const S: String): String;<br />
| Convert ANSI string into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|-<br />
| function '''WideToOem'''(const S: WideString): String; <br />
| Convert WideString into an OEM string.<br/>''Added in v6.6.0.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Basic Conversion ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''BoolToStr'''(B: Boolean): String;<br />
| Convert boolean variable into a string. Returns "''True''" or "''False''" string value.<br />
|-<br />
| function '''IntToStr'''(Value: Integer): String; <br />
| Converts an integer to a string. The following assumptions are correct:<br />
<div style="font-family: monospace"><br />
* IntToStr(123) = '123'<br />
* IntToStr(0123) = '123'<br />
* IntToStr(123) <> '0123'<br />
</div><br />
<b>Note:</b> Be cautious of supplying ''Int64'' type as a parameter as it will be type casted to ''Integer'', which significantly reduces the range of possible values (refer to [[ReNamer:Pascal Script:Types|Types]] for more information). You can use '''FormatFloat''' function to convert ''Int64'' values to a string without a loss of range.<br />
|-<br />
| function '''Int64ToStr'''(Value: Int64): String;<br />
| Same as '''IntToStr''' but takes in ''Int64'' typed parameter.<br />
|-<br />
| function '''StrToInt'''(const S: String): Integer; <br />
| Converts a string to an integer. The following equalities are correct:<br />
<div style="font-family: monospace"><br />
* StrToInt('123') = 123<br />
* StrToInt('123') = 0123<br />
* StrToInt('0123') = 123<br />
</div><br />
'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''StrToInt64'''(const S: String): Int64;<br />
| Same as '''StrToInt''' but returns ''Int64'' typed result.<br />
|-<br />
| function '''StrToIntDef'''(const S: String; const Default: Integer): Integer; <br />
| Behaves like '''StrToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''StrToInt64Def'''(const S: String; Default: Int64): Int64;<br />
| Same as '''StrToIntDef''' but operates with ''Int64'' type.<br />
|-<br />
| function '''TryStrToInt'''(const S: String; out Value: Integer): Boolean;<br />
| Converts a string to an integer, but does not throw an error when invalid string is supplied, unlike '''StrToInt'''. Returns ''False'' if conversion operation has failed.<br />
|-<br />
| function '''FloatToStr'''(Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using default system format.<br />
|-<br />
| function '''StrToFloat'''(const S: string): Extended;<br />
| Converts supplied string to a floating point value.<br>'''Warning:''' An error will occur if the parameter to this function cannot be converted to a floating point value!<br />
|-<br />
| function '''StrToFloatDef'''(const S: string; const Default: Extended): Extended;<br />
| Behaves like '''StrToFloat''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to a floating point value.<br />
|-<br />
| function '''FormatFloat'''(const Format: string; Value: Extended): string;<br />
| Converts supplied floating point value to its string representation, using user specific '''Format'''.<br/>Check [[#Floating point format specifiers|floating point format specifiers]] below for more information.<br />
|-<br />
| function '''DateToStr'''(D: TDateTime): String; <br />
| Converts a date to a string, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''StrToDate'''(const S: String): TDateTime; <br />
| Converts a date string to a proper TDateTime value, using system format for the short date, for example: '''dd/mm/yyyy'''.<br />
|-<br />
| function '''IntToHex'''(Value: Integer; Digits: Integer): String; <br />
| Converts an integer to its hexadecimal representation. Here are samples:<br />
<div style="font-family: monospace"><br />
* IntToHex(1234, 1) = '4D2'<br />
* IntToHex(1234, 8) = '000004D2'<br />
</div><br />
|-<br />
| function '''HexToInt'''(const HexNum: String): Integer; <br />
| Converts a hexadecimal value to its decimal representation.<br/>'''Warning:''' An error will occur if the parameter to this function cannot be converted to an integer!<br />
|-<br />
| function '''HexToIntDef'''(const HexNum: String; Default: Integer): Integer; <br />
| Behaves like '''HexToInt''' function, but instead of producing an error on incorrect input function allows the '''Default''' value to be specified, which will be returned if the input cannot be converted to an integer.<br />
|-<br />
| function '''Ord'''(X: Char): Byte; <br />
| Return an ordinal value (byte representation) of a character.<br />
|-<br />
| function '''Chr'''(X: Byte): Char; <br />
| Return a character by its ordinal value (byte representation).<br />
|}<br />
<br />
=== Floating point format specifiers ===<br />
<br />
{| class="wikitable"<br />
! Specifier<br />
! Represents<br />
|-<br />
| <tt>0</tt>&nbsp;(zero)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "0" appears in the format string, then that digit is copied to the output string. Otherwise, a "0" is stored in that position in the output string.<br />
|-<br />
| <tt>#</tt>&nbsp;(hash)<br />
| Digit placeholder. If the value being formatted has a digit in the position where the "#" appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string.<br />
|-<br />
| <tt>.</tt>&nbsp;(dot)<br />
| Decimal point. The first "." character in the format string determines the location of the decimal separator in the formatted value, any additional "." characters are ignored.<br />
|-<br />
| <tt>,</tt>&nbsp;(comma)<br />
| Thousand separator. If the format string contains one or more "," characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of "," characters in the format string does not affect the output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Date and Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''Date''': TDateTime; <br />
| Returns the current system date.<br />
|-<br />
| function '''Time''': TDateTime; <br />
| Returns the current system time.<br />
|-<br />
| function '''Now''': TDateTime; <br />
| Returns the current system date and time.<br />
|-<br />
| function '''EncodeDate'''(Year, Month, Day: Word): TDateTime; <br />
| Generates date value for the specified '''Year''', '''Month''', '''Day'''. Parameters must be within a valid date range: Year = 0..9999, Month = 1..12, Day = 1..31 (depending on month/year). An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeTime'''(Hour, Min, Sec, MSec: Word): TDateTime; <br />
| Generates time value for the specified '''Hour''', '''Min''', '''Sec''', '''MSec'''. Parameters must be within a valid time range: Hour = 0..23, Min = 0..59, Sec = 0..59, MSec = 0..999. An error will be raised if parameters are invalid.<br />
|-<br />
| function '''EncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word): TDateTime;<br />
| Generates date-time value for the specified components of date and time. Similar to '''EncodeDate''' and '''EncodeTime'''.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''TryEncodeDate'''(Year, Month, Day: Word; var Date: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeDate''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date value will be written in the '''Date''' variable.<br />
|-<br />
| function '''TryEncodeTime'''(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean; <br />
| Behaves exactly like '''EncodeTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated time value will be written in the '''Time''' variable.<br />
|-<br />
| function '''TryEncodeDateTime'''(Year, Month, Day, Hour, Minute, Second, MilliSecond: Word; out ADateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''EncodeDateTime''' function, except this function returns ''TRUE'' or ''FALSE'' depending on the success of the operation. If operation was successful, function will return ''TRUE'' and the generated date-time value will be written in the '''ADateTime''' variable.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| procedure '''DecodeDate'''(const DateTime: TDateTime; var Year, Month, Day: Word); <br />
| Extracts '''Year''', '''Month''' and '''Day''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeTime'''(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word); <br />
| Extracts '''Hour''', '''Min''', '''Sec''' and '''MSec''' components from a given '''DateTime''' value.<br />
|-<br />
| procedure '''DecodeDateTime'''(const DateTime: TDateTime; out Year, Month, Day, Hour, Minute, Second, MilliSecond: Word);<br />
| Similar to '''DecodeDate''' and '''DecodeTime''' but extracts both date and time components at once.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''ComposeDateTime'''(const Date, Time: TDateTime): TDateTime;<br />
| Combine date and time components into a single date-time value.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DateTimeToUnix'''(D: TDateTime): Int64;<br />
| Converts '''D''' value of type '''TDateTime''' to a Unix timestamp.<br />
|-<br />
| function '''UnixToDateTime'''(U: Int64): TDateTime; <br />
| Converts a Unix timestamp to a value of '''TDateTime''' type.<br />
|-<br />
| function '''FormatDateTime'''(const Format: String; DateTime: TDateTime): String;<br />
| Convert date and time value to a string using [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Format''' parameter. <br />
|-<br />
| function '''ScanDateTime'''(const Pattern, Subject: String): TDateTime;<br />
| Convert '''Subject''' string to a date and time value by parsing it according to the [[ReNamer:Date and Time format|Date and Time formatting]] specified in the '''Pattern''' parameter.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''TryScanDateTime'''(const Pattern, Subject: String; out DateTime: TDateTime): Boolean;<br />
| Behaves exactly like '''ScanDateTime''' function, except it suppresses errors and returns either ''TRUE'' or ''FALSE'' depending on the success of the operation.<br/>''Added in v7.1.0.3 Beta.''<br />
|-<br />
| function '''IncYear'''(const AValue: TDateTime; const ANumberOfYears: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of years (plus or minus).<br />
|-<br />
| function '''IncMonth'''(const AValue: TDateTime; ANumberOfMonths: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of months (plus or minus).<br />
|-<br />
| function '''IncWeek'''(const AValue: TDateTime; const ANumberOfWeeks: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of weeks (plus or minus).<br />
|-<br />
| function '''IncDay'''(const AValue: TDateTime; const ANumberOfDays: Integer): TDateTime; <br />
| Increments a TDateTime variable by a number of days (plus or minus).<br />
|-<br />
| function '''IncHour'''(const AValue: TDateTime; const ANumberOfHours: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of hours (plus or minus).<br />
|-<br />
| function '''IncMinute'''(const AValue: TDateTime; const ANumberOfMinutes: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of minutes (plus or minus).<br />
|-<br />
| function '''IncSecond'''(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of seconds (plus or minus).<br />
|-<br />
| function '''IncMilliSecond'''(const AValue: TDateTime; const ANumberOfMilliSeconds: Int64): TDateTime; <br />
| Increments a TDateTime variable by a number of milliseconds (plus or minus).<br />
|-<br />
| function '''SecondSpan'''(const ANow, AThen: TDateTime): Double;<br />
| Calculate the approximate number of seconds between two date-time values.<br/>''Added in v6.2.0.5 Beta.''<br />
|-<br />
| function '''DayOfWeek'''(const DateTime: TDateTime): Word; <br />
| Returns the day number of the week. Returned values: 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday.<br/>''Before v6.1 this function used to return 1=Sunday to 7=Saturday.''<br />
|-<br />
| function '''DayOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''DayOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the day number of the year.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfMonth'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the month.<br/>''Added in v6.1.''<br />
|-<br />
| function '''WeekOfYear'''(const DateTime: TDateTime): Word;<br />
| Returns the week number of the year.<br/>''Added in v6.1.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Management ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideFileSize'''(const FileName: WideString): Int64; <br />
| Returns the size of the file in bytes. If file does not exist "-1" is returned. The return value is of type ''Int64'' which can store the maximum file size of 9,223,372,036,854,775,807 bytes.<br />
|-<br />
| function '''WideFileExists'''(const FileName: WideString): Boolean; <br />
| Check whether specified file exists. Returns TRUE if file exists, otherwise FALSE.<br />
|-<br />
| function '''WideDirectoryExists'''(const Directory: WideString): Boolean; <br />
| Check whether specified directory exists. Returns TRUE if directory exists, otherwise FALSE.<br />
|-<br />
| function '''WideForceDirectories'''(const Dir: WideString): Boolean; <br />
| Makes sure that that all directories in the path exist. If they don't, function will try to create them, recursively. Returns TRUE if all folders exist or have been successfully created.<br />
|-<br />
| function '''WideCreateDir'''(const Dir: WideString): Boolean; <br />
| Create specified directory (non-recursive). Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideRemoveDir'''(const Dir: WideString): Boolean;<br />
| Remove a directory, if it is empty. Returns TRUE on success, otherwise FALSE.<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideDeleteFile'''(const FileName: WideString): Boolean; <br />
| Delete physical file from the disk. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideDeleteToRecycleBin'''(const FileName: WideString): Boolean;<br />
| Delete file or folder by placing it into the Recycle Bin. Returns TRUE on success, otherwise FALSE.<br />
<br />
'''Note:''' You must provide a full path to delete the file to the Recycle Bin (a quirk of Windows API).<br />
<br />
''Added in v6.4.0.1 Beta.''<br />
|-<br />
| function '''WideRenameFile'''(const OldName, NewName: WideString): Boolean; <br />
| Rename file from '''OldName''' to '''NewName'''. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideCopyFile'''(const FromFile, ToFile: WideString; FailIfExists: Boolean): Boolean;<br />
| Rename file from '''FromFile''' to '''ToFile'''. If '''FailIfExists''' flag is TRUE, file will not be copied when destination file already exists, otherwise, destination file will be overwritten. Returns TRUE on success, otherwise FALSE.<br />
|-<br />
| function '''WideFileSearch'''(const Name, DirList: WideString): WideString; <br />
| Search through the directories passed in '''DirList''' for a file named '''Name'''. DirList is a list of path names delimited by semicolons. If file matching Name is located, function returns a string specifying a path name for that file. If no matching file exists, function returns an empty string.<br />
|-<br />
| procedure '''WideScanDirForFiles'''(const Dir: WideString; var Files: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString); <br />
| You can get a list of the files inside a folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Files''': Where the list of files is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden files?<br />
*'''IncludeSystem''': Do you want to list the system files?<br />
*'''Mask''': List only the files which match a [[ReNamer:Masks|wildcard mask]], or specify an empty string to list all files.<br />
|-<br />
| procedure '''WideScanDirForFolders'''(const Dir: WideString; var Folders: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean); <br />
| You can get a list of the folders inside other folder.<br />
*'''Dir''': The folder you want to scan.<br />
*'''Folders''': Where the list of folders is going to be saved.<br />
*'''Recursive''': Do you want to scan the subfolders?<br />
*'''IncludeHidden''': Do you want to list the hidden folders?<br />
*'''IncludeSystem''': Do you want to list the system folders?<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Name Utilities ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideExtractFilePath'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", including the trailing path delimiter, e.g. "C:\Folder\".<br />
|-<br />
| function '''WideExtractFileDir'''(const FileName: WideString): WideString; <br />
| Returns the drive and directory portion from "FileName", excluding the trailing path delimiter, e.g. "C:\Folder".<br />
|-<br />
| function '''WideExtractFileDrive'''(const FileName: WideString): WideString; <br />
| Returns the drive letter, e.g. "C:".<br />
|-<br />
| function '''WideExtractFileName'''(const FileName: WideString): WideString; <br />
| Returns the filename with extension, e.g. "FileName.txt".<br />
|-<br />
| function '''WideExtractBaseName'''(const FileName: WideString): WideString; <br />
| Returns the base name of the file, i.e. file name without extension and path components.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| Document<br />
|}<br />
<br />
|-<br />
| function '''WideExtractFileExt'''(const FileName: WideString): WideString; <br />
| Returns the file's extension with the dot, e.g. ".txt".<br />
|-<br />
| function '''WideChangeFileExt'''(const FileName, Extension: WideString): WideString; <br />
| Replaces the original extension, and returns the new filename with extension, e.g. "FineName.txt" -&gt; "FineName.pdf".<br />
|-<br />
| function '''WideStripExtension'''(const FileName: WideString): WideString; <br />
| Strips off the extension from the filename, maintaining the path component unaffected.<br />
<br />
{|<br />
! Input<br />
! Output<br />
|-<br />
| Document.txt<br />
| Document<br />
|-<br />
| C:\Folder\Document.txt<br />
| C:\Folder\Document<br />
|}<br />
<br />
|-<br />
| function '''WideExpandFileName'''(const FileName: WideString): WideString; <br />
| Converts the relative file name into a fully qualified path. This function does not verify that the resulting path refers to an existing file.<br />
|-<br />
| function '''WideExtractRelativePath'''(const BaseName, DestName: WideString): WideString; <br />
| Creates a relative path to go from '''BaseName''' to '''DestName'''. For example:<br />
<br />
{|<br />
| '''BaseName:'''<br />
| <nowiki>C:\Folder\FileName.txt</nowiki><br />
|-<br />
| '''DestName:'''<br />
| <nowiki>C:\Documents\Article.pdf</nowiki><br />
|-<br />
| '''Result:'''<br />
| <nowiki>..\Documents\Article.pdf</nowiki><br />
|}<br />
<br />
|-<br />
| function '''WideExtractShortPathName'''(const FileName: WideString): WideString; <br />
| It converts a path into it's representation in DOS format.<br />
|-<br />
| function '''WideIncludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a folder '''contains''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideExcludeTrailingPathDelimiter'''(const S: WideString): WideString; <br />
| With this function you can ensure that a path for a file does '''not contain''' the path delimiter ("\") at the end of the path.<br />
|-<br />
| function '''WideSameFileName'''(const FileName1, FileName2: WideString): Boolean;<br />
| Compares the filenames '''FileName1''' and '''FileName2''', and returns ''TRUE'' if they are considered to be same.<br />
<br />
Note that filenames on Windows platform are case insensitive for comparison purposes, but case preserving when creating new files.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMask'''(const FileName, Mask: WideString): Boolean;<br />
| Check if '''FileName''' matches a [[ReNamer:Masks|wildcard mask]] '''Mask'''. Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask <code>*.txt</code> matches files with a <code>.txt</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''WideMatchesMaskList'''(const FileName, MaskList: WideString): Boolean;<br />
| Check if '''FileName''' matches any of the [[ReNamer:Masks|wildcard masks]] listed in '''MaskList'''. The list of masks is separated by semicolons (";"). Return ''TRUE'' if matches, otherwise ''FALSE''.<br />
<br />
For example, a mask list <code>*.txt;*.doc</code> matches files with a <code>.txt</code> or <code>.doc</code> extension.<br />
<br />
''Added in v6.7.0.4 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== File Read/Write ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileReadFragment'''(const FileName: WideString; Start, Length: Integer): String; <br />
| Starting at position '''Start''', read '''Length''' number of characters of the file '''FileName''' and return them as a string. '''Start''' is 0-based, so in order to start the fragment at the beginning of the file, set this parameter to 0 (zero).<br />
|-<br />
| function '''FileReadLines'''(const FileName: WideString): TAnsiStringArray;<br />
| Read all lines from a file '''FileName'''.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''FileReadLine'''(const FileName: WideString; LineNum: Integer): String; <br />
| Read a line from a file '''FileName''' specified by a line index '''LineNum'''. '''LineNum''' is 1 based, so to get the first line set this parameter to 1 (one).<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileCountLines'''(const FileName: WideString): Integer; <br />
| Count number of lines in the file.<br/>'''Note:''' This function is extremely inefficient and provided only for convenience!<br />
|-<br />
| function '''FileReadContent'''(const FileName: WideString): String; <br />
| Return the entire content of the file as a String.<br />
|-<br />
| procedure '''FileWriteContent'''(const FileName: WideString; const Content: String); <br />
| Write '''Content''' to the file. If target file already exists, it will be overwritten.<br />
|-<br />
| procedure '''FileAppendContent'''(const FileName: WideString; const Content: String); <br />
| Append '''Content''' to the end of the file. If target file does not exist, it will be created.<br />
|-<br />
| function '''FileReadText'''(const FileName: WideString): WideString;<br />
| Read text from a file, performing automatic text encoding handling.<br/>''Added in v6.6.0.6 Beta.''<br />
|-<br />
| function '''FileReadTextLines'''(const FileName: WideString): TWideStringArray;<br />
| Read lines of text from a file, performing automatic text encoding handling.<br/>''Added in v6.7.0.1 Beta.''<br />
|}<br />
<br />
Note: Automatic text encoding handling is based on [https://en.wikipedia.org/wiki/Byte_order_mark byte order mark] (BOM) and supports UTF-8, UTF-16BE and UTF-16LE. If no BOM found then text is interpreted as ANSI encoding.<br />
<br />
{{Top}}<br />
<br />
== File Time ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''FileTimeModified'''(const FileName: WideString): TDateTime; <br />
| Returns last modified time of the specified file.<br />
|-<br />
| function '''FileTimeCreated'''(const FileName: WideString): TDateTime; <br />
| Returns creation time of the specified file.<br />
|-<br />
| function '''SetFileTimeCreated'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets creation time for the specified file.<br />
|-<br />
| function '''SetFileTimeModified'''(const FileName: WideString; const DateTime: TDateTime): Boolean; <br />
| Sets last modified time for the specified file.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Meta Tags Extraction ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''CalculateMetaTag'''(const FilePath: WideString; const MetaTagName: String): WideString; <br />
| Extracts and returns the value of a meta tag specified by '''MetaTagName''' from the file specified by the complete absolute path '''FilePath'''.<br/>''Return type changed from String to WideString in v5.74.4 Beta.''<br />
|-<br />
| function '''CalculateMetaTagFormat'''(const FilePath: WideString; const MetaTagName, DateTimeFormat: String): WideString;<br />
| Same as '''CalculateMetaTag''' except an additional parameter '''DateTimeFormat''' is provided to specify custom Date/Time format to be used instead of the application's default setting.<br/>''Added in v5.74.4 Beta.''<br />
|}<br />
<br />
For example, to extract '''EXIF_Date''' tag from an image and set it to the filename using the default date/time formatting:<br />
<syntaxhighlight lang="pascal"><br />
begin<br />
FileName := CalculateMetaTag(FilePath, 'EXIF_Date');<br />
end.<br />
</syntaxhighlight><br />
<br />
The full list of meta tags can be found in [[ReNamer:Meta Tags|Meta Tags]] article. For help with date/time formatting refer to [[ReNamer:Date and Time format|Date and Time format]].<br />
<br />
{{Top}}<br />
<br />
== Regular Expressions ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''IsMatchingRegEx'''(const Input, Pattern: WideString; const CaseSensitive: Boolean): Boolean;<br />
| Check for a match against a RegEx pattern.<br/>''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''ReplaceRegEx'''(const Input, Find, Replace: WideString; const CaseSensitive, UseSubstitution: Boolean): WideString; <br />
| Find and replace all RegEx pattern matches. Works like the [[ReNamer:Rules:RegEx|Regular Expressions rule]].<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''Replace''' - The replacement pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''UseSubstitution''' - Substitute [[ReNamer:Regular Expressions#Backreferences|backreferences]] in the replacement pattern.<br />
|-<br />
| function '''FindRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean; out Positions: TIntegerArray; out Matches: TWideStringArray): Integer;<br />
| Find matches and positions of a RegEx pattern. Returns the number of matches.<br />
<br />
Parameters:<br />
* '''Input''' - The original subject text.<br />
* '''Find''' - The search pattern.<br />
* '''CaseSensitive''' - Search for the pattern in case-sensitive mode.<br />
* '''Positions''' - Receives a list of positions where the matches have been found.<br />
* '''Matches''' - Receives a list of matches.<br />
<br />
''Added in v7.3.0.4 Beta.''<br />
|-<br />
| function '''MatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| Returns a list of RegEx matches as an array. Function returns an array of full matches, which matched the entire expression, not the sub-patterns.<br />
|-<br />
| function '''SubMatchesRegEx'''(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray; <br />
| This function is very similar to '''MatchesRegEx''', but instead of returning full matches it will return an array of sub-expression matches for the '''first''' full match.<br />
<br />
In this way, it can easily be combined with '''MatchesRegEx''' function, to allow users to find all global matches, and then parse those matches through '''SubMatchesRegEx''' function to find individual sub-expression matches of each global match.<br />
|}<br />
<br />
Example input and matches for '''MatchesRegEx''' and '''SubMatchesRegEx''' functions:<br />
<br />
{| class="wikitable"<br />
|-<br />
! Input <br />
! Find<br />
! MatchesRegEx matches<br />
! SubMatchesRegEx matches<br />
|-<br />
| A1_B2_C3 <br />
| [A-Z]\d<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| ''(empty)''<br />
|-<br />
| A1_B2_C3 <br />
| ([A-Z])(\d)<br />
| <br />
* A1<br />
* B2<br />
* C3<br />
| <br />
* A<br />
* 1<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Process Execution ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''ShellOpenFile'''(const FileName: WideString): Boolean; <br />
| Run (open) a file specified by '''FileName'''. Works like "Start &gt; Run" command. Parameter does not have to be an executable file, it can by any file or protocol with assigned handler. For example, you can open a Word document or a web page, and associated application will be launched:<br />
* <tt><nowiki>ShellOpenFile('http://www.den4b.com/');</nowiki></tt><br />
* <tt><nowiki>ShellOpenFile('C:\Document.doc');</nowiki></tt><br />
<br />
'''Beware:''' This function will evaluate the command for the appropriate way of execution which may sometimes lead to unexpected results. For example when executing ''ShellOpenFile('notepad')'' it could actually run a ''Windows Notepad'' application normally located in "''C:\Windows\notepad.exe''", or some other "''notepad.exe''" file located on the search path (''%PATH%''), or even open "''notepad''" folder located in the current working directory.<br />
|-<br />
| function '''ExecuteProgram'''(const Command: String; WaitForProgram: Boolean): Cardinal; <br />
| Execute a command specified by '''Command''' parameter. Parameter '''WaitForProgram''' allows you to specify whether the code needs to wait until the command (launched program) has finished executing.<br />
|-<br />
| function '''ExecuteProgramShow'''(const Command: String; WaitForProgram: Boolean; ShowWindowFlag: Word): Cardinal;<br />
| Execute a command specified by '''Command''' parameter. '''WaitForProgram''' parameter allows you to specify whether the code needs to wait until the command (launched program) has finished executing. '''ShowWindowFlag''' parameter controls how the window is to be shown.<br />
<br />
Commonly used values for '''ShowWindowFlag''' parameter: <br />
* 0 = Hide the window.<br />
* 1 = Activate and display the window.<br />
* 2 = Activate the window and display it minimized.<br />
* 3 = Activate the window and display it maximized.<br />
* 4 = Display the window, but do not activate it.<br />
* 7 = Display the window minimized, but do not activate it.<br />
* More information: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx ShowWindow Windows API function].<br />
<br />
''Added in v5.75.3 Beta.''<br />
|-<br />
| function '''ExecConsoleApp'''(const CommandLine: String; out Output: String): Cardinal; <br />
| Execute a command line specified by '''CommandLine''' parameter and capture its standard output in the '''Output''' variable. This function should be used only for console style applications. Returns the exit code.<br />
<br />
Console application output uses OEM-defined character set by default, unless application itself changes its output code page. '''OemToAnsi''' and '''OemToWide''' functions can be used to convert OEM output.<br />
<br />
Prior to ''v6.6.0.2 Beta'', OEM to ANSI conversion was automatically applied to the console output. As of ''v6.6.0.2 Beta'', the console output is returned "as is" without any modifications, so to prevent corruption of binary or non-OEM encoded output.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Dialogs ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''ShowMessage'''(const Msg: String); <br />
| Show a simple dialog with the message specified by '''Msg''' parameter.<br />
|-<br />
| procedure '''WideShowMessage'''(const Msg: WideString); <br />
| Same as '''ShowMessage''' function but parameter is Unicode text.<br />
|-<br />
| function '''DialogYesNo'''(const Msg: String): Boolean; <br />
| Show a simple prompt with the message specified by '''Msg''' parameter and two button: Yes and No. Returns TRUE if user clicks Yes button, otherwise FALSE.<br />
|-<br />
| function '''WideDialogYesNo'''(const Msg: WideString): Boolean; <br />
| Same as '''DialogYesNo''' function but parameter is WideString text.<br />
|-<br />
| function '''InputBox'''(const ACaption, APrompt, ADefault: String): String; <br />
| Displays a simple dialog box with the given '''ACaption''' and '''APrompt''' message. It asks the user to enter data in a text box on the dialog. A '''ADefault''' value is displayed in the text box initially. If the user presses OK, the value from the text box is returned, otherwise '''ADefault''' value is returned.<br />
|-<br />
| function '''InputQuery'''(const ACaption, APrompt: String; var Value: String): Boolean; <br />
| Operates similar to '''InputBox''' function. The default value and the value of the text box after the dialog is closed are transferred via the '''Value''' parameter. Function returns TRUE is user clicked OK, otherwise returns FALSE.<br />
|-<br />
| function '''WideInputBox'''(const ACaption, APrompt, ADefault: WideString): WideString; <br />
| Same as '''InputBox''' function but operates on WideString text.<br />
|-<br />
| function '''WideInputQuery'''(const ACaption, APrompt: WideString; var Value: WideString): Boolean; <br />
| Same as '''InputQuery''' function but operates on WideString text.<br />
|}<br />
<br />
{{Top}}<br />
<br />
== Application ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''GetApplicationPath''': WideString;<br />
| Return full path to the application, for example: "C:\Program Files\ReNamer\ReNamer.exe".<br />
|-<br />
| function '''GetApplicationParams''': TWideStringArray;<br />
| Return an array of command line parameters which were supplied to the application at launch.<br />
|-<br />
| function '''GetCurrentFileIndex''': Integer;<br />
| Get index of the current file. Index ranges from '''1''' to '''GetTotalNumberOfFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfFiles''': Integer;<br />
| Get total number of files in the application.<br />
|-<br />
| function '''GetCurrentMarkedFileIndex''': Integer;<br />
| Get index of the current file, counting only ''marked'' files. Index ranges from '''1''' to '''GetTotalNumberOfMarkedFiles'''.<br />
|-<br />
| function '''GetTotalNumberOfMarkedFiles''': Integer;<br />
| Get total number of ''marked'' files in the application.<br />
|-<br />
| function '''GetAllFiles''': TWideStringArray;<br />
| Get file paths of all available files. ''Added in v5.74.2 Beta.''<br />
|-<br />
| function '''GetMarkedFiles''': TWideStringArray;<br />
| Get file paths of all marked files. ''Added in v5.74.2 Beta.''<br />
|}<br />
<br />
{{Top}}<br />
<br />
== System ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| function '''WideGetCurrentDir''': WideString; <br />
| Returns the current working directory.<br />
|-<br />
| function '''WideSetCurrentDir'''(const Dir: WideString): Boolean; <br />
| Sets the current working directory to the directory specified by parameter '''Dir'''.<br />
|-<br />
| function '''WideGetTempPath''': WideString;<br />
| Returns system defined temporary directory. If returned value is empty it means that temporary folder could not be determined.<br />
|-<br />
| function '''WideGetEnvironmentVar'''(const VarName: WideString): WideString; <br />
| Returns an environment variable by its name. For example:<br />
<syntaxhighlight lang="pascal"><br />
var<br />
UserName, ComputerName: WideString;<br />
begin<br />
UserName := WideGetEnvironmentVar('USERNAME');<br />
ComputerName := WideGetEnvironmentVar('COMPUTERNAME');<br />
end.<br />
</syntaxhighlight><br />
|}<br />
<br />
{{Top}}<br />
<br />
== Miscellaneous ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Function<br />
! Remarks<br />
|-<br />
| procedure '''Error'''(const Message: String);<br />
| Abruptly terminate the script with an error message.<br/>''Added in v7.2.0.7 Beta.''<br />
|-<br />
| procedure '''Sleep'''(Milliseconds: Cardinal); <br />
| Sleep (pause the execution) for specified number of '''Milliseconds'''.<br />
|-<br />
| procedure '''DivMod'''(Dividend: Integer; Divisor: Word; var Result, Remainder: Word); <br />
| Perform integer division and fetch the remainder as well, all in one operation. '''Dividend''' is the integer into which you are dividing. '''Divisor''' is the value by which to divide '''Dividend'''. '''Result''' returns the result of the integer division. '''Remainder''' returns the remainder (the difference between Result * Divisor and Dividend).<br />
|-<br />
| procedure '''Randomize'''; <br />
| Prepares the random number generator.<br />
'''Note:''' Should only be called once per application cycle, at the start of the process!<br />
|-<br />
| function '''RandomRange'''(const AFrom, ATo: Integer): Integer; <br />
| Return a random integer number within the specified range from '''AFrom''' (inclusive) to '''ATo''' (non-inclusive).<br />
|-<br />
| function '''RandomFloat''': Extended;<br />
| Return a random floating point value between 0.0 (including) and 1.0 (excluding).<br/>''Added in v6.2.0.8 Beta.''<br />
|- <br />
| function '''RandomBoolean''': Boolean;<br />
| Return a random boolean value, either ''True'' or ''False''.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''RandomString'''(Len: Integer; const Chars: String): String;<br />
| Generate a random string of length '''Len''' using characters selected at random from a string '''Chars'''.<br/>''Added in v6.7.0.4 Beta.''<br />
|-<br />
| function '''MinInt'''(const A, B: Integer): Integer;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinInt64'''(const A, B: Int64): Int64;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MinFloat'''(const A, B: Extended): Extended;<br />
| Return the smallest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt'''(const A, B: Integer): Integer;<br />
| Return the largest of two values '''A''' and '''B''' of ''Integer'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxInt64'''(const A, B: Int64): Int64;<br />
| Return the largest of two values '''A''' and '''B''' of ''Int64'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''MaxFloat'''(const A, B: Extended): Extended;<br />
| Return the largest of two values '''A''' and '''B''' of ''Extended'' type.<br/>''Added in v6.2.0.8 Beta.''<br />
|-<br />
| function '''GetClipboardText''': WideString; <br />
| Get the content of the the clipboard (text only).<br />
|-<br />
| procedure '''SetClipboardText'''(const S: WideString); <br />
| Set the content of the the clipboard (text only).<br />
|-<br />
| function '''Base64Encode'''(const S: String): String; <br />
| Encode string '''S''' into [http://en.wikipedia.org/wiki/Base64 Base64]. Useful for encoding binary data in order to minimize the likelihood of data being modified in transit through different systems, like email or internet.<br />
|-<br />
| function '''Base64Decode'''(const S: String): String; <br />
| Decode [http://en.wikipedia.org/wiki/Base64 Base64] encoded string.<br />
|-<br />
| function '''URLDecode'''(const Str: String; UsePlusAsSpace: Boolean): WideString;<br />
| Decode URL encoded string. All occurrences of ''%XX'' hex format are decoded, then entire string is decoded from UTF8.<br />
<br />
Optionally, plus signs ("+") can be interpreted as white space by enabling '''UsePlusAsSpace''' parameter, for compatibility with some encoders such as in [http://php.net/manual/en/function.urlencode.php PHP].<br />
<br />
''Added in v5.74.4 Beta. UsePlusAsSpace parameter added in v6.7.0.1 Beta.''<br />
|-<br />
| function '''URLEncode'''(const Str: WideString; UsePlusAsSpace: Boolean): String;<br />
| Encode string using URL encoding. Input string is encoded with UTF8, then all characters except digits and Latin letters are encoded in ''%XX'' hex format.<br />
<br />
Optionally, white spaces can be encoded as plus signs ("+") by enabling '''UsePlusAsSpace''' parameter, for compatibility with some decoders such as in [http://php.net/manual/en/function.urldecode.php PHP].<br />
<br />
''Added in v5.74.4 Beta.''<br />
|-<br />
| function '''GetTickCount''': Cardinal; <br />
| Retrieves the number of milliseconds that have elapsed since the system was started (up to 49.7 days, then timer resets). The precision of this timer is very limited.<br />
|-<br />
| function '''SizeOf'''(X): Integer; <br />
| Pass a variable reference to determine the number of bytes used to represent the variable. Pass a type identifier to determine the number of bytes used to represent instances of that type.<br />
|}<br />
<br />
{{Top}}<br />
<br />
[[Category:ReNamer]]<br />
[[Category:Pascal Script]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Long_paths&diff=3497ReNamer:Long paths2022-08-17T23:07:52Z<p>Den4b: /* Long paths in Windows */ Paths ending with a dot</p>
<hr />
<div>{{Up|ReNamer}}<br />
<br />
== Introduction ==<br />
<br />
The maximum length of paths and file/folder names is limited in every mainstream operating system and file system. The exact limits can vary significantly between systems. <br />
<br />
For example, in Windows 10 and earlier versions the maximum path length is limited to '''260 characters''' (MAX_PATH constant). In contrast, Linux imposes a limit of '''4096 bytes''' for full paths and '''255 bytes''' for file names. Older systems imposed even stricter limits, like [https://en.wikipedia.org/wiki/DOS DOS] with '''80 characters''' limit for full paths and only '''12 characters''' (8.3 format) for file names.<br />
<br />
Fortunately, this issue is slowly but surely getting addressed, in one way or another. We will also discuss ways of working around some of these limitations.<br />
<br />
== Long paths in Windows ==<br />
<br />
Modern versions of Windows operating system have an alternative file path specification mechanism which overcomes the '''260 characters''' limitation.<br />
<br />
Let's take a conventional file path:<br />
<br />
<pre>C:\Very\Long\Path</pre><br />
<br />
To convert a path to "long path" specification, we just need to prepend it with <code>\\?\</code>, as follows:<br />
<br />
<pre>\\?\C:\Very\Long\Path</pre><br />
<br />
This effectively raises the maximum length of file paths to '''32,767 characters''', and enables paths that end with a dot.<br />
<br />
However, there are other potential culprits:<br />
<br />
* This only raises a limitation imposed by the Windows operating system, while other limitations imposed by file systems may still apply.<br />
* The support for long paths also depends on capabilities of individual applications.<br />
<br />
== Long paths in ReNamer ==<br />
<br />
ReNamer normally operates with conventional file paths, but it can also handle the "long path" specification if such was provided.<br />
<br />
The standard ''Add Files'' and ''Add Folders'' dialogs cannot handle long paths yet. However, you can use the ''Add Paths'' dialog from the main menu or ''Export/Import'' menu options.<br />
<br />
== Truncating long paths ==<br />
<br />
The limitation of the maximum file path can make files inaccessible by some applications, including even the ''Windows File Explorer''.<br />
<br />
A common workaround is to truncate long paths. The truncation can be performed with the help of [[ReNamer:Rules:PascalScript|Pascal Script]] and [[ReNamer:Rules:RegEx|Regular Expressions]] rules.<br />
<br />
== References ==<br />
<br />
* [https://docs.microsoft.com/windows/win32/fileio/naming-a-file Windows: Naming Files, Paths, and Namespaces]<br />
* [https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation Windows: Maximum Path Length Limitation]<br />
* [https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits Wikipedia: Comparison of file systems and limits]<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Long_paths&diff=3496ReNamer:Long paths2022-08-17T23:01:13Z<p>Den4b: /* Long paths in Windows */</p>
<hr />
<div>{{Up|ReNamer}}<br />
<br />
== Introduction ==<br />
<br />
The maximum length of paths and file/folder names is limited in every mainstream operating system and file system. The exact limits can vary significantly between systems. <br />
<br />
For example, in Windows 10 and earlier versions the maximum path length is limited to '''260 characters''' (MAX_PATH constant). In contrast, Linux imposes a limit of '''4096 bytes''' for full paths and '''255 bytes''' for file names. Older systems imposed even stricter limits, like [https://en.wikipedia.org/wiki/DOS DOS] with '''80 characters''' limit for full paths and only '''12 characters''' (8.3 format) for file names.<br />
<br />
Fortunately, this issue is slowly but surely getting addressed, in one way or another. We will also discuss ways of working around some of these limitations.<br />
<br />
== Long paths in Windows ==<br />
<br />
Modern versions of Windows operating system have an alternative file path specification mechanism which overcomes the '''260 characters''' limitation.<br />
<br />
Let's take a conventional file path:<br />
<br />
<pre>C:\Very\Long\Path</pre><br />
<br />
To convert a path to "long path" specification, we just need to prepend it with <code>\\?\</code>, as follows:<br />
<br />
<pre>\\?\C:\Very\Long\Path</pre><br />
<br />
This effectively raises the maximum length of file paths to '''32,767 characters'''.<br />
<br />
However, there are other potential culprits:<br />
<br />
* This only raises a limitation imposed by the Windows operating system, while other limitations imposed by file systems may still apply.<br />
* The support for long paths also depends on capabilities of individual applications.<br />
<br />
== Long paths in ReNamer ==<br />
<br />
ReNamer normally operates with conventional file paths, but it can also handle the "long path" specification if such was provided.<br />
<br />
The standard ''Add Files'' and ''Add Folders'' dialogs cannot handle long paths yet. However, you can use the ''Add Paths'' dialog from the main menu or ''Export/Import'' menu options.<br />
<br />
== Truncating long paths ==<br />
<br />
The limitation of the maximum file path can make files inaccessible by some applications, including even the ''Windows File Explorer''.<br />
<br />
A common workaround is to truncate long paths. The truncation can be performed with the help of [[ReNamer:Rules:PascalScript|Pascal Script]] and [[ReNamer:Rules:RegEx|Regular Expressions]] rules.<br />
<br />
== References ==<br />
<br />
* [https://docs.microsoft.com/windows/win32/fileio/naming-a-file Windows: Naming Files, Paths, and Namespaces]<br />
* [https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation Windows: Maximum Path Length Limitation]<br />
* [https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits Wikipedia: Comparison of file systems and limits]<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=Book:ReNamer_User_Manual&diff=3494Book:ReNamer User Manual2022-08-09T10:56:21Z<p>Den4b: ReNamer:Long paths added</p>
<hr />
<div>{{saved_book|[[File:ReNamer_User_Manual.pdf]]}}<br />
<br />
== ReNamer User Manual ==<br />
=== www.den4b.com ===<br />
<br />
; Basics<br />
:[[ReNamer]]<br />
:[[ReNamer:Introduction|Introduction]]<br />
:[[ReNamer:Quick Guide|Quick Guide]]<br />
:[[ReNamer:Step-by-step|Step-by-step]]<br />
:[[ReNamer:Adding files and folders|Adding files and folders]]<br />
:[[ReNamer:Managing rules|Managing Rules]]<br />
:[[ReNamer:Previewing files|Previewing Files]]<br />
:[[ReNamer:Renaming files|Renaming Files]]<br />
<br />
; Rules<br />
:[[ReNamer:Using the Rules|Using the Rules]]<br />
:[[ReNamer:Rules|Overview of Rules]]<br />
:[[ReNamer:Rules:Insert|Insert Rule]]<br />
:[[ReNamer:Rules:Delete|Delete Rule]]<br />
:[[ReNamer:Rules:Remove|Remove Rule]]<br />
:[[ReNamer:Rules:Replace|Replace Rule]]<br />
:[[ReNamer:Rules:Rearrange|Rearrange Rule]]<br />
:[[ReNamer:Rules:Extension|Extension Rule]]<br />
:[[ReNamer:Rules:Strip|Strip Rule]]<br />
:[[ReNamer:Rules:Case|Case Rule]]<br />
:[[ReNamer:Rules:Serialize|Serialize Rule]]<br />
:[[ReNamer:Rules:Randomize|Randomize Rule]]<br />
:[[ReNamer:Rules:Padding|Padding Rule]]<br />
:[[ReNamer:Rules:CleanUp|Clean Up Rule]]<br />
:[[ReNamer:Rules:Translit|Translit Rule]]<br />
:[[ReNamer:Rules:RegEx|Regular Expressions Rule]]<br />
:[[ReNamer:Rules:PascalScript|Pascal Script Rule]]<br />
:[[ReNamer:Rules:UserInput|User Input Rule]]<br />
:[[ReNamer:Rules:ReformatDate|Reformat Date Rule]]<br />
<br />
; Pascal Script<br />
:[[ReNamer:Pascal Script|Pascal Script]] <br />
:[[ReNamer:Pascal Script:Quick guide|Quick Guide]]<br />
:[[ReNamer:Pascal Script:Types|Types]] <br />
:[[ReNamer:Pascal Script:Functions|Functions]]<br />
:[[ReNamer:Scripts|User Scripts]] <br />
<br />
; Menus and Settings<br />
:[[ReNamer:Program settings|Program settings]] <br />
:[[ReNamer:Main menu|Main menu]] <br />
:[[ReNamer:Rules menu|Rules menu]]<br />
:[[ReNamer:Files menu|Files menu]]<br />
:[[ReNamer:Files header menu|Files header menu]]<br />
:[[ReNamer:Filter settings|Filter settings]]<br />
:[[ReNamer:Export menu|Export menu]]<br />
:[[ReNamer:Options menu|Options menu]]<br />
:[[ReNamer:Menus for the Files pane|Menus for the Files pane]]<br />
<br />
; Appendices<br />
:[[ReNamer:Using presets|Using Presets]]<br />
:[[ReNamer:Manual editing|Manual Editing]]<br />
:[[ReNamer:Analyze|Analyze]]<br />
:[[ReNamer:Date and Time format|Date and Time Format]]<br />
:[[ReNamer:Binary Signatures|Binary Signatures]] <br />
:[[ReNamer:Meta Tags|Meta Tags]]<br />
:[[ReNamer:Analyze|Analyze]]<br />
:[[ReNamer:Regular Expressions|Regular Expressions]] <br />
:[[ReNamer:Command Line|Command Line Mode]] <br />
:[[ReNamer:Sorting files|Sorting Files]]<br />
:[[ReNamer:Masks|Using masks]]<br />
:[[ReNamer:Renaming folders|Renaming folders]]<br />
:[[ReNamer:Renaming to another folder|Renaming to another folder]]<br />
:[[ReNamer:Long paths|Long file paths]]<br />
:[[ReNamer:Failed renaming|Failed renaming]]<br />
:[[ReNamer:Validation|Validation of New Names]]<br />
:[[ReNamer:Examples of Rules|Examples of rules]]<br />
:[[ReNamer:Rules:Rearrange Examples|Examples of Rearrange rule]]<br />
<br />
[[Category:Books]]<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:TOC&diff=3493ReNamer:TOC2022-08-09T10:54:29Z<p>Den4b: ReNamer:Long paths linked</p>
<hr />
<div>{{Beta}}<br />
<br />
{{Open book|Book:ReNamer_User_Manual|Open the book and download the manual as a PDF}}<br />
<br />
{| class="wikitable"<br />
!colspan="3"| Table of Contents<br />
|-<br />
|valign="top"|<br />
*[[ReNamer:Introduction|Introduction]] <br />
*[[ReNamer:Quick Guide|Quick Guide]] <br />
*[[ReNamer:Step-by-step|Step-by-step]] <br />
**[[ReNamer:Adding files and folders|Adding files and folders]] <br />
**[[ReNamer:Managing rules|Managing rules]] <br />
**[[ReNamer:Previewing files|Previewing files]] <br />
**[[ReNamer:Renaming files|Renaming files]]<br />
*[[ReNamer:Using presets|Using presets]]<br />
*[[ReNamer:Analyze|Analyze window]] <br />
*[[ReNamer:Manual editing|Manual editing]]<br />
* Menus and settings<br />
**[[ReNamer:Program settings|Program settings]] <br />
**[[ReNamer:Main menu|Main menu]] <br />
**[[ReNamer:Rules menu|Rules menu]]<br />
**[[ReNamer:Files menu|Files menu]]<br />
**[[ReNamer:Files header menu|Files header menu]]<br />
**[[ReNamer:Filter settings|Filter settings]]<br />
**[[ReNamer:Export menu|Export menu]]<br />
**[[ReNamer:Options menu|Options menu]]<br />
**[[ReNamer:Menus for the Files pane|Menus for the Files pane]]<br />
<br />
|valign="top"|<br />
*[[ReNamer:Using the Rules|Using the Rules]] <br />
**[[ReNamer:Rules|Overview]] <br />
**[[ReNamer:Rules:Insert|Insert]] <br />
**[[ReNamer:Rules:Delete|Delete]] <br />
**[[ReNamer:Rules:Remove|Remove]] <br />
**[[ReNamer:Rules:Replace|Replace]]<br />
**[[ReNamer:Rules:Rearrange|Rearrange]]<br />
**[[ReNamer:Rules:Extension|Extension]] <br />
**[[ReNamer:Rules:Strip|Strip]] <br />
**[[ReNamer:Rules:Case|Case]] <br />
**[[ReNamer:Rules:Serialize|Serialize]] <br />
**[[ReNamer:Rules:Randomize|Randomize]]<br />
**[[ReNamer:Rules:Padding|Padding]]<br />
**[[ReNamer:Rules:CleanUp|Clean Up]] <br />
**[[ReNamer:Rules:Translit|Translit]] <br />
**[[ReNamer:Rules:RegEx|Regular Expressions]]<br />
**[[ReNamer:Rules:PascalScript|Pascal Script]]<br />
**[[ReNamer:Rules:UserInput|User Input]]<br />
**[[ReNamer:Rules:ReformatDate|Reformat Date]]<br />
<br />
|valign="top"|<br />
*[[ReNamer:Date and Time format|Date and Time format]]<br />
*[[ReNamer:Binary Signatures|Binary Signatures]] <br />
*[[ReNamer:Meta Tags|Meta Tags]]<br />
*[[ReNamer:Analyze|Analyze dialog]]<br />
*[[ReNamer:Regular Expressions|Regular Expressions]] <br />
*[[ReNamer:Pascal Script|Pascal Script]] <br />
**[[ReNamer:Pascal Script:Quick guide|Quick guide]]<br />
**[[ReNamer:Pascal Script:Types|Types]] <br />
**[[ReNamer:Pascal Script:Functions|Functions]]<br />
**[[ReNamer:Pascal_Script#Script cookbook|Script cookbook]] <br />
**[[ReNamer:Scripts|Scripts]] <br />
*[[ReNamer:Command Line|Command line mode]] <br />
*[[ReNamer:Sorting files|Sorting files]]<br />
*[[ReNamer:Masks|Using masks]]<br />
*[[ReNamer:Renaming folders|Renaming folders]]<br />
*[[ReNamer:Renaming to another folder|Renaming to another folder]]<br />
*[[ReNamer:Long paths|Long file paths]]<br />
*[[ReNamer:Failed renaming|Failed renaming]]<br />
*[[ReNamer:Validation|Validation]]<br />
*[[ReNamer:Skip extension|Skip extension]]<br />
*[[ReNamer:Examples of Rules|Examples of rules]]<br />
*[[ReNamer:Rules:Rearrange Examples|Examples of Rearrange rule]]<br />
|}<br />
<br />
[[Category:ReNamer]]<br />
[[Category:TOC]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Long_paths&diff=3492ReNamer:Long paths2022-08-09T10:53:08Z<p>Den4b: Created page with "{{Up|ReNamer}} == Introduction == The maximum length of paths and file/folder names is limited in every mainstream operating system and file system. The exact limits can ver..."</p>
<hr />
<div>{{Up|ReNamer}}<br />
<br />
== Introduction ==<br />
<br />
The maximum length of paths and file/folder names is limited in every mainstream operating system and file system. The exact limits can very significantly between systems. <br />
<br />
For example, in Windows 10 and earlier versions the maximum path length is limited to '''260 characters''' (MAX_PATH constant). In contrast, Linux imposes a limit of '''4096 bytes''' for full paths and '''255 bytes''' for file names. Older systems imposed even stricter limits, like [https://en.wikipedia.org/wiki/DOS DOS] with '''80 characters''' limit for full paths and only '''12 characters''' (8.3 format) for file names.<br />
<br />
Fortunately, this issue is slowly but surely getting addressed, in one way or another. We will also discuss ways of working around some of these limitations.<br />
<br />
== Long paths in Windows ==<br />
<br />
Modern versions of Windows operating system have an alternative file path specification mechanism which overcomes the '''260 characters''' limitation.<br />
<br />
Let's take a conventional file path:<br />
<br />
<pre>C:\Very\Long\Path</pre><br />
<br />
To convert a path to a "long path" specification, we just need to prepend it with <code>\\?\</code>, as follows:<br />
<br />
<pre>\\?\C:\Very\Long\Path</pre><br />
<br />
This effectively raises the maximum length of file paths to '''32,767 characters'''.<br />
<br />
However, there are other potential culprits:<br />
<br />
* This only raises a limitation imposed by the Windows operating system, while other limitations imposed by file systems may still apply.<br />
* The support for long paths also depends on capabilities of individual applications.<br />
<br />
== Long paths in ReNamer ==<br />
<br />
ReNamer normally operates with conventional file paths, but it can also handle the "long path" specification if such was provided.<br />
<br />
The standard ''Add Files'' and ''Add Folders'' dialogs cannot handle long paths yet. However, you can use the ''Add Paths'' dialog from the main menu or ''Export/Import'' menu options.<br />
<br />
== Truncating long paths ==<br />
<br />
The limitation of the maximum file path can make files inaccessible by some applications, including even the ''Windows File Explorer''.<br />
<br />
A common workaround is to truncate long paths. The truncation can be performed with the help of [[ReNamer:Rules:PascalScript|Pascal Script]] and [[ReNamer:Rules:RegEx|Regular Expressions]] rules.<br />
<br />
== References ==<br />
<br />
* [https://docs.microsoft.com/windows/win32/fileio/naming-a-file Windows: Naming Files, Paths, and Namespaces]<br />
* [https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation Windows: Maximum Path Length Limitation]<br />
* [https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits Wikipedia: Comparison of file systems and limits]<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=File:ReNamer_User_Manual.pdf&diff=3491File:ReNamer User Manual.pdf2022-06-05T13:07:21Z<p>Den4b: Den4b uploaded a new version of File:ReNamer User Manual.pdf</p>
<hr />
<div>Generated from [[Book:ReNamer User Manual]].<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Renaming_folders&diff=3490ReNamer:Renaming folders2022-05-16T17:59:42Z<p>Den4b: Rewritten the basic instructions for renaming folders</p>
<hr />
<div>{{Up|ReNamer}}<br />
<br />
== How to rename folders ==<br />
<br />
[[ReNamer]] has several [[ReNamer:Filter settings|filter options]] which configure how the added files and folders are treated.<br />
<br />
The default filter settings are configured for renaming files only, not the folders. When you add a folder, it will be scanned recursively and the contained files will be added to the renaming list.<br />
<br />
To rename the folders themselves, open [[ReNamer:Filter settings|filter settings]] and enable the "'''Add folders as files'''" option. If you are interested in renaming only folders and not the contained files, you also need to disable the "'''Add files within folders'''" option.<br />
<br />
Note that if you add both folders and their content to the renaming list, you must take extra care to avoid potential [[#Conflicting order|conflicts in the renaming order]].<br />
<br />
== Extensions in folders ==<br />
<br />
Note that [[ReNamer:Skip extension|Skip extension]] option may also affect folders. A setting "[[ReNamer:Program_settings#General_settings|Folders also have extensions]]" controls whether ReNamer treats extension in folder names the same way as in files. That is, if there are any periods in the name of a folder, the portion on the right side of the last period is treated as extension. <br />
<br />
For example, if you had a list of tutorials organized in folders <code>01.Introduction</code>, <code>02.Basics</code>, <code>03.Advanced</code> and so on. If the "''Folders also have extensions''" option was enabled, <code>01</code>, <code>02</code> and <code>03</code> would be treated as base names, while <code>Introduction</code>, <code>Basics</code> and <code>Advanced</code> parts would be treated as their extensions, respectively.<br />
<br />
== Conflicting order ==<br />
<br />
Renaming a folder also affects all of its content. Therefore renaming of folders requires a little more care.<br />
<br />
A problem can occur if you try to rename folders and their content in a single run. Items in the renaming list are processed from top to bottom. The order of items in this case is extremely important for successful renaming.<br />
<br />
'''Important:''' Parent folders must always appear below their contained items. This can be easily achieved by [[ReNamer:Sorting files|sorting items]] in descending order by the '''Folder''' or '''Path''' column.<br />
<br />
If a parent folder is renamed first, the actual path for its contents changes instantly, with its new name. However, the subfolders and files contained in that folder are still listed in ReNamer with their old path. As a result, ReNamer is unable to find those items at the specified location, and therefore it cannot rename them.<br />
<br />
=== Example ===<br />
<br />
Let's imagine that you have a folder <code>C:\Folder</code> which contains a file <code>C:\Folder\Document.txt</code>. You would like to rename both the folder and the contained file at the same time. You have listed the '''Folder''' before the '''Document.txt''' in ReNamer. As soon as the '''Folder''' is renamed to '''NewFolder''', the path for '''Document.txt''' changes to <code>C:\NewFolder\Document.txt</code> in the file system. However, the '''Document.txt''' is still listed in ReNamer at its original location <code>C:\Folder\Document.txt</code>. Thus ReNamer is unable to find '''Document.txt''' when it attempts to rename it. <br />
<br />
In other words, while the contained folder is renamed, the contents are not.<br />
<br />
=== Problem occurred ===<br />
<br />
{| <br />
! Preview<br />
! Rename<br />
|-<br />
| [[Image:ReNamer Folder Rename Bad Before.png]]<br />
| [[Image:ReNamer Folder Rename Bad After.png]]<br />
|}<br />
Items as they appear after they were added, no sorting.<br />
<br />
=== Problem solved ===<br />
<br />
{| <br />
! Preview<br />
! Rename<br />
|-<br />
| [[Image:ReNamer Folder Rename Good Before.png]]<br />
| [[Image:ReNamer Folder Rename Good After.png]]<br />
|}<br />
Items after they were sorted in descending order by Folder column.<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Export_menu&diff=3489ReNamer:Export menu2022-05-05T16:51:01Z<p>Den4b: Clarified the handling of relative paths</p>
<hr />
<div>{{Up|ReNamer}}<br />
<br />
When you click on the [[Image:ExportButton.png]] button, the following menu pops up: <br />
<br />
[[Image:ExportMenu.png|frame|none]]<br />
<br />
{| class="wikitable"<br />
! Option<br />
! Description<br />
<br />
|-<br />
| Export file paths and undo paths<br />
| Exports ''file paths'' and ''undo paths'' to the .csv (comma separated) or .txt (tab separated) file.<br />
<br />
|-<br />
| Export file paths and new names<br />
| Exports ''file paths'' and ''new names'' to the .csv (comma separated) or .txt (tab separated) file. <br />
<br />
|-<br />
| Import file paths and new names<br />
| Imports ''file paths'' and ''new names'' from the .csv (comma separated) or .txt (tab separated) file.<br />
<br />
'''Note:''' This importing feature does not support relative paths, so all file paths must be absolute.<br />
<br />
|-<br />
| Import files from text-list or play-list<br />
| Imports ''file paths'' from a list file (one file per line) or a playlist file (M3U/PLS format).<br />
<br />
'''Note:''' It will load file paths into '''Files''' pane only if the file really exists on your file system.<br />
<br />
|-<br />
| Export as batch renaming file (full paths)<br />
|<br />
<br />
|-<br />
| Export as batch renaming file (only names)<br />
|<br />
<br />
|-<br />
| Export new names to clipboard<br />
| Export ''new names'' to clipboard. One name per line.<br />
<br />
|-<br />
| Import new names from clipboard<br />
| Imports ''new names'' from clipboard. Every name should be placed in a new line.<br />
<br />
If there is less lines in the clipboard text than files in '''Files''' pane last files won't be renamed.<br><br />
If there is more lines in the clipboard text than files in '''Files''' pane, then last lines won't be used.<br />
<br />
|-<br />
| Export paths to clipboard<br />
| Export full original paths of all files to the clipboard.<br />
<br />
|-<br />
| Export all columns to clipboard<br />
| Exports ''all columns'' to clipboard as a tab separated text.<br />
|}<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Export_menu&diff=3488ReNamer:Export menu2022-05-05T16:30:02Z<p>Den4b: Reverted edits by Stefan (talk) to last revision by Den4b</p>
<hr />
<div>{{Up|ReNamer}}<br />
<br />
When you click on the [[Image:ExportButton.png]] button, the following menu pops up: <br />
<br />
[[Image:ExportMenu.png|frame|none]]<br />
<br />
{| class="wikitable"<br />
! Option<br />
! Description<br />
<br />
|-<br />
| Export file paths and undo paths<br />
| Exports ''file paths'' and ''undo paths'' to the .csv (comma separated) or .txt (tab separated) file.<br />
<br />
|-<br />
| Export file paths and new names<br />
| Exports ''file paths'' and ''new names'' to the .csv (comma separated) or .txt (tab separated) file. <br />
<br />
|-<br />
| Import file paths and new names<br />
| Imports ''file paths'' and ''new names'' from the .csv (comma separated) or .txt (tab separated) file.<br />
<br />
|-<br />
| Import files from text-list or play-list<br />
| Imports ''file paths'' from the .txt/.log file (one file per line) or .m3u/.pls playlist.<br />
<br />
'''Note:''' It will load file paths into '''Files''' pane only if the file really exists on your file system.<br />
<br />
|-<br />
| Export as batch renaming file (full paths)<br />
|<br />
<br />
|-<br />
| Export as batch renaming file (only names)<br />
|<br />
<br />
|-<br />
| Export new names to clipboard<br />
| Export ''new names'' to clipboard. One name per line.<br />
<br />
|-<br />
| Import new names from clipboard<br />
| Imports ''new names'' from clipboard. Every name should be placed in a new line.<br />
<br />
If there is less lines in the clipboard text than files in '''Files''' pane last files won't be renamed.<br><br />
If there is more lines in the clipboard text than files in '''Files''' pane, then last lines won't be used.<br />
<br />
|-<br />
| Export paths to clipboard<br />
| Export full original paths of all files to the clipboard.<br />
<br />
|-<br />
| Export all columns to clipboard<br />
| Exports ''all columns'' to clipboard as a tab separated text.<br />
|}<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:TOC&diff=3485ReNamer:TOC2022-04-15T22:44:43Z<p>Den4b: User friendly rule names</p>
<hr />
<div>{{Beta}}<br />
<br />
{{Open book|Book:ReNamer_User_Manual|Open the book and download the manual as a PDF}}<br />
<br />
{| class="wikitable"<br />
!colspan="3"| Table of Contents<br />
|-<br />
|valign="top"|<br />
*[[ReNamer:Introduction|Introduction]] <br />
*[[ReNamer:Quick Guide|Quick Guide]] <br />
*[[ReNamer:Step-by-step|Step-by-step]] <br />
**[[ReNamer:Adding files and folders|Adding files and folders]] <br />
**[[ReNamer:Managing rules|Managing rules]] <br />
**[[ReNamer:Previewing files|Previewing files]] <br />
**[[ReNamer:Renaming files|Renaming files]]<br />
*[[ReNamer:Using presets|Using presets]]<br />
*[[ReNamer:Analyze|Analyze window]] <br />
*[[ReNamer:Manual editing|Manual editing]]<br />
* Menus and settings<br />
**[[ReNamer:Program settings|Program settings]] <br />
**[[ReNamer:Main menu|Main menu]] <br />
**[[ReNamer:Rules menu|Rules menu]]<br />
**[[ReNamer:Files menu|Files menu]]<br />
**[[ReNamer:Files header menu|Files header menu]]<br />
**[[ReNamer:Filter settings|Filter settings]]<br />
**[[ReNamer:Export menu|Export menu]]<br />
**[[ReNamer:Options menu|Options menu]]<br />
**[[ReNamer:Menus for the Files pane|Menus for the Files pane]]<br />
<br />
|valign="top"|<br />
*[[ReNamer:Using the Rules|Using the Rules]] <br />
**[[ReNamer:Rules|Overview]] <br />
**[[ReNamer:Rules:Insert|Insert]] <br />
**[[ReNamer:Rules:Delete|Delete]] <br />
**[[ReNamer:Rules:Remove|Remove]] <br />
**[[ReNamer:Rules:Replace|Replace]]<br />
**[[ReNamer:Rules:Rearrange|Rearrange]]<br />
**[[ReNamer:Rules:Extension|Extension]] <br />
**[[ReNamer:Rules:Strip|Strip]] <br />
**[[ReNamer:Rules:Case|Case]] <br />
**[[ReNamer:Rules:Serialize|Serialize]] <br />
**[[ReNamer:Rules:Randomize|Randomize]]<br />
**[[ReNamer:Rules:Padding|Padding]]<br />
**[[ReNamer:Rules:CleanUp|Clean Up]] <br />
**[[ReNamer:Rules:Translit|Translit]] <br />
**[[ReNamer:Rules:RegEx|Regular Expressions]]<br />
**[[ReNamer:Rules:PascalScript|Pascal Script]]<br />
**[[ReNamer:Rules:UserInput|User Input]]<br />
**[[ReNamer:Rules:ReformatDate|Reformat Date]]<br />
<br />
|valign="top"|<br />
*[[ReNamer:Date and Time format|Date and Time format]]<br />
*[[ReNamer:Binary Signatures|Binary Signatures]] <br />
*[[ReNamer:Meta Tags|Meta Tags]]<br />
*[[ReNamer:Analyze|Analyze dialog]]<br />
*[[ReNamer:Regular Expressions|Regular Expressions]] <br />
*[[ReNamer:Pascal Script|Pascal Script]] <br />
**[[ReNamer:Pascal Script:Quick guide|Quick guide]]<br />
**[[ReNamer:Pascal Script:Types|Types]] <br />
**[[ReNamer:Pascal Script:Functions|Functions]]<br />
**[[ReNamer:Pascal_Script#Script cookbook|Script cookbook]] <br />
**[[ReNamer:Scripts|Scripts]] <br />
*[[ReNamer:Command Line|Command line mode]] <br />
*[[ReNamer:Sorting files|Sorting files]]<br />
*[[ReNamer:Masks|Using masks]]<br />
*[[ReNamer:Renaming folders|Renaming folders]]<br />
*[[ReNamer:Renaming to another folder|Renaming to another folder]]<br />
*[[ReNamer:Failed renaming|Failed renaming]]<br />
*[[ReNamer:Validation|Validation]]<br />
*[[ReNamer:Skip extension|Skip extension]]<br />
*[[ReNamer:Examples of Rules|Examples of rules]]<br />
*[[ReNamer:Rules:Rearrange Examples|Examples of Rearrange rule]]<br />
|}<br />
<br />
[[Category:ReNamer]]<br />
[[Category:TOC]]</div>Den4bhttp://www.den4b.com/w/index.php?title=Shutter:Events&diff=3484Shutter:Events2022-04-15T13:48:08Z<p>Den4b: Restructure the article, no more massive table.</p>
<hr />
<div>{{Up|Shutter}}<br />
<br />
Below is a list of all available events. <br />
<br />
Remember that Shutter is often used with a ''set'' of multiple events (rather than a single event); and these events have a [[Shutter:Logic|pre-defined relationship]] between them. <br />
<br />
== Countdown ==<br />
<br />
Count down a specified amount of time. This Event is considered "triggered" when the timer reaches zero. <br />
<br />
'''Example uses:'''<br />
<br />
#If you suffer from [http://en.wikipedia.org/wiki/Repetitive_strain_injury RSI], set timer to take a break every few minutes and exercise your hands, shoulder and neck.<br />
#Use Shutter as a count-down timer clock (to give alarm at the end of specified time). <br />
#Play a pre-recorded sound every few minutes (to calm down a baby or a pet).<br />
<br />
== On Time ==<br />
<br />
Event is triggered when the current time (as displayed in the system tray) reaches the specified time. <br />
<br />
'''Example uses:'''<br />
<br />
#Launch an application (e.g. a downloader) at certain time. <br />
#Share your PC on LAN till a particular time, and then turn it off at certain time.<br />
<br />
== Winamp Stops ==<br />
<br />
Event periodically checks the playback state of [http://www.winamp.com/ Winamp]. The event is triggered once it is detected that application is no longer playing the media. <br />
<br />
'''Note:''' [http://forums.winamp.com/showthread.php?threadid=180297 Winamp Messaging API] is used to achieve this. <br />
<br />
'''Example uses:'''<br />
<br />
#When the WinAmp playlist is over, pause for a specified time period and then play another playlist, or hibernate the PC.<br />
<br />
== CPU Usage ==<br />
<br />
Periodically check the processor usage and trigger event when the usage stays above (or below) the specified mark for the specified amount of time.<br />
<br />
'''Example uses:'''<br />
<br />
#Launch a CPU-intensive application (e.g. Blender rendering) to get the benefit of full CPU power.<br />
#When CPU usage goes above certain threshold, pause the resource-intensive applications.<br />
<br />
== Network usage ==<br />
<br />
Check the network's load (select from ''total'', ''upload only'', or ''download only''); and if it falls below specified limit for the specified duration, then the event is triggered. <br />
<br />
'''Example uses:'''<br />
<br />
#Start a downloader when the download is below a limit.<br />
#Upload a large folder when the upload falls below certain point<br />
#Pause file-transfers till the total traffic in the network falls below a certain limit.<br />
<br />
== User Inactive ==<br />
<br />
Track the time of user's last mouse and keyboard activity. Trigger the event when the user has been inactive for the specified period of time. <br />
<br />
Methods for monitoring user inactivity:<br />
<br />
# '''Last Input Event''' - Uses <tt>GetLastInputInfo</tt> API. Captures activity only of the initiating user session. The most stable and the least intrusive approach.<br />
# '''Low Level Hook''' - Uses <tt>SetWindowsHookEx(WH_KEYBOARD_LL)</tt> and <tt>SetWindowsHookEx(WH_MOUSE_LL)</tt> API. Captures activity from all user sessions. Applied without injection into foreign processes to achieve a less intrusive effect, contrary to the official documentation, so it may stop working in future versions of Windows.<br />
# '''Injection Hook''' - Uses <tt>SetWindowsHookEx(WH_KEYBOARD)</tt> and <tt>SetWindowsHookEx(WH_MOUSE)</tt> API. Captures activity from all user sessions. A tiny dedicated library file is injected into all foreign processes to capture user activity across all applications. This is a well established approach which may yield better results in some cases, but it is the most intrusive approach. <br />
<br />
'''Example uses:'''<br />
<br />
#Play WinAmp when no one is using the PC (turn the PC into entertainment center). <br />
#Launch a task that can otherwise slow down the PC.<br />
<br />
== Battery Low ==<br />
<br />
Monitor power battery level and trigger event when level drops below specified level. <br />
<br />
'''Example uses:'''<br />
<br />
#Take backup of critical data. <br />
#Close specified applications gracefully. <br />
#Remind the user to plug in the laptop charger.<br />
<br />
== Window Closes ==<br />
<br />
Monitor opened windows for the specified title match. Event is triggered when specified title does not match any of the opened windows. <br />
<br />
*The name is NOT case-sensitive. <br />
*You can specify wildcards to find a <u>partial</u> match. For example, '''''*Firefox*'''''.<br>If you do not use wildcards, Shutter will look for an <u>exact</u> match (if the actual Window name has more characters compared to the specified string, Shutter will treat it as "not matching").<br />
<br />
'''Note:''' Be careful when specifying the window name: The text should match with what you see in the '''Title Bar '''of the application (the top bar of the application's window). Sometimes the '''Title Bar''' shows the file that is opened in the application, instead of the application's name.<br />
<br />
'''Example uses:'''<br />
<br />
#Warn the user that the desired application has stopped running.<br />
#Launch the process ''only if'' the application is not running already (to avoid multiple instances running simultaneously)<br />
<br />
== Process Stops ==<br />
<br />
Monitor all processes that match the specified filename. Event is triggered when the specified filename is not found in the list of executing processes. <br />
<br />
'''Example uses:'''<br />
<br />
#Warn the user that the process has stopped. <br />
#Launch the next process in sequence.<br />
<br />
== Ping Stops ==<br />
<br />
[http://en.wikipedia.org/wiki/Ping Ping] the specified host and trigger when host is not responding for the specified period of time. Useful for monitoring availability of network services. <br />
<br />
'''Example uses:'''<br />
<br />
#Warn the user that the remote PC is not communicating any more (either bad link or crash).<br />
<br />
== File Size ==<br />
<br />
Periodically check the size of the specified file and trigger the event when the selected condition is met.<br />
<br />
The list of available conditions:<br />
<br />
# file reaches a certain size;<br />
# file is created;<br />
# file no longer exists.<br />
<br />
Internally, when the file or directory does not exist, it has an effective size of "-1".<br />
<br />
'''Example uses:'''<br />
<br />
#Take a backup of the file.<br />
#Warn the user that the file size has reached the limit.<br />
<br />
[[Category:Shutter]]</div>Den4bhttp://www.den4b.com/w/index.php?title=Shutter:TOC&diff=3483Shutter:TOC2022-04-15T13:39:09Z<p>Den4b: Renamed the Workflow article link</p>
<hr />
<div>{{Beta}}<br />
<br />
{{Open book|Book:Shutter_User_Manual|Open the book and download the manual as a PDF}}<br />
<br />
{| class="wikitable"<br />
! Table of Contents<br />
|-<br />
|<br />
* [[Shutter:Quick Guide|Quick Guide]] <br />
* [[Shutter:Workflow|Workflow]] <br />
** [[Shutter:Events|Events]] <br />
** [[Shutter:Actions|Actions]] <br />
** [[Shutter:Logic|Relationship between Events]]<br />
* [[Shutter:Options|Program options]] <br />
* [[Shutter:Web Interface|Remote access (Web interface)]] <br />
* [[Shutter:Command Line|Command line mode]]<br />
* [[Shutter:Run as service|Run as service]] <br />
* [[Shutter:Typical uses|Typical uses]]<br />
* [[Shutter:FAQ|Frequently Asked Questions (FAQ)]]<br />
|}<br />
<br />
[[Category:Shutter]]<br />
[[Category:TOC]]</div>Den4bhttp://www.den4b.com/w/index.php?title=Shutter:Workflow&diff=3482Shutter:Workflow2022-04-15T13:05:50Z<p>Den4b: Clarified the link between events and actions, and multiple independent schedules.</p>
<hr />
<div>{{Up|Shutter}} <br />
<br />
The workflow of [[Shutter]] is a simple 3-step process: <br />
<br />
#Add [[Shutter:Events|events]] that are to be monitored, and <br />
#Add [[Shutter:Actions|actions]] that are to be executed when the specified events occur. <br />
#Start monitoring for the specified events.<br />
<br />
Shutter monitors for the events to be triggered according to the [[Shutter:Logic|selected logic]], then all actions will be executed one by one. Note that individual events are not directly linked to individual actions, but the lists of events and actions are linked.<br />
<br />
You can consider that a single instance of Shutter has a single active schedule (preset). If you need multiple active schedules, you need to start multiple instances of Shutter each with its own schedule.<br />
<br />
=== Step 1: Add Events ===<br />
<br />
[[Shutter:Events|Events]] are usually based on periodic checking of a system state, execution state of a process, or system time. <br />
<br />
*You can add multiple events, and also set the [[Shutter:Logic|logical relationship]] between them.<br />
<br />
Note that this step only loads the events; Shutter will not start monitoring for the event till you press the [[Image:ShutterStartButton.png]] button (see '''Step 3''').<br />
<br />
=== Step 2: Add Actions ===<br />
<br />
[[Shutter:Actions|Actions]] are executed ''one by one'', from top to bottom. <br />
<br />
You can add as many actions as you want, but please be aware of the following factors: <br />
<br />
*Each action can affect the execution of the other actions listed below it. <br>To avoid that, you may have to change the order of the Actions by moving them up/down. <br />
*Some of these actions are ''terminal'': They close Shutter, log out the Windows user or shut down the PC. For example: the '''Shutdown''' action.<br>Therefore, such Actions <u>must</u> be placed at the very <u>end</u> of the '''Actions''' stack. Otherwise the actions listed below them will ''never'' be executed!<br />
<br />
=== Step 3: Start monitoring ===<br />
<br />
Press the [[Image:ShutterStartButton.png]] button. Shutter starts monitoring for the events. The button changes to [[Image:ShutterStopButton.png]]. Press it if you want to stop Shutter in an emergency. <br />
<br />
*Shutter also has a [[Image:ShutterNowButton.png]] button, which starts all actions without waiting for triggering the event-set.<br />
<br />
:This is useful to check how the specified actions would actually work.<br />
<br />
[[Category:Shutter]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Serialize&diff=3481ReNamer:Rules:Serialize2022-04-01T02:00:40Z<p>Den4b: /* Numbering system */ Music notes system added</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Case|next=ReNamer:Rules:Randomize}}<br />
<br />
== Serialize Rule ==<br />
<br />
[[Image:SerializeRule.png|center]]<br />
<br />
This rule works on a set of files, and inserts incremental numeric series of digits in the names of those filenames.<br />
<br />
The files listed in the pane can be numbered in increasing or decreasing order, with various steps, repeat and reset configuration. The position of each file in the '''Files''' pane becomes important, so check the order of the files in the list before applying this rule.<br />
<br />
Examples:<br />
<br />
# You have a bunch of log files, and you want to make them look like "log0001", "log0002", "log0003", etc.<br />
# You want to force specific sorting for files: "01 - Song XYZ", "02 - Song ABC", "03 - Song YYY", etc.<br />
<br />
The parameters are as follows:<br />
<br />
{| class="wikitable"<br />
! Parameter<br />
! Description<br />
<br />
|-<br />
| Index start<br />
| Starting number. For example, if the destination folder already has some files with serialized numbers, you can start with the next number.<br />
<br />
|-<br />
| Step<br />
| Increment the index by this value after each processed file. Usually 1, but you may like to enter a higher number here if files with intermediate numbers are expected later. Also, negative numbers can be used to make decremental indexes, e.g. -1, -2, -3, etc.<br />
<br />
|-<br />
| Repeat<br />
| How many times to repeat (reuse) the same index before incrementing it.<br />
<br />
|-<br />
| Reset every<br />
| Reset index to the initial value after processing this many files.<br />
<br />
|-<br />
| Reset if folder changes<br />
| Since ReNamer can work on files collected from multiple folders, this control allows you to reset the counter for each of those folders. The effect is as if you are repeating the same command for each of the folders separately.<br />
<br />
|-<br />
| Reset if file name changes<br />
| Reset the counter when the file name changes. This option is especially useful for fixing (serializing) duplicated file names, when the files with the same name are grouped together, which can be achieved by sorting the files by name or path.<br />
<br />
|-<br />
| Pad with zeros to length<br />
| Pad the inserted number with leading zeros. For example, "457" becomes "000457" if it is padded to reach 6 digits, and "0457" if padded to 4 digits.<br />
<br />
|-<br />
| Insert where<br />
| Specify where to insert the number (see below for individual options).<br />
<br />
|}<br />
<br />
=== Insert location ===<br />
<br />
Options for where to insert the number:<br />
<br />
{| class="wikitable"<br />
! Option<br />
! Description<br />
<br />
|-<br />
| Prefix<br />
| Before the original filename<br />
<br />
|-<br />
| Suffix<br />
| After the original filename<br />
<br />
|-<br />
| Position<br />
| Insert the number at the specified position.<br />
<br />
|-<br />
| Replace current name<br />
| Inserted number replaces the entire filename.<br />
<br />
|-<br />
| Skip extension<br />
| Exclude file extension when calculating the position for insertion.<br />
<br />
|}<br />
<br />
=== Numbering system ===<br />
<br />
A choice of the '''Numbering system''' dictates which symbols and enumeration technique are used for the serialization.<br />
<br />
{| class="wikitable"<br />
! Number system<br />
! Description / Examples<br />
<br />
|-<br />
| Decimal digits<br />
| Index starts at 0 with repeat 1 and step 1:<br/><br />
<tt>0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, …</tt><br />
<br />
|-<br />
| English letters<br />
| Index starts at 1 with repeat 1 and step 1:<br/><br />
<tt>a, b, c, …, x, y, z, ba, bb, bc, …, bx, by, bz, ca, cb, cc, …, zx, zy, zz, baa, bab, bac, …</tt><br />
<br />
Index starts at 1 with repeat 1 and step 1, pad to length 3:<br/><br />
<tt>aaa, aab, aac, …, aax, aay, aaz, aba, abb, abc, …, abx, aby, abz, aca, acb, acc, …, azx, azy, azz, baa, bab, bac, …</tt><br />
<br />
|-<br />
| Roman numerals<br />
| Index starts at 1 with repeat 1 and step 1:<br/><br />
<tt>I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, …</tt><br />
<br />
|-<br />
| Music notes<br />
| Index starts at 1 with repeat 1 and step 1:<br/><br />
<tt>C0, C#0, D0, D#0, E0, F0, F#0, G0, G#0, A0, A#0, B0, C1, C#1, …</tt><br/><br />
''Added in ReNamer 7.3.0.2 Beta.''<br />
<br />
|-<br />
| Simplified Chinese<br />
| Index starts at 1 with repeat 1 and step 1:<br/><br />
<tt>一, 二, 三, 四, 五, 六, 七, 八, 九, 一十, 一十一, 一十二, 一十三, …</tt><br />
<br />
|-<br />
| Custom alphabetic<br />
| Index starts at 1 with repeat 1 and step 1, using "ABC" symbols:<br/><br />
<tt>A, B, C, BA, BB, BC, CA, CB, CC, BAA, BAB, BAC, BBA, …</tt><br />
<br />
Index starts at 1 with repeat 1 and step 1, using "01" symbols:<br/><br />
<tt>0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, …</tt><br />
<br />
|-<br />
| Custom numeric<br />
| Index starts at 0 with repeat 1 and step 1, using "ABC" symbols:<br/><br />
<tt>A, B, C, BA, BB, BC, CA, CB, CC, BAA, BAB, BAC, BBA, …</tt><br />
<br />
Index starts at 0 with repeat 1 and step 1, using "01" symbols:<br/><br />
<tt>0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, …</tt><br />
<br />
|}<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Binary_Signatures&diff=3480ReNamer:Binary Signatures2022-04-01T01:48:03Z<p>Den4b: Updated the file signature list to ReNamer 7.3</p>
<hr />
<div>ReNamer's [[ReNamer:Rules:Extension|Extension]] rule uses an internal binary signature database for detecting various file extensions.<br />
<br />
These signatures in files can be seen only with specialized tools, such as [http://mh-nexus.de/hxd HxD Hex Editor] and [http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm XVI32 Hex Editor].<br />
<br />
The signature list below corresponds to '''ReNamer 7.3''' dated 14 April 2021.<br />
<br />
<pre style="overflow:auto"><br />
482B424544562050726F6475637473204C6963656E7365204B65792046696C650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001A, KEY, Avira Product Key<br />
FFFE570069006E0064006F0077007300200052006500670069007300740072007900200045006400690074006F0072002000560065007200730069006F006E00200035002E0030003000, REG, Registry Data File 5.00<br />
504B0304????????????????????????????????????????????????????6D696D65747970656170706C69636174696F6E2F657075622B7A6970, EPUB, Open Publication Structure eBook<br />
504B0304????????????????????????????????????????????????????5B436F6E74656E745F54797065735D2E786D6C, DOCX|XLSX|PPTX, Microsoft Office Open XML Format document<br />
1A45DFA3010000000000001F4286810142F7810142F2810442F381084282847765626D42878102428581021853806701, WEBM, WebM Video File<br />
41565020416E7469766972616C2044617461626173652E202863294B6173706572736B79204C616220313939372D32, AVC, Kaspersky Anti-Virus Database<br />
00000002FFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000, MAC, MacPaint Bitmap Graphic<br />
1A45DFA3934282886D6174726F736B61428781014285810118538067, MKV, Matroska Video Stream<br />
00000018667479706D7034320000000069736F6D6D703432, MP4, MP4 Video File<br />
000000186674797069736F6D0000000169736F6D61766331, MP4, MP4 Video File<br />
0000001C667479706D7034320000000069736F6D61766331, MP4, MP4 Video File<br />
24464C3240282329205350535320444154412046494C45, SAV, SPSS Data<br />
4C0000000114020000000000C000000000000046, LNK, Windows Shortcut<br />
5B436C6F6E6543445D0D0A56657273696F6E3D, CCD, CloneCD Control File<br />
000100005374616E6461726420414345204442, ACCDB, Access 2007 Database File<br />
000100005374616E64617264204A6574204442, MDB, Microsoft Access Database<br />
4D454449412044455343524950544F52, MDS, Media Descriptor CD Image File<br />
0006156100000002000004D200001000, DB, Netscape Navigator (v4) database file<br />
52494646????????43444441666D7420, CDA, Compact Disc Digital Audio (CD-DA)<br />
52494646????????415649204C495354, AVI, Windows Audio Video Interleave<br />
52494646????????524D494464617461, RMI, Windows Musical Instrument Digital Interface<br />
52494646????????57415645666D7420, WAV, Waveform Audio<br />
89504E470D0A1A0A0000000D49484452, PNG, Portable Network Graphics<br />
50532D58204558450000000000000000, EXE, Playstation Executable<br />
3026B2758E66CF11A6D900AA0062CE6C, WMA|WMV|ASF, Windows Media File<br />
4F67675300020000000000000000, OGG, Ogg Vorbis Audio<br />
??BE000000AB0000000000000000, WRI, Microsoft Write Document<br />
0000000020000000FFFF0000FFFF, RES, Resource File<br />
0000020006040600080000000000, WK1, 1-2-3 Spreadsheet<br />
38425053000100000000000000, PSD, Photoshop Image<br />
??????10123A001019040010, SIS, Symbian OS Installer File<br />
414F4C204665656462616720, BAG, AOL Instant Messenger Buddy List<br />
52494646????????41434F4E, ANI, Windows Animated Cursor<br />
52494646????????57454250, WEBP, Google WebP image file<br />
EFBBBF234558544D33550D0A, M3U8, MP3 Playlist (UTF-8)<br />
110000005343410F000000, PF, Windows Prefetch<br />
4D54686400000006000100, MID, Musical Instrument Digital Interface (MIDI)<br />
5B6175746F72756E5D0D0A, INF, Autorun File<br />
64383A616E6E6F756E6365, TORRENT, BitTorrent Metainfo File<br />
504B0304140008000800, JAR, Java Archive<br />
424547494E3A564D5347, VMG, Nokia Text Message<br />
5B706C61796C6973745D, PLS, Winamp Playlist<br />
2E524D460000001200, RM, RealMedia Streaming Media<br />
67696D702078636620, GZ, GIMP Image<br />
234558544D33550D0A, M3U, MP3 Playlist<br />
D0CF11E0A1B11AE1, DOC|PPT|XLS|MSI|PUB, Microsoft Office or Installer Document<br />
5245474544495434, REG, Windows Registry Data<br />
300000004C664C65, EVT, Windows NT/2000 Event Viewer Log<br />
4D53434600000000, CAB, Microsoft Cabinet File<br />
????????6D6F6F76, MOV, QuickTime Movie<br />
FF4B455942202020, SYS, Keyboard Driver<br />
255044462D312E, PDF, Adobe Portable Document Format<br />
526172211A0700, RAR, WinRAR Compressed Archive<br />
000001BA210001, MPG, MPEG 1 System Stream<br />
52454745444954, REG, Registry Data File<br />
377ABCAF271C, 7Z, 7-Zip Compressed Archive<br />
AC9EBD8F0000, QDF, Quicken Data<br />
D7CDC69A0000, WMF, Windows Metafile<br />
010009000003, WMF, Windows 3.x Metafile<br />
4A4152435300, JAR, JARCS Compressed Archive<br />
424547494E3A, VCF, vCard File<br />
2E7261FD00, RA, RealMedia Streaming Media<br />
7B5C727466, RTF, Rich Text Format File<br />
000001BA44, MPG, ProgDVBR MPEG2 Video<br />
464F524D00, AIFF, Audio Interchange File<br />
49735A21, ISZ, UltraISO ISO Zipped Format<br />
4B4C7377, KEY, Kaspersky Anti-Virus Key<br />
4D502B07, MPC, Musepack Audio<br />
93B20000, LNG, SourceEdit Language Definition<br />
DF0000?F, DCU, Delphi Compiled Unit<br />
00000100, ICO, Windows Icon<br />
01000000, EMF, Extended (Enhanced) Windows Metafile Format<br />
CFAD12FE, DBX, Outlook Express E-mail Folder<br />
47494638, GIF, Graphic Interchange Format<br />
49492A00, TIF, Tagged Image Format<br />
4D4D002A, TIF, Tagged Image Format<br />
00000200, CUR, Windows Cursor<br />
C5D0D3C6, EPS, Encapsulated PostScript<br />
3F5F0300, HLP, Windows Help File<br />
49536328, CAB, Install Shield v5.x or 6.x Compressed File<br />
504B0304, ZIP, ZIP Compressed Archive<br />
E3828596, PWL, Windows Password List<br />
EDABEEDB, RPM, RedHat Package Manager<br />
50533244, SYS, PlayStation 2 Icon<br />
FF575043, WPD, WordPerfect Document<br />
464C5601, FLV, Flash Video<br />
000001, MPG, MPEG Video File<br />
465753, SWF, Macromedia Flash Format<br />
435753, SWF, Shockwave Flash (v5+)<br />
FFD8FF, JPG, JPEG/JIFF Image<br />
1F8B08, GZ, GZip Compressed Archive<br />
1F9D90, Z, UNIX Compressed Archive<br />
494433, MP3, MP3 Audio<br />
FFFB, MP3, MP3 Audio<br />
FFFA, MP3, MP3 Audio<br />
4D5A, EXE|COM|DLL|SYS, Windows Executable<br />
424D, BMP, Windows OS/2 Bitmap Graphics<br />
9501, SKR, PGP Private Keyring<br />
9901, PKR, PGP Public Keyring<br />
</pre><br />
<br />
For more information regarding known file signatures look here:<br />
* http://mark0.net/soft-trid-e.html (TrID)<br />
* http://filext.com/<br />
* http://file-extension.net/seeker/<br />
* http://www.garykessler.net/library/file_sigs.html<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Binary_Signatures&diff=3479ReNamer:Binary Signatures2022-04-01T01:41:58Z<p>Den4b: HxD Hex Editor, and some rephrasing.</p>
<hr />
<div>ReNamer's [[ReNamer:Rules:Extension|Extension]] rule uses an internal binary signature database for detecting various file extensions.<br />
<br />
These signatures in files can be seen only with specialized tools, such as [http://mh-nexus.de/hxd HxD Hex Editor] and [http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm XVI32 Hex Editor].<br />
<br />
The signature list below is up to date for '''ReNamer 5.50+ Beta 32''', from 19 July 2010.<br />
<br />
<pre style="overflow:auto"><br />
482B424544562050726F6475637473204C6963656E7365204B65792046696C650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001A, KEY, Avira Product Key<br />
FFFE570069006E0064006F0077007300200052006500670069007300740072007900200045006400690074006F0072002000560065007200730069006F006E00200035002E0030003000, REG, Registry Data File 5.00<br />
41565020416E7469766972616C2044617461626173652E202863294B6173706572736B79204C616220313939372D32, AVC, Kaspersky Anti-Virus Database<br />
00000002FFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000, MAC, MacPaint Bitmap Graphic<br />
1A45DFA3934282886D6174726F736B61428781014285810118538067, MKV, Matroska Video Stream<br />
24464C3240282329205350535320444154412046494C45, SAV, SPSS Data<br />
4C0000000114020000000000C000000000000046, LNK, Windows Shortcut<br />
5B436C6F6E6543445D0D0A56657273696F6E3D, CCD, CloneCD Control File<br />
000100005374616E6461726420414345204442, ACCDB, Access 2007 Database File<br />
000100005374616E64617264204A6574204442, MDB, Microsoft Access Database<br />
4D454449412044455343524950544F52, MDS, Media Descriptor CD Image File<br />
0006156100000002000004D200001000, DB, Netscape Navigator (v4) database file<br />
52494646????????43444441666D7420, CDA, Compact Disc Digital Audio (CD-DA)<br />
52494646????????415649204C495354, AVI, Windows Audio Video Interleave<br />
52494646????????524D494464617461, RMI, Windows Musical Instrument Digital Interface<br />
52494646????????57415645666D7420, WAV, Waveform Audio<br />
89504E470D0A1A0A0000000D49484452, PNG, Portable Network Graphics<br />
50532D58204558450000000000000000, EXE, Playstation Executable<br />
3026B2758E66CF11A6D900AA0062CE6C, WMA|WMV|ASF, Windows Media File<br />
4F67675300020000000000000000, OGG, Ogg Vorbis Audio<br />
??BE000000AB0000000000000000, WRI, Microsoft Write Document<br />
0000000020000000FFFF0000FFFF, RES, Resource File<br />
0000020006040600080000000000, WK1, 1-2-3 Spreadsheet<br />
38425053000100000000000000, PSD, Photoshop Image<br />
??????10123A001019040010, SIS, Symbian OS Installer File<br />
414F4C204665656462616720, BAG, AOL Instant Messenger Buddy List<br />
52494646????????41434F4E, ANI, Windows Animated Cursor<br />
EFBBBF234558544D33550D0A, M3U8, MP3 Playlist (UTF-8)<br />
110000005343410F000000, PF, Windows Prefetch<br />
4D54686400000006000100, MID, Musical Instrument Digital Interface (MIDI)<br />
5B6175746F72756E5D0D0A, INF, Autorun File<br />
64383A616E6E6F756E6365, TORRENT, BitTorrent Metainfo File<br />
504B0304140008000800, JAR, Java Archive<br />
424547494E3A564D5347, VMG, Nokia Text Message<br />
5B706C61796C6973745D, PLS, Winamp Playlist<br />
2E524D460000001200, RM, RealMedia Streaming Media<br />
67696D702078636620, GZ, GIMP Image<br />
234558544D33550D0A, M3U, MP3 Playlist<br />
D0CF11E0A1B11AE1, DOC|PPT|XLS, Microsoft Office Document<br />
5245474544495434, REG, Windows Registry Data<br />
300000004C664C65, EVT, Windows NT/2000 Event Viewer Log<br />
4D53434600000000, CAB, Microsoft Cabinet File<br />
????????6D6F6F76, MOV, QuickTime Movie<br />
FF4B455942202020, SYS, Keyboard Driver<br />
255044462D312E, PDF, Adobe Portable Document Format<br />
526172211A0700, RAR, WinRAR Compressed Archive<br />
000001BA210001, MPG, MPEG 1 System Stream<br />
52454745444954, REG, Registry Data File<br />
377ABCAF271C, 7Z, 7-Zip Compressed Archive<br />
AC9EBD8F0000, QDF, Quicken Data<br />
D7CDC69A0000, WMF, Windows Metafile<br />
010009000003, WMF, Windows 3.x Metafile<br />
4A4152435300, JAR, JARCS Compressed Archive<br />
424547494E3A, VCF, vCard File<br />
2E7261FD00, RA, RealMedia Streaming Media<br />
7B5C727466, RTF, Rich Text Format File<br />
000001BA44, MPG, ProgDVBR MPEG2 Video<br />
464F524D00, AIFF, Audio Interchange File<br />
49735A21, ISZ, UltraISO ISO Zipped Format<br />
4B4C7377, KEY, Kaspersky Anti-Virus Key<br />
4D502B07, MPC, Musepack Audio<br />
93B20000, LNG, SourceEdit Language Definition<br />
DF0000?F, DCU, Delphi Compiled Unit<br />
00000100, ICO, Windows Icon<br />
01000000, EMF, Extended (Enhanced) Windows Metafile Format<br />
CFAD12FE, DBX, Outlook Express E-mail Folder<br />
47494638, GIF, Graphic Interchange Format<br />
49492A00, TIF, Tagged Image Format<br />
4D4D002A, TIF, Tagged Image Format<br />
00000200, CUR, Windows Cursor<br />
C5D0D3C6, EPS, Encapsulated PostScript<br />
3F5F0300, HLP, Windows Help File<br />
49536328, CAB, Install Shield v5.x or 6.x Compressed File<br />
504B0304, ZIP, ZIP Compressed Archive<br />
E3828596, PWL, Windows Password List<br />
EDABEEDB, RPM, RedHat Package Manager<br />
50533244, SYS, PlayStation 2 Icon<br />
FF575043, WPD, WordPerfect Document<br />
464C5601, FLV, Flash Video<br />
000001, MPG, MPEG Video File<br />
465753, SWF, Macromedia Flash Format<br />
435753, SWF, Shockwave Flash (v5+)<br />
FFD8FF, JPG, JPEG/JIFF Image<br />
1F8B08, GZ, GZip Compressed Archive<br />
1F9D90, Z, UNIX Compressed Archive<br />
494433, MP3, MP3 Audio<br />
FFFB, MP3, MP3 Audio<br />
FFFA, MP3, MP3 Audio<br />
4D5A, EXE|COM|DLL|SYS, Windows Executable<br />
424D, BMP, Windows OS/2 Bitmap Graphics<br />
9501, SKR, PGP Private Keyring<br />
9901, PKR, PGP Public Keyring<br />
</pre><br />
<br />
For more information regarding known file signatures look here:<br />
* http://mark0.net/soft-trid-e.html (TrID)<br />
* http://filext.com/<br />
* http://file-extension.net/seeker/<br />
* http://www.garykessler.net/library/file_sigs.html<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Rearrange&diff=3478ReNamer:Rules:Rearrange2022-04-01T00:31:42Z<p>Den4b: Clarified the "skip extension" option</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Replace|next=ReNamer:Rules:Extension}}<br />
<br />
== Rearrange rule ==<br />
<br />
[[Image:RearrangeRule.png|center]] <br />
<br />
This rule allows you to chop up the existing file name and reuse any/all of the parts in any order to compose a new name. <br />
<br />
*You can also add your own text, or use meta tags while composing the new name. <br />
*You can also use the whole original name, and insert literal text (or meta tags) around it.<br><br />
<br />
The parameters are as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter<br />
! Description<br />
|-<br />
| Split using <br />
| <br />
Specifies how to split the existing name into parts. <br />
<br />
*You can use only one of the three options at a time (you cannot combine the chopping methods)<br />
<br />
For detailed explanation of split methods please look below at the [[#Split options explained|split options explained]] section.<br />
<br />
|-<br />
| [[Image:PlusButton.png]] <br />
| Add a separator for additional delimiters. The separator is a "{{Pipe}}" (vertical pipe) character, which can also be entered manually.<br />
|-<br />
| New pattern <br />
| <br />
How to compose the new name from the parts created from the original name (see above). <br />
<br />
*You can add meta tags and literal text wherever you want. <br />
*$0 refers to the whole original name. This allows you to quickly compose a new name by inserting a string at the beginning and/or end.<br />
<br />
|-<br />
| [[Image:ReNamer Insert Meta Tag Button.png]] <br />
| Click the button to see a list of [[ReNamer:Meta Tags|meta-tags]]. Select any meta tag to insert it in the new name template.<br />
<br />
|-<br />
| Skip extension<br />
| If checked, the file extension will be excluded from the processing and will remain unaffected.<br />
<br />
|-<br />
| Right-to-left <br />
| <br />
If selected, the numbering starts from right. <br />
<br />
*The characters of the original names are counted from right (the count begins with 1) <br />
*The chopped parts will also be numbered from right ($1, $2, etc.)<br />
|}<br />
<br />
=== Split options explained ===<br />
<br />
{| class="wikitable"<br />
|-<br />
! Option<br />
! Description<br />
|-<br />
| Delimiters <br />
| <br />
Chop the name where the delimiter occurs. <br />
<br />
*The delimiter can be a single character or a string. <br />
*The chopped parts do <u>''not''</u> contain the delimiters (they are omitted totally) <br />
*Spaces, numbers and symbols are treated like normal characters. <br />
*Several delimiters can be used at a time. Use the {{pipe}} character to separate them. <br />
*The chopped parts are numbered from left, as $1, $2, $3, etc.<br />
:The same parts can be referred from the end as $-1, $-2, $-3, etc.<br />
*If the delimiter occurs at the very beginning of the name, the resultant $1 contains nothing (because there is nothing on the left side of the delimiter).<br />
:The same is true if an delimiter match at the very end of the name, the resultant $n contains nothing.<br />
<br />
<span style="color: red;">'''Warning:'''</span> The number of parts into which the filename is broken down depends solely on the number of delimiters in the filename. If you reference fewer parts in the output pattern that the number of available parts - not referenced parts will be lost! For example, take filename "Artist - Title" and to swap them around one would use " - " as a delimiter and "$2 - $1" as a new pattern which will result in "Title - Artist", but if some filename appears with more dashes like "Artist - Title - Album" the result will also be "Title - Artist" and last part will be lost. To make sure that no parts are lost use '''Exact pattern of delimiters''' option instead. <br />
<br />
|-<br />
| Positions <br />
| <br />
Chop the name at the indicated position (the position count begins with 1). <br />
<br />
*If you enter position '''n''', ReNamer will chop the '''n'''-th character and all characters beyond that in a separate piece. <br />
*Spaces, numbers and symbols are treated like normal characters. <br />
*No part of the original name is omitted during chopping. <br />
*You can enter multiple positions. Separate them with the '''*&#124;*''' sequence. <br />
*The chopped parts are numbered from left, as $1, $2, $3, etc.<br />
<br />
:The same parts can be referred from the end as $-1, $-2, $-3, etc.<br />
<br />
|-<br />
| Exact pattern of delimiters <br />
| <br />
Chop the name using the exact pattern (sequence) of the delimiters. <br />
<br />
With this option you basically define how many parts you want the filename to be split into and the order in which the delimiters must occur. If you specify 1 delimiter then you end up with exactly 2 parts, if you specify 2 delimiters you'll get 3 parts, and so on. <br />
<br />
|}<br />
<br />
== Examples ==<br />
<br />
This rule is so versatile that it can be used in a huge number of ways.<br />
Therefore its examples have been moved to a separate article [[ReNamer:Rules:Rearrange Examples|Rearrange Examples]].<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Replace&diff=3477ReNamer:Rules:Replace2022-04-01T00:28:51Z<p>Den4b: Clarified the "skip extension" option</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Remove|next=ReNamer:Rules:Rearrange}}<br />
<br />
== Replace Rule ==<br />
<br />
[[Image:ReplaceRule.png|center]]<br />
<br />
This rule removes the specified string from the name and replaces it with another string. It has options to replace the first occurrence, the last occurrence, or all the occurrences. You can replace multiple strings at a time. You can create a pattern with wildcards, so that any string that matches the pattern will be removed. <br />
<br />
The parameters are as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter <br />
! Details<br />
|-<br />
| Find <br />
| Enter the string to be replaced. <br />
*You can enter multiple strings at a time. They will be searched &amp; replaced in the order as they appear. Press the + button to insert a separator between two strings. Instead of pressing this button, you can also enter '''*&#124;*''' from the keyboard. <br />
*If the name does not contain the specified string, the rule will not act on it. <br />
*If the name contains more than one of these strings, it will replace them according to the Occurrences parameter.<br />
<br />
|-<br />
| [[Image:PlusButton.png]] button <br />
| Inserts a separator ('''*&#124;*''') sequence between two delimiter entries. (You can directly type'''*&#124;*''' <br />
You can use this button in the '''Replace''' box also. In that case, the nthe entry in the '''Find''' box is replaced by the nths entry in the '''Replace''' box. (e.g. A --&gt;A', B --&gt;B' etc.) } <br />
<br />
|-<br />
| Replace <br />
| Enter strings that will replace the "Find" strings. <br />
*Note that the number of strings (separated with '''*&#124;*''') in "Find" and "Replace" boxes should be the same. If there is more strings in the "Find" box than in the "Replace" box the spare strings will be removed (replaced with an empty string). If there is more strings in the "Replace" box, the spare strings will be ignored.<br />
<br />
|-<br />
| Insert meta tag <br />
[[Image:ReNamer Insert Meta Tag Button.png]] <br />
<br />
| Click the button to see a list of [[ReNamer:Meta Tags|meta-tags]].<br />
|-<br />
| Occurrences <br />
| In case that strings occur more than once in the filename, specify which occurrences should be replaced. (Options are: ''first only'', ''last only'', or ''all'')<br />
|-<br />
| Skip extension <br />
| If checked, the file extension will be excluded from the processing and will remain unaffected.<br />
|-<br />
| Case sensitive <br />
| Will only remove a specified string from the name if the case matches exactly.<br />
|-<br />
| Whole words only<br />
| Remove the subject text only when it is whole word, not a part of another word.<br />
<br />
For example, searching for "bar" would not find a match in "foobar" or "bars".<br />
|-<br />
| Interpret symbols as wild cards <br />
| Treat certain symbols as [[#Wildcards|Wildcards]] for matching simple patterns (similar to [[ReNamer:Regular Expressions|Regular Expressions]]). <br />
<br />
|}<br />
<br />
=== Wildcards ===<br />
<br />
{| class="wikitable"<br />
|-<br />
! Wildcard<br />
! Represents<br />
! Example<br />
|-<br />
| <center>*</center> <br />
| any number of characters (including numbers, space, underscores, etc.). <br />
| '''abc*''' equals '''abc''' followed by 0 or more characters.<br />
|-<br />
| <center>?</center> <br />
| Any single character (including numbers, space, underscores, etc.) <br />
| '''ab?d''' equals '''abcd''', '''ab1d''', '''ab d''', '''ab_d''', etc.<br />
|-<br />
| <center>[]</center> <br />
| Brackets enclose a set of characters, any one of which may match a single character at that position. <br />
| '''foo[ab]ar '''equals '''fooaar''' and '''foobar'''<br />
|-<br />
| <center>-</center> <br />
| (only within a pair of brackets) denotes a range of characters. <br />
| '''foo[a-z]ar '''equals '''fooaar''', '''foobar,''' '''foocar,''' '''foodar,''' etc.<br />
|}<br />
<br />
== Beware of conflicting replacements == <br />
<br />
If you enter multiple find and replace strings they will be executed as multiple Replace rules, so first string will go first and only after replacing all (or first, or last) occurrences of that string the second string in the Find box will be searched & replaced.<br />
<br />
{|<br />
|<br />
<br />
{| class="wikitable"<br />
! Find<br />
! Replace<br />
|-<br />
| A*{{Pipe}}*B<br />
| B*{{Pipe}}*A<br />
|}<br />
<br />
|<br />
<br />
{| class="wikitable"<br />
! Name<br />
! New Name<br />
|-<br />
| ABBA.mp3<br />
| AAAA.mp3<br />
|}<br />
<br />
|}<br />
<br />
You may expect the new name to be <tt>BAAB.mp3</tt>, but it's not. This happens because first all <tt>A</tt>'s are replaced with <tt>B</tt>'s (we get <tt>BBBB.mp3</tt>) and only then all <tt>B</tt>'s are replaced with <tt>A</tt>'s (and the final result is <tt>AAAA.mp3</tt>). <br />
<br />
If you need to apply character-to-character mappings you should use [[ReNamer:Rules:Translit|Translit rule]].<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Remove&diff=3476ReNamer:Rules:Remove2022-04-01T00:28:12Z<p>Den4b: Clarified the "skip extension" option</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Delete|next=ReNamer:Rules:Replace}}<br />
<br />
== Remove Rule ==<br />
<br />
[[Image:RemoveRule.png|center]] <br />
<br />
This rule removes the specified string from the file name. It has options to remove the first occurrence, the last occurrence, or all the occurrences of the specified string. You can enter multiple strings at a time (just separate them with '''*|*'''). If ReNamer finds any of them in the name, they will be removed. You can create a pattern with wildcards, so that any string that matches the pattern will be removed. <br />
<br />
The parameters are as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter <br />
! Details<br />
|-<br />
| Remove <br />
| Enter the string to be removed. <br />
*You can enter multiple strings at a time. Press the + button to separate two strings <br />
*If the name does not contain the specified string, the rule will not act on it. <br />
*If the name contains more than one of these strings, it will remove all of them.<br />
<br />
'''TIP:''' Sometimes, the file names have a common string that needs to be removed. In such cases, rather than entering the whole string by hand, it is easier to borrow it from one of the file names. To do this, just click on a file name in the '''Files''' pane of ReNamer ''BEFORE'' launching the '''Remove''' rule. ReNamer will automatically copy the entire name of the selected file into the Remove field. Now edit this entry to get the desired common string. <br />
<br />
|-<br />
| [[Image:PlusButton.png]] button <br />
| Inserts a separator ('''*{{Pipe}}*''') sequence between two delimiter entries. (You can directly type *{{Pipe}}* instead of clicking on this button.)<br />
|-<br />
| Occurrences <br />
| In case the strings occur multiple times in the name, specify which occurrences should be removed. (Options are: ''first only'', ''last only'', or ''all'')<br />
|-<br />
| Skip extension <br />
| If checked, the file extension will be excluded from the processing and will remain unaffected.<br />
|-<br />
| Case sensitive <br />
| Will only remove a specified string from the name if the case matches exactly.<br />
|-<br />
| Whole words only<br />
| Remove the subject text only when it is whole word, not a part of another word.<br />
<br />
For example, searching for "bar" would not find a match in "foobar" or "bars".<br />
|-<br />
| Interpret symbols as wildcards <br />
| Treat certain symbols as [[#Wildcards|Wildcards]] for matching simple patterns (similar to [[ReNamer:Regular Expressions|Regular Expressions]]). <br />
<br />
|}<br />
<br />
=== Wildcards ===<br />
<br />
{| class="wikitable"<br />
|-<br />
! Wildcard<br />
! Represents <br />
! Example<br />
|-<br />
| <center><nowiki>*</nowiki></center> <br />
| any number of characters (including numbers, space, underscores, etc.). <br />
| '''abc*''' equals '''abc''' followed by 0 or more characters.<br />
|-<br />
| <center>?</center> <br />
| Any single character (including numbers, space, underscores, etc.) <br />
| '''ab?d''' equals '''abcd''', '''ab1d''', '''ab d''', '''ab_d''', etc.<br />
|-<br />
| <center><nowiki>[]</nowiki></center> <br />
| Brackets enclose a set of characters, any one of which may match a single character at that position. <br />
| '''<nowiki>foo[ab]ar </nowiki>'''equals '''fooaar''' and '''foobar'''<br />
|-<br />
| <center>-</center> <br />
| (only within a pair of brackets) denotes a range of characters. <br />
| '''<nowiki>foo[a-z]ar </nowiki>'''equals '''fooaar''', '''foobar,''' '''foocar,''' '''foodar,''' etc.<br />
|}<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Delete&diff=3475ReNamer:Rules:Delete2022-04-01T00:27:24Z<p>Den4b: Clarified the "skip extension" option.</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Insert|next=ReNamer:Rules:Remove}}<br />
<br />
== Delete Rule ==<br />
<br />
<center>[[Image:DeleteRule.png]]</center><br />
<br />
This rule will delete all characters located between the '''From''' and the '''Until ''' positions. Optionally, it can delete from the specified position till the end of the name. <br />
<br />
The parameters are as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter <br />
! Details<br />
|-<br />
| From <br />
| From which character-position you want to start the deletion.<br />
Select from the following options: <br />
*The starting position (count starts from 1) <br />
*The delimiter from where the deletion starts.<br />
**The delimiter can be a single character or even a string.<br />
**Typically ''', . / ( ) -''' and space are used as delimiters.<br />
<br />
|-<br />
| Until <br />
| Till which point you want to delete:<br />
Select from the following options: <br />
*Count: Specify how many characters to be deleted, starting from the FROM position. <br />
*Delete till a specified delimiter is reached. <br />
**You can use two different delimiters in '''From '''and '''Until''' sections.<br />
**The delimiter can be a single character or even a string.<br />
**Typically ''', . / ( ) -''' and space are used as delimiters.<br />
*Delete all characters till the end.<br />
<br />
|-<br />
| Delete current name<br />
| A shortcut option for deleting the whole current name.<br />
<br />
|-<br />
| Skip extension <br />
| If checked, the file extension will be excluded from the processing and will remain unaffected.<br />
|-<br />
| Right-to-left <br />
| Inverts the normal direction for counting a position, so that the count goes from right and towards left.<br />
<br />
When this option is selected, the "till the end" option in '''Until''' deletes all characters on the left, what we normally regard as the ''beginning'' of the name.<br />
<br />
For example, to keep only the four characters on the right side of the name and delete all the rest of the characters on the left, use:<br />
<br />
* '''From:''' Position 5<br />
* '''Until:''' Till the end<br />
<br />
|-<br />
| Do not remove delimiters <br />
| If you select this option, the delimiters themselves will be retained.<br />
<br />
If you have used two different delimiters in '''From '''and '''Until''' sections, ''both'' of them will be retained.<br />
<br />
|}<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:Delete&diff=3474ReNamer:Rules:Delete2022-04-01T00:25:20Z<p>Den4b: Clarified the "right-to-left" option</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Insert|next=ReNamer:Rules:Remove}}<br />
<br />
== Delete Rule ==<br />
<br />
<center>[[Image:DeleteRule.png]]</center><br />
<br />
This rule will delete all characters located between the '''From''' and the '''Until ''' positions. Optionally, it can delete from the specified position till the end of the name. <br />
<br />
The parameters are as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter <br />
! Details<br />
|-<br />
| From <br />
| From which character-position you want to start the deletion.<br />
Select from the following options: <br />
*The starting position (count starts from 1) <br />
*The delimiter from where the deletion starts.<br />
**The delimiter can be a single character or even a string.<br />
**Typically ''', . / ( ) -''' and space are used as delimiters.<br />
<br />
|-<br />
| Until <br />
| Till which point you want to delete:<br />
Select from the following options: <br />
*Count: Specify how many characters to be deleted, starting from the FROM position. <br />
*Delete till a specified delimiter is reached. <br />
**You can use two different delimiters in '''From '''and '''Until''' sections.<br />
**The delimiter can be a single character or even a string.<br />
**Typically ''', . / ( ) -''' and space are used as delimiters.<br />
*Delete all characters till the end.<br />
<br />
|-<br />
| Delete current name<br />
| A shortcut option for deleting the whole current name.<br />
<br />
|-<br />
| Skip extension <br />
| If this check box is unselected, the extension will be included in the rule.<br />
|-<br />
| Right-to-left <br />
| Inverts the normal direction for counting a position, so that the count goes from right and towards left.<br />
<br />
When this option is selected, the "till the end" option in '''Until''' deletes all characters on the left, what we normally regard as the ''beginning'' of the name.<br />
<br />
For example, to keep only the four characters on the right side of the name and delete all the rest of the characters on the left, use:<br />
<br />
* '''From:''' Position 5<br />
* '''Until:''' Till the end<br />
<br />
|-<br />
| Do not remove delimiters <br />
| If you select this option, the delimiters themselves will be retained.<br />
<br />
If you have used two different delimiters in '''From '''and '''Until''' sections, ''both'' of them will be retained.<br />
<br />
|}<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules&diff=3473ReNamer:Rules2022-03-31T20:26:05Z<p>Den4b: /* Overview of Rules */ User friendly rule names</p>
<hr />
<div>{{Go|up=ReNamer}}<br />
<br />
== Overview of Rules ==<br />
<br />
ReNamer has an extensive set of rules. These rules can be combined together, in a logical sequence, to perform nearly any thinkable operation with the filename. You can also [[ReNamer:Manual editing|manually edit]] the name of any file. <br />
<br />
The table below lists all rules, with a brief description of each rule. <br>The subsequent chapters provide more details for each rule (follow the links). <br />
<br />
{| class="wikitable"<br />
|-<br />
! Rules <br />
! Description<br />
|-<br />
| [[ReNamer:Rules:Insert|Insert]] <br />
| Insert the specified text into the filename: as prefix, as suffix, at the specified position, before- or after the specified text. There is also an option to insert meta tags into the filename.<br />
|-<br />
| [[ReNamer:Rules:Delete|Delete]] <br />
| Delete a portion of the filename, usually defined by character positions: from the specified position, from the occurrence of the specified delimiter, until the specified number of characters, until occurrence of the specified delimiter or till the end. This rule can be set to process the filename in a right-to-left manner.<br />
|-<br />
| [[ReNamer:Rules:Remove|Remove]] <br />
| Remove the specified text from the filename: first, last or all occurrences. Optionally, wildcards can be used within this rule, to remove masked text fragments.<br />
|-<br />
| [[ReNamer:Rules:Replace|Replace]] <br />
| This rule is very much like the '''Remove '''rule (above). It has similar options, except that instead of removing the text fragments, it will replace them with the specified text.<br />
|-<br />
| [[ReNamer:Rules:Rearrange|Rearrange]] <br />
| Chop up the existing file name using any delimiter or position and reuse any/all of the parts in any order to compose a new name.Add your strings, or use the meta tags extracted from the file to compose the new name.<br><br />
|-<br />
| [[ReNamer:Rules:Extension|Extension]] <br />
| Change extension of files to the specified extension, or to the extension automatically detected through the internal database of binary signatures.<br />
|-<br />
| [[ReNamer:Rules:Strip|Strip]] <br />
| Strip all occurrences of the specified characters from the filename. This rule has predefined character sets, like digits, symbols, brackets, but you can also define your own character set.<br />
|-<br />
| [[ReNamer:Rules:Case|Case]] <br />
| Change the case of the filename: capitalize each word, to lower case, to upper case, invert case, or capitalize only the first letter and force the rest to lowercase (as in a sentence). There is also an option to force case for the manually entered fragments, for example: CD, DVD, India, ReNamer, etc.<br />
|-<br />
| [[ReNamer:Rules:Serialize|Serialize]] <br />
| Add incremental numbers to put filenames into an order.<br />
|-<br />
| [[ReNamer:Rules:Randomize|Randomize]]<br />
| Add randomly generated sequences into filenames.<br />
|-<br />
| [[ReNamer:Rules:Padding|Padding]]<br />
| Apply or remove zero padding to/from number sequences, or add text padding using custom characters.<br />
|-<br />
| [[ReNamer:Rules:CleanUp|Clean Up]] <br />
| Cleanup filenames from (or for) commonly used naming conventions for Internet, peer-to-peer networks, and other resources.<br />
|-<br />
| [[ReNamer:Rules:Translit|Translit]] <br />
| Transliterate Non-English characters from different languages into their English/Latin representation. Useful for preparing files for network storage and transfer. Several transliteration maps are built in, and you can define your own maps.<br />
|-<br />
| [[ReNamer:Rules:RegEx|Regular Expressions]] <br />
| <br />
Regular Expressions (RegEx) are used for complex pattern/expression matching and replacing operations. Although it may look complex at first, you can learn it quite easily, using the guide provided in this manual! <br />
<br />
|-<br />
| [[ReNamer:Rules:PascalScript|Pascal Script]] <br />
| Scripting allows programming-aware users to code their own renaming rule using predefined set of functions. This rule uses Pascal/Delphi programming syntax and conventions. Extremely powerful feature in the right hands.<br />
|-<br />
| [[ReNamer:Rules:UserInput|User Input]] <br />
| Rule that simply sets the new names of the files to the names entered in a list (one name per line).<br />
|-<br />
| [[ReNamer:Rules:ReformatDate|Reformat Date]] <br />
| Change format of date/time values in the filename.<br />
|}<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=Test&diff=3470Test2022-03-31T19:48:16Z<p>Den4b: Add greetings in many languages</p>
<hr />
<div>This is TEST article and below is a template that should not get printed.<br />
<br />
{{Test}}<br />
<br />
Still testing now...<br />
<br />
<pre><br />
var greetings = [<br />
'Hello', // English<br />
'¡Hola', // Spanish<br />
'Salut', // French<br />
'Bonjour', // French<br />
'Guten Tag', // German<br />
'Hallo', // German, Dutch<br />
'Goededag', // Dutch<br />
'Γειά', // Greek<br />
'Aloha', // Hawaiian<br />
'Ciao', // Italian<br />
'Сәлем', // Kazakh<br />
'Sveiki', // Latvian<br />
'Здраво', // Serbian, Macedonian<br />
'Cześć', // Polish<br />
'Olá', // Portuguese<br />
'Привет', // Russian<br />
'Здравствуйте', // Russian<br />
'Haai', // Afrikaans<br />
'Вітаю', // Belarusian<br />
'Дзень добры', // Belarusian<br />
'Здравейте', // Bulgarian<br />
'今日は', // Japanese<br />
'你好' // Chinese<br />
];<br />
</pre></div>Den4bhttp://www.den4b.com/w/index.php?title=Localization&diff=3469Localization2022-03-26T18:48:20Z<p>Den4b: /* Auxiliary translation files */ Updated links to Lazarus issue tracker and master translation files.</p>
<hr />
<div>This article describes localization (translation) of applications into different languages.<br />
<br />
Products which support this method of localization:<br />
<br />
* [[ReNamer]] (since v6.0.0.1)<br />
* [[Hasher]] (since v3.1.0.1)<br />
* [[Colors]] (since v2.0.0.1)<br />
* [[Resizer]] (since v1.0.0.0)<br />
* [[RandPass]] (since v1.4.0.0)<br />
* [[Shutter]] (since v4.0.0.1)<br />
<br />
Please carefully study the material in this article before attempting to update or create a translation!<br />
<br />
== Translation files ==<br />
<br />
Translations are stored in '''PO files''' (as produced by [http://en.wikipedia.org/wiki/Gettext gettext]) which are distributed together with the application, inside '''Languages''' folder:<br />
* <tt>Languages\Application.po</tt> &ndash; '''Template''' file.<br />
* <tt>Languages\Application.ru.po</tt> &ndash; '''Russian''' (RU) translation file.<br />
* <tt>Languages\Application.es.po</tt> &ndash; '''Spanish''' (ES) translation file.<br />
* <tt>Languages\Application.fr.po</tt> &ndash; '''French''' (FR) translation file.<br />
* ...<br />
<br />
Template file (<tt>Application.po</tt>) is used for creating translations for new languages and normally should not be edited.<br />
<br />
Translation files (<tt>Application.XX.po</tt>) contain translated text. A '''two-letter language code''' in the file extension identifies a particular language.<br />
<br />
== Create new translations ==<br />
<br />
To create a translation file for a new language:<br />
# Create a copy of <tt>Application.po</tt> (template file)<br />
# Rename it to <tt>Application.XX.po</tt> (translation file), where ''XX'' is a two-letter language code.<br />
# Translate entries to the new langauge using instructions below.<br />
# Populate PO file headers, copy from any other translation file and modify appropriately.<br />
# Save new file using UTF-8 encoding, without byte order mark ([https://en.wikipedia.org/wiki/Byte_order_mark BOM]).<br />
<br />
Example of relevant entries in PO file headers for a new translation file:<br />
<pre><nowiki><br />
msgid ""<br />
msgstr ""<br />
...<br />
"Language: ru\n"<br />
"X-Country: ru\n"<br />
"X-Country-Name: Russia\n"<br />
"X-Language-Name: Russian\n"<br />
"X-Language-Name-Native: Русский\n"<br />
"X-Translators: Your Name <your.email@example.com>\n"<br />
...<br />
</nowiki></pre><br />
<br />
* Language codes are defined in [http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes ISO 639-1]<br />
* Country codes are defined in [http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2].<br />
* In conflicting and ambiguous situations:<br />
*# Name the translation file using <tt>Application.XX_YY.po</tt> format, where ''XX'' is a language code and ''YY'' is a country code.<br />
*# Set <tt>X-Language-Name</tt> header to highlight the difference between translations.<br />
*: For example: "<tt>en_US</tt>" code for ''English (United States)'', "<tt>en_GB</tt>" code for ''English (United Kingdom)''.<br />
<br />
== Editing translation file ==<br />
<br />
The process involves translation of individual textual messages to create a mapping from original text to a different language.<br />
<br />
Translation files (*.po) should be edited with specifically designed translation tools, such as:<br />
* [http://poedit.net/ Poedit] &ndash; for Windows, Linux and Mac.<br />
<br />
Notes for advanced users:<br />
* Translation files could also be edited manually using a text editor, but this is highly discouraged as tiny mistakes can result in corruption of the entire file.<br />
* [http://poedit.net/ Poedit] versions prior to 1.7 forcefully wrap long entries causing "noise" in diffs, so PO files need to be cleaned via <code>msgcat --no-wrap</code> before committing. [http://github.com/vslavik/poedit/issues/94].<br />
<br />
== Guidelines for translators ==<br />
<br />
Guidelines for translators:<br />
* Use the most up-to-date language files from the <u>latest development version</u> (Beta versions).<br />
* Try not the exceed the length of the translated text, comparing to the length of the original text.<br />
*: Some components may not fit longer text, so it is better to make it shorter rather than longer. <br />
* Beware of the special formatting, symbols and placeholders, e.g. "\n", "%s", "%d".<br />
*: Make sure to maintain such formatting, translate only actual words.<br />
* If you don't have a good translation for some text, just leave those blank.<br />
*: Other people may be able to fill in the blanks later.<br />
* Try to use formal but easy to understand language.<br />
*: Avoid the use of slang, which may not be understood by some readers.<br />
<br />
Attribution to translators:<br />
* Add your name to "<tt>X-Translators:</tt>" field in PO file headers.<br />
* Please keep names of other translators (separate multiple names with a comma).<br />
<br />
== Auxiliary translation files ==<br />
<br />
In addition to the main translation file, you may find auxiliary translation files in subfolders. These correspond to 3rd party components, for example, "LCLStrConsts" subfolder contains messages that appear in Lazarus Component Library (LCL). We do not handle the updates to auxiliary translation files directly, because we source that from the original vendor. If you wish, you can submit your improvements directly to the vendor.<br />
<br />
Updates for "LCLStrConsts" translations should submitted to the [https://www.lazarus-ide.org/ Lazarus IDE] project, using the following steps:<br />
<br />
# The translation should be based on the [https://gitlab.com/freepascal.org/lazarus/lazarus/-/tree/main/lcl/languages latest development files].<br />
# The translation file can be submitted via the [https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues issue tracker] or as a [https://gitlab.com/freepascal.org/lazarus/lazarus/-/merge_requests merge request] (preferred).<br />
<br />
== Loading specific language == <br />
<br />
All available language files are automatically added to the "Languages" menu on startup. Select a desired language and restart the application.<br />
<br />
When selected language is set to "''Autodetect''" mode:<br />
* Application automatically tries to recognize system language and loads appropriate translation file.<br />
* It is also possible to load a specific language file, by either:<br />
*# Adding "<tt>--lang XX</tt>" command line parameters to the application, where ''XX'' is a two-letter language code.<br />
*# Setting "<tt>LANG</tt>" environmental variable to a two-letter language code.<br />
<br />
== Publishing your translation ==<br />
<br />
Please send new and updated translation files via email, as attachments.<br />
<br />
The email address can be found in the ''About'' dialog of every application.<br />
<br />
[[Category:Localization]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Pascal_Script&diff=3468ReNamer:Pascal Script2022-03-07T18:47:12Z<p>Den4b: /* Tips */ Minor corrections.</p>
<hr />
<div>{{Up|ReNamer}}<br />
<br />
The [[ReNamer:Rules:PascalScript|PascalScript Rule]] in [[ReNamer]] uses Pascal Script component to allow users to program their own renaming rule. <br />
<br />
To master Pascal Script, follow these steps: <br />
<br />
# Learn the basic syntax and concepts of Pascal Script<br />
# Understand the specific variables, procedures and functions that are defined within ReNamer<br />
# Learn how to use these variables/functions/procedures in scripts <br />
<br />
Let us see these steps in more details.<br />
<br />
== Learn the basics ==<br />
<br />
To learn the basics of Pascal Script, please refer to the [[ReNamer:Pascal Script:Quick guide|Pascal Script Quick Guide]].<br />
<br />
== Types and functions ==<br />
<br />
In this section, we will see all types, procedures and functions which can be used ''within'' ReNamer.<br />
<br />
*[[ReNamer:Pascal Script:Types|Types]] <br />
*[[ReNamer:Pascal Script:Functions|Procedures and functions]]<br />
<br />
<span style="color: red">Note:</span> Most of these are <u>not</u> part of the "standard" Pascal Script, so you may not find them in other applications.<br />
<br />
== Script cookbook ==<br />
<br />
In this section, we will see how to write scripts for some common renaming tasks. <br />
<br />
They also demonstrate how to use ReNamer's types, procedures and functions. <br />
<br />
# [[ReNamer:Pascal Script:FileName|How to rename a file (using the FileName variable)]]<br />
# [[ReNamer:Pascal Script:FileName Utilities|How to skip extention (basic FileName utilities)]]<br />
# [[ReNamer:Pascal Script:WideUpperCase|How to convert the filename to ALLCAPS (the WideUpperCase function)]]<br />
# [[ReNamer:Pascal Script:Unicode String Handling Routines|How to operate on words (Unicode string-handling routines)]]<br />
# [[ReNamer:Pascal Script:Basic Conversion Routines|How to serialize files (basic conversion routines)]]<br />
# [[ReNamer:Pascal Script:Initialization of variables|How to initialize variables]] <br />
# [[ReNamer:Pascal Script:Dialogs|How to create interactive dialogs]]<br />
# [[ReNamer:Pascal Script:FilePath|How to work with folders and paths (FilePath constant)]]<br />
# [[ReNamer:Pascal Script:Break script execution|How to break the script execution]]<br />
# [[ReNamer:Pascal Script:Read file content|How to read file content]]<br />
# [[ReNamer:Pascal Script:Import functions|How to import functions]]<br />
# [[ReNamer:Pascal Script:SplitPath|How to split file path into parts (folders, base, extension)]]<br />
# [[ReNamer:Pascal Script:Reuse variable|How to store/load variables for later reuse]]<br />
<br />
== Scripts repository ==<br />
<br />
* Official [[ReNamer:Scripts|Scripts Repository]].<br />
* The [http://www.den4b.com/forum/ Forum] contains several ready scripts.<br />
<br />
Study them and adopt them for your purpose.<br />
<br />
== Tips ==<br />
<br />
A few quick tips: <br />
<br />
* In Pascal Script, ReNamer has defined the '''FileName''' variable to represent the "New Name" of a file. Therefore, in your script, you will have to manipulate this variable to change the filename. Changes to the '''FileName''' variable do not actually change the name of the file, they simply change the value in the "New Name" column. Changes are applied only when you click the "Rename" button.<br />
* The '''FilePath''' constant holds the original path of the file. It allows you to access the file directly.<br />
* ReNamer supports User Defined Functions (UDF) and also [[ReNamer:Pascal Script:Import functions|importing of external functions from DLLs]].<br />
* Try to use '''WideString '''[[ReNamer:Pascal Script:Types|type]] instead of an ordinary '''String''' type. This will allow ReNamer to handle Unicode filenames. In other words, it will be able to handle non-English scripts, such as Cyrillic, Asian, German, French, etc.<br />
* You may use <code>{$INCLUDE 'filename.inc'}</code> directive to include code from an external file, allowing for easier reuse and better organization of your code. ''Available since v6.5.0.1 Beta.''<br />
<br />
<div style="color: red"><br />
'''Warnings:'''<br />
* Do not override ReNamer's built-in variables, types and functions.<br />
* Some functions are able to alter your file system, e.g. create new folders, change file content, delete files, etc. Use such functions with caution!<br />
* Remember that scripts are executed during the Preview (not the Rename) operation and can also get executed automatically if Auto Preview is enabled.<br />
</div ><br />
<br />
== External links ==<br />
<br />
* [http://www.remobjects.com/ps RemObjects Pascal Script]<br />
: Developers of the Pascal Script component.<br />
* [http://www.delphibasics.co.uk/ Delphi Basics]<br />
: Help and reference for the fundamentals of the Delphi/Pascal language.<br />
<br />
[[Category:ReNamer]]<br />
[[Category:Pascal Script]]</div>Den4bhttp://www.den4b.com/w/index.php?title=Compatibility&diff=3467Compatibility2022-02-07T13:01:34Z<p>Den4b: /* Mac and Linux */ OS links updated</p>
<hr />
<div>This article describes different compatibility aspects of the software, specifically operating systems, compatibility issues and different workarounds.<br />
<br />
All applications on this site are developed for [http://en.wikipedia.org/wiki/Microsoft_Windows Microsoft Windows] platform. Even though there is no official support for other platforms apart from Windows, many people have successfully used these applications on [http://en.wikipedia.org/wiki/Mac_OS_X Mac] and [http://en.wikipedia.org/wiki/Linux Linux] platforms using so called emulation software. <br />
<br />
== Windows Vista and later ==<br />
<br />
In [http://en.wikipedia.org/wiki/Windows_Vista Windows Vista] an new security feature was introduced called [http://en.wikipedia.org/wiki/User_Account_Control User Account Control (UAC)] which prevents unauthorized changes to system configuration on your computer. It works by prompting you for permission when a task requires administrative rights, such as installing software or changing settings that affect other users.<br />
<br />
UAC presents a problem for software which was designed in the days of [http://en.wikipedia.org/wiki/Windows_9x Windows 9x] series of operating systems, which did not include any sophisticated user account control features such as UAC. It was a common practice for software to store configuration data and other documents in the installation directory of the application, making everything compact, isolated and self-contained. This practice doesn't always work in the recent operating systems such as Windows Vista, 7, 8 and later versions.<br />
<br />
The most common installation path for software in Windows is ''Program Files'' directory, located in path "C:\Program Files" or similar. UAC treats this location as a system folder, hence, forbids normal users from writing to this folder. UAC requires ''administrative privileges'' in order to make modifications to the content of this folder. <br />
<br />
Another place where ''administrative privileges'' may be required is the registry, where most of locations are now protected from modifications. Applications sometimes have to write to the registry in order to use some of the functionality, for example: automatically start application on login.<br />
<br />
=== Workarounds for UAC issues ===<br />
<br />
{| class="wikitable"<br />
! Title<br />
! Description<br />
|-<br />
| Turn off UAC<br />
| Open Control Panel and find User Accounts controls, where you can easily turn off User Account Control. Although it helps eliminate the issues, but it comes at a cost of lowered down security.<br />
|-<br />
| Run as Administrator<br />
| When launching applications, user can specify to run it with administrative privileges. Just right-click on the application icon and select "Run as administrator".<br />
|-<br />
| Custom installation path<br />
| Instead of installing application into the default and problematic "Program Files" folder, choose a custom path which is not shared by any system applications. For example "<tt>C:\Tools\</tt>", or even "<tt>D:\Programs\</tt>" on a another drive if available, and so on.<br />
|-<br />
| Compatibility mode<br />
| Windows compatibility mode allows the use of applications which require write access to the installation folder even when they are installed in a protected folder such as "Program Files". In this mode, when application will try to create files/folders in the installation folder they will be silently redirected by the operating system to so called ''VirtualStore'' location.<br />
<br />
For additional information on locating application data and the ''VirtualStore'' concept, please see [[Application Data Storage]] article.<br />
|}<br />
<br />
== Mac and Linux ==<br />
<br />
[https://en.wikipedia.org/wiki/MacOS Mac] and [https://en.wikipedia.org/wiki/Linux Linux] operating systems are not directly supported, however, there are ways to run and use applications developed for Windows on these platforms. Below is a brief description of the two possible approaches.<br />
<br />
* Compatibility layers - using special wrapping software to run applications developed for Windows inside your native operating system.<br />
* Virtualization platforms - setting up a virtual machine with Windows operating system inside your native operating system.<br />
<br />
Further down are lists of products which make it all possible. These are not exhaustive lists by any means.<br />
<br />
=== Compatibility layers ===<br />
<br />
Compatibility layers try to simulate a Windows environment for the application by providing alternative implementations of functions of Windows and other necessary libraries. This is a simplest approach but may not work for all applications and possibly not all software features will be usable.<br />
<br />
{| class="wikitable"<br />
! Product<br />
! OS<br />
! Cost<br />
! Description<br />
<br />
|-<br />
| [http://www.playonmac.com/ PlayOnMac]<br />
| Mac OS X<br />
| Free<br />
| Easily install and use numerous games and software designed to run on Windows.<br />
<br />
|-<br />
| [http://www.playonlinux.com/ PlayOnLinux]<br />
| Linux<br />
| Free<br />
| Easily install and use numerous games and software designed to run on Windows.<br />
<br />
|-<br />
| [http://q4wine.brezblock.org.ua/ Q4Wine]<br />
| Linux, FreeBSD<br />
| Free<br />
| It helps you manage wine prefixes and installed applications.<br />
<br />
|-<br />
| [http://winebottler.kronenberg.org/ WineBottler]<br />
| Mac OS X<br />
| Free<br />
| Turn Windows-based programs into Mac apps.<br />
<br />
|-<br />
| [http://www.winehq.org/ Wine]<br />
| Linux, BSD, Solaris, Mac OS X<br />
| Free<br />
| Run Windows applications on Linux, BSD, Solaris and Mac OS X.<br />
<br />
|- <br />
| [http://www.codeweavers.com/products/ CrossOver]<br />
| Mac, Linux<br />
| Paid<br />
| Run Windows applications on Linux, easily and affordably.<br />
<br />
|}<br />
<br />
=== Virtualization platforms ===<br />
<br />
Virtualization allows you to install and run a guest operating systems within your native host operating system. In this case, you can install and run Windows inside Mac and Linux as if it was an application by itself. This approach may be more complex depending of the level of user experience with installing Windows operating system.<br />
<br />
{| class="wikitable"<br />
! Product<br />
! Host OS<br />
! Cost<br />
|-<br />
| [https://www.virtualbox.org/ VirtualBox]<br />
| Windows, Linux, Mac, Solaris<br />
| Free<br />
|-<br />
| [https://www.parallels.com/ Parallels]<br />
| Mac<br />
| Paid<br />
|-<br />
| [https://www.vmware.com/products/workstation-player.html VMware Workstation]<br />
| Windows, Linux<br />
| Free/Paid<br />
|}</div>Den4bhttp://www.den4b.com/w/index.php?title=Compatibility&diff=3466Compatibility2022-02-07T12:59:49Z<p>Den4b: /* Virtualization platforms */ Updated product info</p>
<hr />
<div>This article describes different compatibility aspects of the software, specifically operating systems, compatibility issues and different workarounds.<br />
<br />
All applications on this site are developed for [http://en.wikipedia.org/wiki/Microsoft_Windows Microsoft Windows] platform. Even though there is no official support for other platforms apart from Windows, many people have successfully used these applications on [http://en.wikipedia.org/wiki/Mac_OS_X Mac] and [http://en.wikipedia.org/wiki/Linux Linux] platforms using so called emulation software. <br />
<br />
== Windows Vista and later ==<br />
<br />
In [http://en.wikipedia.org/wiki/Windows_Vista Windows Vista] an new security feature was introduced called [http://en.wikipedia.org/wiki/User_Account_Control User Account Control (UAC)] which prevents unauthorized changes to system configuration on your computer. It works by prompting you for permission when a task requires administrative rights, such as installing software or changing settings that affect other users.<br />
<br />
UAC presents a problem for software which was designed in the days of [http://en.wikipedia.org/wiki/Windows_9x Windows 9x] series of operating systems, which did not include any sophisticated user account control features such as UAC. It was a common practice for software to store configuration data and other documents in the installation directory of the application, making everything compact, isolated and self-contained. This practice doesn't always work in the recent operating systems such as Windows Vista, 7, 8 and later versions.<br />
<br />
The most common installation path for software in Windows is ''Program Files'' directory, located in path "C:\Program Files" or similar. UAC treats this location as a system folder, hence, forbids normal users from writing to this folder. UAC requires ''administrative privileges'' in order to make modifications to the content of this folder. <br />
<br />
Another place where ''administrative privileges'' may be required is the registry, where most of locations are now protected from modifications. Applications sometimes have to write to the registry in order to use some of the functionality, for example: automatically start application on login.<br />
<br />
=== Workarounds for UAC issues ===<br />
<br />
{| class="wikitable"<br />
! Title<br />
! Description<br />
|-<br />
| Turn off UAC<br />
| Open Control Panel and find User Accounts controls, where you can easily turn off User Account Control. Although it helps eliminate the issues, but it comes at a cost of lowered down security.<br />
|-<br />
| Run as Administrator<br />
| When launching applications, user can specify to run it with administrative privileges. Just right-click on the application icon and select "Run as administrator".<br />
|-<br />
| Custom installation path<br />
| Instead of installing application into the default and problematic "Program Files" folder, choose a custom path which is not shared by any system applications. For example "<tt>C:\Tools\</tt>", or even "<tt>D:\Programs\</tt>" on a another drive if available, and so on.<br />
|-<br />
| Compatibility mode<br />
| Windows compatibility mode allows the use of applications which require write access to the installation folder even when they are installed in a protected folder such as "Program Files". In this mode, when application will try to create files/folders in the installation folder they will be silently redirected by the operating system to so called ''VirtualStore'' location.<br />
<br />
For additional information on locating application data and the ''VirtualStore'' concept, please see [[Application Data Storage]] article.<br />
|}<br />
<br />
== Mac and Linux ==<br />
<br />
[http://en.wikipedia.org/wiki/Mac_OS_X Mac] and [http://en.wikipedia.org/wiki/Linux Linux] operating systems are not directly supported, however, there are ways to run and use applications developed for Windows on these platforms. Below is a brief description of the two possible approaches.<br />
<br />
* Compatibility layers - using special wrapping software to run applications developed for Windows inside your native operating system.<br />
* Virtualization platforms - setting up a virtual machine with Windows operating system inside your native operating system.<br />
<br />
Further down are lists of products which make it all possible. These are not exhaustive lists by any means.<br />
<br />
=== Compatibility layers ===<br />
<br />
Compatibility layers try to simulate a Windows environment for the application by providing alternative implementations of functions of Windows and other necessary libraries. This is a simplest approach but may not work for all applications and possibly not all software features will be usable.<br />
<br />
{| class="wikitable"<br />
! Product<br />
! OS<br />
! Cost<br />
! Description<br />
<br />
|-<br />
| [http://www.playonmac.com/ PlayOnMac]<br />
| Mac OS X<br />
| Free<br />
| Easily install and use numerous games and software designed to run on Windows.<br />
<br />
|-<br />
| [http://www.playonlinux.com/ PlayOnLinux]<br />
| Linux<br />
| Free<br />
| Easily install and use numerous games and software designed to run on Windows.<br />
<br />
|-<br />
| [http://q4wine.brezblock.org.ua/ Q4Wine]<br />
| Linux, FreeBSD<br />
| Free<br />
| It helps you manage wine prefixes and installed applications.<br />
<br />
|-<br />
| [http://winebottler.kronenberg.org/ WineBottler]<br />
| Mac OS X<br />
| Free<br />
| Turn Windows-based programs into Mac apps.<br />
<br />
|-<br />
| [http://www.winehq.org/ Wine]<br />
| Linux, BSD, Solaris, Mac OS X<br />
| Free<br />
| Run Windows applications on Linux, BSD, Solaris and Mac OS X.<br />
<br />
|- <br />
| [http://www.codeweavers.com/products/ CrossOver]<br />
| Mac, Linux<br />
| Paid<br />
| Run Windows applications on Linux, easily and affordably.<br />
<br />
|}<br />
<br />
=== Virtualization platforms ===<br />
<br />
Virtualization allows you to install and run a guest operating systems within your native host operating system. In this case, you can install and run Windows inside Mac and Linux as if it was an application by itself. This approach may be more complex depending of the level of user experience with installing Windows operating system.<br />
<br />
{| class="wikitable"<br />
! Product<br />
! Host OS<br />
! Cost<br />
|-<br />
| [https://www.virtualbox.org/ VirtualBox]<br />
| Windows, Linux, Mac, Solaris<br />
| Free<br />
|-<br />
| [https://www.parallels.com/ Parallels]<br />
| Mac<br />
| Paid<br />
|-<br />
| [https://www.vmware.com/products/workstation-player.html VMware Workstation]<br />
| Windows, Linux<br />
| Free/Paid<br />
|}</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Regular_Expressions&diff=3465ReNamer:Regular Expressions2022-01-24T08:54:19Z<p>Den4b: Use for renaming files.</p>
<hr />
<div>{{Up|ReNamer}}<br />
<br />
== Introduction ==<br />
<br />
Regular Expressions (RegEx) is a syntax for specifying patterns of text to search and replace, which can be used for renaming files via the [[ReNamer:Rules:RegEx|Regular Expressions renaming rule]]. Special metacharacters allow you to specify, for instance, that a particular string you are looking for occurs at the beginning or end of a line, or contains N recurrences of a certain character.<br />
<br />
Metacharacters, such as <span class="hl-orange">$ . ^ { [ ( | ) * + ? \</span> are ''interpreted'' according to their individual meaning, instead of finding a literal match for them. <br />
<br />
In this document, RegEx patterns are shown in <span class="hl-orange">bold orange</span>. The subject text which is checked against a RegEx pattern for a possible match is shown in '''bold black'''. Parts of the subject text are color-coded to provide a clue as to why a certain part matches (<span class="hl-teal">green</span> color), or does <u>not</u> match (<span class="hl-red">red</span> color).<br />
<br />
== Simple matches ==<br />
<br />
When the search string does not contain any metacharacters, the RegEx engine works like "normal" search. (it tries to find an exact copy of the search string.) (This is also known as "literal match"). <br />
<br />
If you want to find a literal match for a metacharacter, put a backslash '''\''' ''before'' it. (The <span class="hl-orange">\</span> character is called "''escape character''", because it lets the metacharacter escape from its special duty, and lets it act as a normal character. Its combination with a metacharacter is called "''escape sequence''"). <br />
<br />
For example, metacharacter <span class="hl-orange">^</span> matches the beginning of string, but <span class="hl-orange">\^</span> matches the character <span class="hl-teal">^</span>. <br />
<br />
Note that the RegEx pattern <span class="hl-orange">\\</span> matches the character <span class="hl-teal">\</span>. <br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx pattern<br />
! Matches<br />
! Remarks<br />
|-<br />
| <center><span class="hl-orange">foobar</span></center> <br />
| <center><span class="hl-teal">foobar</span></center> <br />
| This RegEx pattern does not contain any metacharacters; so all characters are matched literally.<br />
|-<br />
| <center><span class="hl-orange">\^FooBarPtr</span></center><br />
| <center><span class="hl-teal">^FooBarPtr</span></center><br />
| The <span class="hl-orange">\^</span> escape sequence searches for the character '''^''' ''literally'' .<br />
|}<br />
<br />
== Escape sequences ==<br />
<br />
We already saw one use of escape sequence (above). <br />
<br />
Specific escape sequences are interpreted as special conditions, as listed below. <br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx pattern<br />
! matches<br />
|-<br />
| <center><span class="hl-orange">\xnn</span></center> <br />
| Character represented by the hex code ''nn''<br />
|-<br />
| <center><span class="hl-orange">\x{nnnn}</span></center> <br />
| two bytes char with hex code nnnn (unicode)<br />
|-<br />
| <center><span class="hl-orange">\t</span></center> <br />
| tab (HT/TAB), same as \x09 (Hex 09)<br />
|-<br />
| <center><span class="hl-orange">\n</span></center> <br />
| new line (NL), same as \x0a (Hex 0a)<br />
|-<br />
| <center><span class="hl-orange">\r</span></center> <br />
| carriage return (CR), same as \x0d (Hex 0d)<br />
|-<br />
| <center><span class="hl-orange">\f</span></center> <br />
| form feed (FF), same as \x0c (Hex 0c)<br />
|-<br />
| <center><span class="hl-orange">foo\x20bar</span></center> <br />
| matches <span class="hl-teal">foo bar</span> (note the space in the middle), but does ''not'' match '''foobar'''<br />
|-<br />
| <center><span class="hl-orange">\tfoobar</span></center> <br />
| matches <span class="hl-teal">foobar</span> preceded by a tab (the tab is needed for the match)<br />
|}<br />
<br />
Note that the tab, new line, carriage return, and form feed are known as "white spaces". But RegEx can distinguish between them. This allows you to make high-precision searches. <br />
<br />
== Character classes ==<br />
<br />
A character class is a list of characters surrounded by square brackets "<span class="hl-orange">[</span>" and "<span class="hl-orange">]</span>", which will match any one (and only one) character from the list. <br />
<br />
Note that:<br />
<br />
* The characters are not separated with a comma or a space. <br />
* If you repeat any character in the list, it is considered only once (duplicates are ignored). <br />
* A hyphen "<span class="hl-orange">-</span>" is used to indicate range of characters.<br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx Pattern<br />
! Remarks<br />
|-<br />
| <center><span class="hl-orange">[abcdef]</span></center> <br />
| Matches <span class="hl-teal">a</span>, <span class="hl-teal">b</span>, <span class="hl-teal">c</span>, <span class="hl-teal">d</span>, <span class="hl-teal">e</span>, or <span class="hl-teal">f</span> (only ''one'' character), but no other characters<br />
|-<br />
| <center><span class="hl-orange">[c-m]</span></center> <br />
| Matches any one (and only one) of the small alphabetical characters, from <span class="hl-teal">c</span> to <span class="hl-teal">m</span><br />
|-<br />
| <center><span class="hl-orange">[G-J]</span></center> <br />
| Matches any one (and only one) of the capital alphabetical characters from <span class="hl-teal">G</span> to <span class="hl-teal">J</span><br />
|-<br />
| <center><span class="hl-orange">[a-zA-Z]</span></center> <br />
| Matches any one (and only one) of the alphabetical characters (capital or small)<br />
|-<br />
| <center><span class="hl-orange">[5-8]</span></center> <br />
| Matches any one (and only one) of numerical characters from <span class="hl-teal">5</span> to <span class="hl-teal">8</span><br />
|-<br />
| <center><span class="hl-orange">[\n-\x1F]</span></center> <br />
| <br />
Matches any one (and only one) of characters with their ordinal value in range from <span class="hl-teal">#10</span> (<span class="hl-orange">\n</span>) to <span class="hl-teal">#31</span> (<span class="hl-orange">\x1F</span>), which in [https://en.wikipedia.org/wiki/ASCII ASCII] character table correspond to some non-printable characters.<br />
<br />
Note the use of [[#Escape_sequences|escape sequences]] inside of this example.<br />
<br />
|}<br />
<br />
There are some special conditions: <br />
<br />
*If you do not want any of the characters in the specified class, then place <span class="hl-orange">^</span> at the very beginning of the list (RegEx interprets that as "none of the characters listed in this class"). <br />
*If you want <span class="hl-orange">[</span> or <span class="hl-orange">]</span> itself to be a member of a class, put it at the start or end of the list, or create a [[#Simple_.28literal.29_matches|escape sequence]] (by putting <span class="hl-orange">\</span> before it).<br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx Pattern<br />
! Remarks<br />
|-<br />
| <center><span class="hl-orange">[-az]</span></center> <br />
| matches <span class="hl-teal">a</span>, <span class="hl-teal">z</span>, and <span class="hl-teal">-</span><br/>(since <span class="hl-orange">–</span> is put at the beginning, the escape sequence is not needed)<br />
|-<br />
| <center><span class="hl-orange">[a\-z]</span></center> <br />
| matches <span class="hl-teal">a</span>, <span class="hl-teal">z</span>, and <span class="hl-teal">-</span><br/>(since <span class="hl-orange">–</span> is ''not'' at the beginning/end, the escape sequence ''is'' needed)<br />
|-<br />
| <center><span class="hl-orange">[^0-9]</span></center> <br />
| matches any ''non-digit'' character<br />
|-<br />
| <center><span class="hl-orange">[]-a]</span></center> <br />
| matches any character from <span class="hl-teal">]</span> to <span class="hl-teal">a</span>. <br>(since <span class="hl-orange">]</span> is at the beginning, the escape sequence ''is not'' needed)<br />
|-<br />
| <center><span class="hl-orange">foob[aeiou]r</span></center> <br />
| Matches with '''foob<span class="hl-teal">a</span>r''', '''foob<span class="hl-teal">e</span>r''', etc. but not '''foob<span class="hl-red">b</span>r''', '''foob<span class="hl-red">c</span>r''', etc.<br />
|-<br />
| <center><span class="hl-orange">foob[^aeiou]r</span></center> <br />
| Matches with '''foob<span class="hl-teal">b</span>r''', '''foob<span class="hl-teal">c</span>r''' etc. but not '''foob<span class="hl-red">a</span>r''', '''foob<span class="hl-red">e</span>r''', etc.<br />
|}<br />
<br />
== Predefined classes ==<br />
<br />
Some of the character classes are used so often that RegEx has predefined escape sequences to represent them. <br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx Pattern<br />
! Remarks<br />
|-<br />
| <center><span class="hl-orange">\w</span></center> <br />
| an alphanumeric character, including an ''underscore'' ('''_''')<br />
|-<br />
| <center><span class="hl-orange">\W</span></center> <br />
| a non-alphanumeric character<br />
|-<br />
| <center><span class="hl-orange">\d</span></center> <br />
| a numeric character<br />
|-<br />
| <center><span class="hl-orange">\D</span></center> <br />
| a non-numeric character<br />
|-<br />
| <center><span class="hl-orange">\s</span></center> <br />
| any space (same as the <span class="hl-orange">[ \t\n\r\f]</span> class)<br />
|-<br />
| <center><span class="hl-orange">\S</span></center> <br />
| a non space<br />
|-<br />
| <center><span class="hl-orange">.</span></center> <br />
| any character in line (the symbol is just a dot)<br />
|}<br />
<br />
Notice that the capitalized letter is used to negate (for example, compare <span class="hl-orange">\w</span> with <span class="hl-orange">\W</span>) <br />
<br />
== Word and text boundaries ==<br />
<br />
A word boundary <span class="hl-orange">\b</span> matches a position between a word character <span class="hl-orange">\w</span> and a non-word character <span class="hl-orange">\W</span>. For the purpose of a word boundary position, the start and end of text will be treated as non-word characters <span class="hl-orange">\W</span>. These markers are commonly used for matching patterns as whole words, while ignoring occurrences within words.<br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx Pattern<br />
! Remarks<br />
|-<br />
| <center><span class="hl-orange">\b</span></center> <br />
| word boundary<br />
|-<br />
| <center><span class="hl-orange">\B</span></center> <br />
| not word boundary<br />
|-<br />
| <center><span class="hl-orange">\A</span></center> <br />
| start of text (<span class="hl-orange">^</span> is an alternative)<br />
|-<br />
| <center><span class="hl-orange">\Z</span></center> <br />
| end of text (<span class="hl-orange">$</span> is an alternative)<br />
|}<br />
<br />
For example, <span class="hl-orange">\bhis\b</span> will search for a whole word '''his''', but will ignore '''<span class="hl-red">t</span>his''', '''his<span class="hl-red">tory</span>''' or '''<span class="hl-red">w</span>his<span class="hl-red">tle</span>'''.<br />
<br />
== Iterators ==<br />
<br />
Iterators (quantifiers) are meta-characters that specify how many times the ''preceding'' expression has to repeat. For example, finding a numeric sequence exactly 3 to 5 digits long.<br />
<br />
Iterators can be 'Greedy' or 'Non-Greedy'. Greedy means the expression grabs as ''much'' matching text as possible. In contrast, the non-greedy expression tries to match as ''little'' as possible. <br />
<br />
All iterators are greedy by default. Adding <span class="hl-orange">?</span> (question mark) at the end of an iterator makes it non-greedy.<br />
<br />
For example: <br />
<br />
* when <span class="hl-orange">b+</span> (a greedy expression) is applied to string '''abbbbc''', it matches '''bbbb''' (as many as possible), <br />
* but when <span class="hl-orange">b+?</span> (a non-greedy expression) is applied to '''abbbbc''', it matches only '''b''' (as few as possible).<br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx pattern<br />
! Remarks<br />
! Greedy?<br />
! Remarks<br />
|-<br />
| <center><span class="hl-orange">*</span></center> <br />
| zero or more <br />
| <center>Yes</center> <br />
| equivalent to <span class="hl-orange">{0,}</span><br />
|-<br />
| <center><span class="hl-orange">+</span></center> <br />
| one or more <br />
| <center>Yes</center> <br />
| equivalent to <span class="hl-orange">{1,}</span><br />
|-<br />
| <center><span class="hl-orange">?</span></center> <br />
| zero or one <br />
| <center>Yes</center> <br />
| equivalent to <span class="hl-orange">{0,1}</span><br />
|-<br />
| <center><span class="hl-orange">{n}</span></center> <br />
| exactly ''n'' times <br />
| <center>Yes</center> <br />
| <br />
|-<br />
| <center><span class="hl-orange">{n,}</span></center> <br />
| at least ''n'' times <br />
| <center>Yes</center> <br />
| <br />
|-<br />
| <center><span class="hl-orange">{n,m}</span></center> <br />
| at least ''n'' but not more than ''m'' times <br />
| <center>Yes</center> <br />
| <br />
|-<br />
| <center><span class="hl-orange">*?</span></center> <br />
| zero or more <br />
| <center>No</center> <br />
| equivalent to <span class="hl-orange">{0,}?</span><br />
|-<br />
| <center><span class="hl-orange">+?</span></center> <br />
| one or more <br />
| <center>No</center> <br />
| equivalent to <span class="hl-orange">{1,}?</span><br />
|-<br />
| <center><span class="hl-orange">??</span></center> <br />
| zero or one <br />
| <center>No</center> <br />
| equivalent to <span class="hl-orange">{0,1}?</span><br />
|-<br />
| <center><span class="hl-orange">{n}?</span></center> <br />
| exactly ''n'' times <br />
| <center>No</center> <br />
| <br />
|-<br />
| <center><span class="hl-orange">{n,}?</span></center> <br />
| at least ''n'' times <br />
| <center>No</center> <br />
| <br />
|-<br />
| <center><span class="hl-orange">{n,m}?</span></center> <br />
| at least ''n'' but not more than ''m'' times <br />
| <center>No</center> <br />
| <br />
|}<br />
<br />
Let us see some examples: <br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx pattern<br />
! Remarks<br />
|-<br />
| <center><span class="hl-orange">foob.*r</span></center> <br />
| matches '''foob<span class="hl-teal">a</span>r''', '''foob<span class="hl-teal">alkjdflkj9</span>r''' and '''foobr'''<br />
|-<br />
| <center><span class="hl-orange">foob.+r</span></center> <br />
| matches '''foob<span class="hl-teal">a</span>r''', '''foob<span class="hl-teal">alkjdflkj9</span>r''' but not '''foobr'''<br />
|-<br />
| <center><span class="hl-orange">foob.?r</span></center> <br />
| matches '''foob<span class="hl-teal">a</span>r,''' '''foob<span class="hl-teal">b</span>r''' and '''foobr''' but not '''foob<span class="hl-red">alkj9</span>r'''<br />
|-<br />
| <center><span class="hl-orange">fooba{2}r</span></center> <br />
| matches '''foob<span class="hl-teal">aa</span>r'''<br />
|-<br />
| <center><span class="hl-orange">fooba{2,}r</span></center> <br />
| matches '''foob<span class="hl-teal">aa</span>r,''' '''foob<span class="hl-teal">aaa</span>r''', '''foob<span class="hl-teal">aaaa</span>r''' etc. but not '''foob<span class="hl-red">a</span>r'''<br />
|-<br />
| <center><span class="hl-orange">fooba{2,3}r</span></center> <br />
| matches '''foob<span class="hl-teal">aa</span>r''', or '''foob<span class="hl-teal">aaa</span>r''' but not '''foob<span class="hl-red">aaaa</span>r''' or '''foob<span class="hl-red">a</span>r'''<br />
|}<br />
<br />
== Alternatives ==<br />
<br />
A RegEx expression can have multiple alternative characters or subexpressions. The metacharacter <span class="hl-orange">|</span> is used to separate the alternatives. <br />
<br />
For example, <span class="hl-orange">fee|fie|foe</span> will match with '''fee''', '''fie''', or '''foe''' in the target string. <br />
<br />
It is difficult to understand where each alternative starts and ends. This is why it is a common practice to include alternatives in parentheses, to make it easier to understand. <br />
<br />
For example, <span class="hl-orange">fee|fie|foe</span> can be written as <span class="hl-orange">f(e|i|o)e</span>, to make it easier to understand. <br />
<br />
Alternatives are tried from left to right, so the first alternative found for which the entire expression matches, is the one that is chosen. For example, when matching <span class="hl-orange">foo|foot</span> against '''barefoot''', only the '''foo''' part will match, because that is the first alternative tried, and it successfully matches the target string. (This is important when you are capturing matched text using parentheses.) <br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx Pattern<br />
! Remarks<br />
|-<br />
| <span class="hl-orange">foo(bar&#124;foo)</span> <br />
| matches '''foobar''' or '''foofoo'''<br />
|}<br />
<br />
Also remember that alternatives cannot be used inside a character class (square brackets), because <span class="hl-orange">|</span> is interpreted as a literal within <span class="hl-orange">[]</span>. That means <span class="hl-orange">[fee|fie|foe]</span> is same as <span class="hl-orange">[feio|]</span>. (The other characters are treated as duplicates, and ignored).<br />
<br />
== Subexpressions ==<br />
<br />
Parts of any RegEx pattern can be enclosed in brackets <span class="hl-orange">()</span>, just like using brackets in a mathematics formula. Each part that is enclosed in brackets is called a "''subexpression''".<br />
<br />
The brackets serve two main purposes: <br />
<br />
* Better readability, as in the mathematical formula '''a+(b+c)'''.<br />
* Make a functional group, as in the mathematical formula '''a(b+c)'''. This group is evaluated first.<br />
<br />
Let us see some examples: <br />
<br />
{| class="wikitable"<br />
|-<br />
! RegEx Pattern<br />
! Remarks<br />
|-<br />
| <center><span class="hl-orange">(fee)&#124;(fie)&#124;(foe)</span></center> <br />
| Much better readability than the equivalent RegEx pattern <span class="hl-orange">fee&#124;fie&#124;foe</span>.<br />
|-<br />
| <center><span class="hl-orange">(foobar){2,3}</span></center> <br />
| Matches with the entire enclosed string '''foobar''' repeated 2 or 3 times.<br />
(i.e., matches with '''foobarfoobar''' or '''foobarfoobarfoobar''')<br/>(The iterator acts on the entire subexpression. Compare with the example below!) <br />
<br />
|-<br />
| <center><span class="hl-orange">foobar{2,3}</span></center> <br />
| Matches with '''fooba''' followed by the character '''r''' repeated 2 or 3 times.<br/>(i.e., matches with '''fooba<span class="hl-teal">rr</span>''' or '''fooba<span class="hl-teal">rrr</span>''') (The iterator acts only on the last character.)<br />
|-<br />
| <span class="hl-orange">foob([0-9]&#124;a+)r</span> <br />
| matches only the character '''foob<span class="hl-teal">0</span>r''', '''foob<span class="hl-teal">1</span>r''', '''foob<span class="hl-teal">a</span>r''', '''foob<span class="hl-teal">aa</span>r''', '''foob<span class="hl-teal">aaaa</span>r''', etc.<br/>(The subexpression is evaluated first.)<br />
|}<br />
<br />
== Backreferences ==<br />
<br />
You must have told (or heard-) jokes like this one: <br />
<br />
"Two guys walk in a bar. The '''''first guy''''' says.... Then the '''''second guy''''' replies....". <br />
<br />
Then you are already familiar with ''backreferences''! <br />
<br />
A "''backreference''" is a ''numbered reference'' to a previously mentioned thing. <br />
<br />
RegEx also has backreferences. Let us understand how backreferences are defined in RegEx. <br />
<br />
The RegEx engine tries to find text that matches the ''whole'' RegEx pattern. If a matching text is found, the RegEx engine identifies the matching text for each of the subexpressions in the pattern. <br />
<br />
At this stage, the RegEx engine gives numbers to these matching parts: <br />
<br />
* The text that matches the ''entire'' RegEx expression takes the number '0'. <br />
* The text matching any subexpression is given a number based on the position of that subexpression inside the pattern. In other words, text matching the ''n''th subexpression will take the number 'n'.<br />
<br />
Now we use those numbers to refer to the entire pattern and/or subexpressions. (That is why these numbers are called "'''backreference'''".) <br />
<br />
The backreference to the ''n''<sup>th</sup> subexpression is written as '''<span class="hl-orange">\n</span>'''. <br />
<br />
The backreferences can be used to compose the RegEx pattern itself, as shown below: <br />
<br />
{| class="wikitable"<br />
|-<br />
| <center><span class="hl-orange">(.)\1+</span></center> <br />
| matches '''aaaa''' and '''cc''' (any single character that is repeated twice or more)<br />
|-<br />
| <center><span class="hl-orange">(.+)\1+</span></center> <br />
| matches <span class="hl-blue">aa</span><span class="hl-pink">aa</span>, <span class="hl-blue">c</span><span class="hl-pink">c</span>, <span class="hl-blue">ab</span><span class="hl-pink">ab</span><span class="hl-blue">ab</span><span class="hl-pink">ab</span>, <span class="hl-blue">123</span><span class="hl-pink">123</span> <br />
(a set of one or more characters, repeated twice or more) <br />
<br />
(The character-sets are alternately colored <span class="hl-blue">blue</span> and <span class="hl-pink">pink</span> for easy identification. Observe how a RegEx pattern can match quite different text!) <br />
<br />
|}<br />
<br />
=== Substitution of text using backreference ===<br />
<br />
The backreferences are also used in ''find-and-replace'' operations, to re-assemble new text from old. <br />
<br />
*The expressions <span class="hl-orange">\1</span> through <span class="hl-orange">\9</span> serve as backreferences to the subexpressions found in the RegEx pattern. The expression <span class="hl-orange">\0</span> is used to represent the text that matches the whole RegEx pattern. These are used in the "find" part of the operation. <br />
*The expressions <span class="hl-orange">$1</span> through <span class="hl-orange">$9</span> represent the actual text that matches the ''respective'' subexpressions. These are used in the "replace" part of the operation.<br />
*The expressions <span class="hl-orange">$0</span> refers to the whole original name. Note: it is not necessary to enclosed them in round brackets <span class="hl-orange">()</span> for this use, <span class="hl-orange">$0</span> is just there.<br />
<br />
The replacement text is typically a combination of- <br />
<br />
* The text that matched the subexpressions, and <br />
* Some new text.<br />
<br />
Note that the RegEx pattern ''may'' have some parts that are not enclosed in (). (In other words, it may have parts that are not subexpressions.) Such parts are not used in the replacement text. <br />
<br />
Here are some "find-and-replace" examples: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Expression<br />
! Replace<br />
! Description<br />
|-<br />
| <center><span class="hl-orange">(.*) (.*)</span></center> <br />
| <center><span class="hl-orange">$2, $1</span></center> <br />
| Switch two words around and put a comma after the resulting first word. Example: if input string is "John Smith", then output will be "Smith, John". <br />
Notice that the replacement text also has additional literal text in the middle (comma and space). <br />
<br />
|-<br />
| <center><span class="hl-orange">\b(\d{2})-(\d{2})-(\d{4})\b</span></center> <br />
| <center><span class="hl-orange">$3-$2-$1</span></center> <br />
| Find date sequences in dd-mm-yyyy format and reverse them into yyyy-mm-dd format. <br>(e.g. 25-10-2007 is converted to 2007-10-25). <br />
'''Note''': This is not a very robust example, because <span class="hl-orange">\d</span> can represent any digit in range of 0-9. That means sequences like 99-99-9999 also will match this pattern, resulting in a problem. This in fact shows that you need to be careful with RegEx patterns! <br />
<br />
|-<br />
| <center><span class="hl-orange">\[.*?\]</span></center> <br />
| <br />
| Remove the contents of the [...] (square brackets), and the brackets too. <br>(Replace with ''nothing'' means ''deleting''.) <br />
<br />
|}<br />
<br />
=== Upper case and lower case manipulations ===<br />
<br />
Backreferences can also be used to adjust the case of a certain patterns or fragments, which cannot be easily achieved with generic case manipulation rules.<br />
<br />
{| class="wikitable"<br />
! Flag<br />
! Description<br />
|-<br />
| <code>\L</code><br />
| Convert all characters to lowercase.<br />
|-<br />
| <code>\l</code><br />
| Convert only the first character to lowercase (that's a lower case L).<br />
|-<br />
| <code>\U</code><br />
| Convert all characters to uppercase.<br />
|-<br />
| <code>\u</code><br />
| Convert only the first character to uppercase.<br />
|}<br />
<br />
These flags can be used together with the backreferences in the replace pattern to adjust the case of text inserted by backreferences.<br />
<br />
For example, we can do the following manipulations:<br />
<br />
{| class="wikitable"<br />
! Input || Find || Replace || Result<br />
|-<br />
| test ExAmple || <span class="hl-orange">(.+) (.+)</span> || <span class="hl-orange">$1 $2</span> || <span class="hl-teal">test ExAmple</span><br />
|-<br />
| test ExAmple || <span class="hl-orange">(.+) (.+)</span> || <span class="hl-orange">\U$1 $2</span> || <span class="hl-teal"><span class="hl-red">TEST</span> ExAmple</span><br />
|-<br />
| test ExAmple || <span class="hl-orange">(.+) (.+)</span> || <span class="hl-orange">$1 \L$2</span> || <span class="hl-teal">test <span class="hl-red">example</span></span><br />
|-<br />
| test ExAmple || <span class="hl-orange">(.+) (.+)</span> || <span class="hl-orange">\u$1 \L$2</span> || <span class="hl-teal"><span class="hl-red">T</span>est <span class="hl-red">example</span></span><br />
|}<br />
<br />
'''Note:''' Case manipulation features were added in ''v5.72.4 Beta''. This feature is less common and may not exist in other RegEx engines.<br />
<br />
== Limitations for binary data ==<br />
<br />
One of the known limitation of RegEx engine when working with binary data is that the <u>input string is not searched beyond the first occurrence of NULL character (\x00)</u>. This would not affect file names because there are simply no NULL characters in them, but may affect parsing of binary content of files when working in [[ReNamer:Pascal Script|Pascal Script]] for example.<br />
<br />
== Useful references ==<br />
<br />
* [http://www.regular-expressions.info/ www.regular-expressions.info]<br />
*: Excellent site devoted to regular expressions. It is nicely structured, with many easy to understand examples.<br />
* [https://github.com/andgineer/TRegExpr TRegExpr] component with documentation at [https://regex.sorokin.engineer/ regex.sorokin.engineer]<br />
*: Regular expressions library for Delphi / Free Pascal.<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=ReNamer:Rules:RegEx&diff=3464ReNamer:Rules:RegEx2022-01-24T08:48:36Z<p>Den4b: Rephrased the introduction and updated reference links.</p>
<hr />
<div>{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:Translit|next=ReNamer:Rules:PascalScript}}<br />
<br />
[[Image:RegExRule.png|center]]<br />
<br />
This rule allows finding and replacing patterns defined as [[ReNamer:Regular Expressions|Regular Expressions]].<br />
<br />
Regular Expressions (RegEx) use a special syntax for describing search and replace patterns, they are very powerful and ''really'' worth learning.<br />
<br />
ReNamer users have posted many RegEx examples at the [http://www.den4b.com/forum/ User Forum], where you might find your particular case already solved.<br />
<br />
'''Note:''' The RegEx engine used in ReNamer is a little different from the mainstream [http://perldoc.perl.org/perlre.html PERL RegEx] or [http://msdn.microsoft.com/en-us/library/6wzad2b2(VS.85).aspx Windows RegEx]. You can check the syntax in the [[ReNamer:Regular Expressions|Regular Expressions]] article.<br />
<br />
The parameters are as follows: <br />
<br />
{| class="wikitable"<br />
|-<br />
! Parameter <br />
! Details<br />
|-<br />
| Expression <br />
| RegEx pattern to match or find.<br />
|-<br />
| Replace <br />
| RegEx pattern that replaces the found pattern.<br />
|-<br />
| Skip extension <br />
| If this check box is selected, the extension will be ignored by the rule.<br />
|-<br />
| Case-sensitive <br />
| If this option is selected, ReNamer will search for the text in ''case-sensitive'' manner.<br />
|}<br />
<br />
A simple set of commonly used RegEx syntax patterns is provided in the hint menu:<br />
<br />
[[File:RegExRuleSyntaxHint.png]]<br />
<br />
[[Category:ReNamer]]</div>Den4bhttp://www.den4b.com/w/index.php?title=File:ReNamer.png&diff=3463File:ReNamer.png2021-12-17T19:50:21Z<p>Den4b: Den4b uploaded a new version of File:ReNamer.png</p>
<hr />
<div>[[Category:ReNamer]]</div>Den4b