Difference between revisions of "ReNamer:Pascal Script"
Line 1: | Line 1: | ||
− | The [[ReNamer:Rules:PascalScript| | + | The [[ReNamer:Rules:PascalScript|PascalScript Rule]] in ReNamer uses Pascal Script component to allow users to program their own renaming rule. |
− | To master Pascal | + | To master Pascal Script, follow these steps: |
− | #Learn the basic syntax of Pascal | + | # Learn the basic syntax and concepts of Pascal Script |
− | #Understand the specific variables, procedures and functions that are defined within ReNamer | + | # Understand the specific variables, procedures and functions that are defined within ReNamer |
− | #Learn how to use these variables/functions/procedures in | + | # Learn how to use these variables/functions/procedures in scripts |
− | Let us see these steps in more details. | + | Let us see these steps in more details. |
− | == Learn Pascal | + | == Learn Pascal Script == |
− | + | To learn the basics of Pascal Script, please refer to the [[ReNamer:Pascal Script:Quick guide|Pascal Script Quick Guide]]. | |
== Types and functions == | == Types and functions == | ||
Line 22: | Line 22: | ||
<span style="color: red">Note:</span> Most of these are <u>not</u> part of the "standard" Pascal Script, so you will not find them in other applications. | <span style="color: red">Note:</span> Most of these are <u>not</u> part of the "standard" Pascal Script, so you will not find them in other applications. | ||
− | == Script cookbook | + | == Script cookbook == |
In this section, we will see how to write scripts for some common renaming tasks. | In this section, we will see how to write scripts for some common renaming tasks. | ||
Line 42: | Line 42: | ||
The User Forum contains several ready scripts. Some examples are listed on the [[ReNamer:Scripts|Scripts]] page. Study them and adopt them for your purpose. | The User Forum contains several ready scripts. Some examples are listed on the [[ReNamer:Scripts|Scripts]] page. Study them and adopt them for your purpose. | ||
− | == Tips | + | == 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 the File. <br>Therefore, in your script, you will have to manipulate this variable to change the filename. |
− | *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.<br> |
− | *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 UDFs (User-Defined Functions) and also importing of external functions from DLLs.<br>'''???''' what is the syntax for referencing such an external routine? |
− | *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.) | + | * 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.) |
− | <span style="color: red | + | <span style="color: red">'''Warning:''' Do not override ReNamer's built-in variables, types and functions.</span> |
− | <span style="color: red | + | <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> |
+ | |||
+ | == External links == | ||
+ | |||
+ | * [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. |
Revision as of 14:05, 30 July 2009
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:
- 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
Let us see these steps in more details.
Learn Pascal Script
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 will 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.
- How to rename a file (using the FileName variable)
- How to skip extention (Basic FileName utilities)
- How to convert the filename to ALLCAPS (the WideUpperCase function)
- How to operate on words (Unicode string-handling routines)
- How to serialize files (Basic conversion routines)
- How to initialize variables
- How to create interactive dialogs
- How to work with folders and paths (FilePath)
- How to break the script execution
Scripts at the User Forum
The User Forum contains several ready scripts. Some examples are listed on the Scripts page. 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 the File.
Therefore, in your script, you will have to manipulate this variable to change the filename. - 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.
??? what is the syntax for referencing such an external routine? - 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.)
Warning: Do not override ReNamer's built-in variables, types and functions.
Warning: Some of the functions are able to alter your file system (create new folders, move files, etc.). So use them with caution!
External links
- Developers of the Pascal Script component.
- Help and reference for the fundamentals of the Delphi/Pascal language.