Difference between revisions of "ReNamer:Pascal Script"

From den4b Wiki
Jump to navigation Jump to search
(→‎Script cookbook: read lines from file link)
Line 28: Line 28:
 
They also demonstrate how to use ReNamer's types, procedures and functions.  
 
They also demonstrate how to use ReNamer's types, procedures and functions.  
  
#[[ReNamer:Pascal Script:FileName|How to rename a file]] ([[ReNamer:Pascal Script:FileName|using the FileName variable]])
+
# [[ReNamer:Pascal Script:FileName|How to rename a file]] ([[ReNamer:Pascal Script:FileName|using the FileName variable]])
#[[ReNamer:Pascal Script:FileName Utilities|How to skip extention]] ([[ReNamer:Pascal Script:FileName Utilities|Basic FileName utilities]])
+
# [[ReNamer:Pascal Script:FileName Utilities|How to skip extention]] ([[ReNamer:Pascal Script:FileName Utilities|Basic FileName utilities]])
#[[ReNamer:Pascal Script:WideUpperCase|How to convert the filename to ALLCAPS]] ([[ReNamer:Pascal Script:WideUpperCase|the WideUpperCase function]])
+
# [[ReNamer:Pascal Script:WideUpperCase|How to convert the filename to ALLCAPS]] ([[ReNamer:Pascal Script:WideUpperCase|the WideUpperCase function]])
#[[ReNamer:Pascal Script:Unicode String Handling Routines|How to operate on words]] ([[ReNamer:Pascal Script:Unicode String Handling Routines|Unicode string-handling routines]])
+
# [[ReNamer:Pascal Script:Unicode String Handling Routines|How to operate on words]] ([[ReNamer:Pascal Script:Unicode String Handling Routines|Unicode string-handling routines]])
#[[ReNamer:Pascal Script:Basic Conversion Routines|How to serialize files]] ([[ReNamer:Pascal Script:Basic Conversion Routines|Basic conversion routines]])
+
# [[ReNamer:Pascal Script:Basic Conversion Routines|How to serialize files]] ([[ReNamer:Pascal Script:Basic Conversion Routines|Basic conversion routines]])
#[[ReNamer:Pascal Script:Initialization of variables|How to initialize variables]]  
+
# [[ReNamer:Pascal Script:Initialization of variables|How to initialize variables]]  
#[[ReNamer:Pascal Script:Dialogs|How to create interactive dialogs]]
+
# [[ReNamer:Pascal Script:Dialogs|How to create interactive dialogs]]
#[[ReNamer:Pascal Script:FilePath|How to work with folders and paths]] ([[ReNamer:Pascal Script:FilePath|FilePath]])
+
# [[ReNamer:Pascal Script:FilePath|How to work with folders and paths]] ([[ReNamer:Pascal Script:FilePath|FilePath]])
#[[ReNamer:Pascal Script:Break script execution|How to break the script execution]]
+
# [[ReNamer:Pascal Script:Break script execution|How to break the script execution]]
 +
# [[ReNamer:Pascal Script:Read lines from file|How to read lines from file]]
  
 
== Scripts at the User Forum  ==
 
== Scripts at the User Forum  ==

Revision as of 20:38, 2 August 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:

  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 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.

  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)
  9. How to break the script execution
  10. How to read lines from file

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.