Difference between revisions of "ReNamer:Pascal Script"

From den4b Wiki
Jump to navigation Jump to search
(→‎Tips: Minor corrections.)
 
(34 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The [[ReNamer:Rules:PascalScript|'''PascalScript Rule''']] in ReNamer uses Pascal Script.
+
{{Up|ReNamer}}
  
To be able to use Pascal script, follow these steps:
+
The [[ReNamer:Rules:PascalScript|PascalScript Rule]] in [[ReNamer]] uses Pascal Script component to allow users to program their own renaming rule.
  
#Learn the basic Pascal script syntax (see the [[ReNamer:Pascal Script:Pascal Script quick guide|Pascal Script Quick Guide]])
+
To master Pascal Script, follow these steps:
#Understand the specific variables, procedures and functions that are defined within ReNamer (see the '''Reference''' section below).<br>
 
#Learn how to use these variables/functions/procedures in Pascal scripts (see the '''In a Nutshell '''section below)
 
  
== Reference  ==
+
# Learn the basic syntax and concepts of Pascal Script
 +
# Understand the specific variables, procedures and functions that are defined within ReNamer
 +
# Learn how to use these variables/functions/procedures in scripts
  
In this section, we will see a list of all variable types, procedures and functions defined ''within'' ReNamer.<br>(These are <u>not</u> part of the "standard" Pascal Script; so you will not find them anywhere else.)
+
Let us see these steps in more details.
 +
 
 +
== Learn the basics ==
 +
 
 +
To learn the basics of Pascal Script, please refer to the [[ReNamer:Pascal Script:Quick guide|Pascal Script Quick Guide]].
 +
 
 +
== Types and functions ==
 +
 
 +
In this section, we will see all types, procedures and functions which can be used ''within'' ReNamer.
  
 
*[[ReNamer:Pascal Script:Types|Types]]  
 
*[[ReNamer:Pascal Script:Types|Types]]  
 
*[[ReNamer:Pascal Script:Functions|Procedures and functions]]
 
*[[ReNamer:Pascal Script:Functions|Procedures and functions]]
  
== In a nutshell  ==
+
<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.
  
In this section, we will see some examples of Pascal Script.
+
== Script cookbook ==
  
They show how to use ReNamer's types, procedures and functions in Pascal scripts.  
+
In this section, we will see how to write scripts for some common renaming tasks.  
  
#[[ReNamer:Pascal Script:FileName|How to rename a file (]][[ReNamer:Pascal Script:FileName|using the '''FileName''' variable)]]
+
They also demonstrate how to use ReNamer's types, procedures and functions.
#[[ReNamer:Pascal Script:FileName Utilities|How to skip extention (]][[ReNamer:Pascal Script:FileName Utilities|Basic FileName utilities)&nbsp;]]
 
#[[ReNamer:Pascal Script:WideUpperCase|How to convert the filename to ALLCAPS (]][[ReNamer:Pascal Script:WideUpperCase|the '''WideUpperCase''' function)&nbsp;]]
 
#[[ReNamer:Pascal Script:Unicode String Handling Routines|How to operate on words (]][[ReNamer:Pascal Script:Unicode String Handling Routines|Unicode string-handling routines)&nbsp;]]
 
#[[ReNamer:Pascal Script:Basic Conversion Routines|How to serialize files (]][[ReNamer:Pascal Script:Basic Conversion Routines|Basic conversion routines)&nbsp;]]
 
#[[ReNamer:Pascal Script:Initialization of variables|How to initialize variables]]
 
#[[ReNamer:Pascal Script:Dialogs|How to create interactive dialogs (let the user decide]])
 
#[[ReNamer:Pascal Script:FilePath|How to work with folders and paths (]][[ReNamer:Pascal Script:FilePath|FilePath)&nbsp;]]
 
#[[ReNamer:Pascal Script:Break script execution|How to break the script execution]]
 
  
<br>
+
# [[ReNamer:Pascal Script:FileName|How to rename a file (using the FileName variable)]]
 +
# [[ReNamer:Pascal Script:FileName Utilities|How to skip extention (basic FileName utilities)]]
 +
# [[ReNamer:Pascal Script:WideUpperCase|How to convert the filename to ALLCAPS (the WideUpperCase function)]]
 +
# [[ReNamer:Pascal Script:Unicode String Handling Routines|How to operate on words (Unicode string-handling routines)]]
 +
# [[ReNamer:Pascal Script:Basic Conversion Routines|How to serialize files (basic conversion routines)]]
 +
# [[ReNamer:Pascal Script:Initialization of variables|How to initialize variables]]
 +
# [[ReNamer:Pascal Script:Dialogs|How to create interactive dialogs]]
 +
# [[ReNamer:Pascal Script:FilePath|How to work with folders and paths (FilePath constant)]]
 +
# [[ReNamer:Pascal Script:Break script execution|How to break the script execution]]
 +
# [[ReNamer:Pascal Script:Read file content|How to read file content]]
 +
# [[ReNamer:Pascal Script:Import functions|How to import functions]]
 +
# [[ReNamer:Pascal Script:SplitPath|How to split file path into parts (folders, base, extension)]]
 +
# [[ReNamer:Pascal Script:Reuse variable|How to store/load variables for later reuse]]
  
== Scripts at the User Forum ==
+
== Scripts repository ==
  
The User Forum contains several ready scripts. Some examples are listed [http://den4b.com/wiki/index.php?title=ReNamer:Scripts here]. Study them and adopt them for your purpose.
+
* Official [[ReNamer:Scripts|Scripts Repository]].
 +
* The [http://www.den4b.com/forum/ Forum] contains several ready scripts.
  
== Tips ==
+
Study them and adopt them for your purpose.
 +
 
 +
== Tips ==
  
 
A few quick tips:  
 
A few quick tips:  
  
*In Pascal Script, ReNamer has defined the '''FileName''' variable to represent the New Name of the File. <br>Therefore, in your script, you will have to manipulate this variable to change the filename.  
+
* 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.
*The '''FilePath''' constant holds the original path of the file. It allows you to access the file directly.<br>
+
* The '''FilePath''' constant holds the original path of the file. It allows you to access the file directly.
*ReNamer supports UDFs (User-Defined Functions) and also importing of external functions from DLLs.<br>??? what is the syntax for referencing such an external routine?
+
* ReNamer supports User Defined Functions (UDF) and also [[ReNamer:Pascal Script:Import functions|importing of external functions from DLLs]].
*Try to use '''WideString '''[[ReNamer:Pascal Script:Types|type]] instead of an ordinary '''String''' type. This will allow ReNamer to handle Unicode filenames.<br>(In other words, it will be able to handle non-English scripts, such as Cyrillic, Asian, German, French, etc.)<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.
 +
* 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.''
 +
 
 +
<div style="color: red">
 +
'''Warnings:'''
 +
* Do not override ReNamer's built-in variables, types and functions.
 +
* 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!
 +
* Remember that scripts are executed during the Preview (not the Rename) operation and can also get executed automatically if Auto Preview is enabled.
 +
</div >
 +
 
 +
== External links ==
  
<span style="color: red;">'''Warning:''' Do not override ReNamer's built-in variables, types and functions.</span>
+
* [http://www.remobjects.com/ps RemObjects Pascal Script]
 +
: Developers of the Pascal Script component.
 +
* [http://www.delphibasics.co.uk/ Delphi Basics]
 +
: Help and reference for the fundamentals of the Delphi/Pascal language.
  
<span style="color: red;">'''Warning:''' Some of the functions are able to alter your file system (create new folders, move files, etc.). So use them with caution! </span>
+
[[Category:ReNamer]]
 +
[[Category:Pascal Script]]

Latest revision as of 19:47, 7 March 2022

Arrow Return.png ReNamer  

The PascalScript Rule in ReNamer uses Pascal Script component to allow users to program their own renaming rule.

To master Pascal Script, follow these steps:

  1. Learn the basic syntax and concepts of Pascal Script
  2. Understand the specific variables, procedures and functions that are defined within ReNamer
  3. Learn how to use these variables/functions/procedures in scripts

Let us see these steps in more details.

Learn the basics

To learn the basics of Pascal Script, please refer to the Pascal Script Quick Guide.

Types and functions

In this section, we will see all types, procedures and functions which can be used within ReNamer.

Note: Most of these are not part of the "standard" Pascal Script, so you may not find them in other applications.

Script cookbook

In this section, we will see how to write scripts for some common renaming tasks.

They also demonstrate how to use ReNamer's types, procedures and functions.

  1. How to rename a file (using the FileName variable)
  2. How to skip extention (basic FileName utilities)
  3. How to convert the filename to ALLCAPS (the WideUpperCase function)
  4. How to operate on words (Unicode string-handling routines)
  5. How to serialize files (basic conversion routines)
  6. How to initialize variables
  7. How to create interactive dialogs
  8. How to work with folders and paths (FilePath constant)
  9. How to break the script execution
  10. How to read file content
  11. How to import functions
  12. How to split file path into parts (folders, base, extension)
  13. How to store/load variables for later reuse

Scripts repository

Study them and adopt them for your purpose.

Tips

A few quick tips:

  • 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.
  • The FilePath constant holds the original path of the file. It allows you to access the file directly.
  • ReNamer supports User Defined Functions (UDF) and also importing of external functions from DLLs.
  • Try to use WideString 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.
  • You may use {$INCLUDE 'filename.inc'} 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.

Warnings:

  • Do not override ReNamer's built-in variables, types and functions.
  • 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!
  • Remember that scripts are executed during the Preview (not the Rename) operation and can also get executed automatically if Auto Preview is enabled.

External links

Developers of the Pascal Script component.
Help and reference for the fundamentals of the Delphi/Pascal language.