Difference between revisions of "ReNamer:Rules:PascalScript"

From den4b Wiki
Jump to: navigation, search
(Using a script)
m (Borrowing scripts from forum)
 
(32 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== PascalScript Rule ==
+
{{Go|up=ReNamer:Rules|prev=ReNamer:Rules:RegEx|next=ReNamer:Rules:UserInput}}
[[Image:PascalScriptRule.png]]
 
  
 +
[[Image:PascalScriptRule.png|center]]
  
This rule uses Pascal/Delphi programming syntax and conventions. ReNamer comes some preloaded scripts. Let us see how to use them, and later see how to add a new script.
+
This rule uses [[ReNamer:Pascal Script|Pascal Script programming engine]] with syntax and conventions similar to Delphi/Pascal. ReNamer comes with some preloaded scripts. We will see how to use them, and how to add a new script.  
  
=== Using a script ===
+
== Using a ready script ==
# Click on the [[Image:ScriptsButton.png]] button (located just below the '''Configuration '''pane). A list of scripts appears.[[Image:PascalScriptsMenu.png]]
 
# All available scripts are listed ''above'' the line. Click on any script to load it into the '''Configuration '''pane.
 
# Edit the script if required
 
# Press [[Image:AddRuleButton.png]] button to add the script to the rule stack.
 
# Repeat steps 1-4 to add more script-based rules.
 
  
=== Borrowing scripts from forum ===
+
# Click on the [[Image:ScriptsButton.png]] button (located just below the '''Configuration '''pane).
Even if you do not know how to write a script, you can easily use scripts written by others.  
+
#: A list of scripts appears.
 +
#: [[Image:PascalScriptsMenu.png]]
 +
# All available scripts are listed ''above'' the line. Click on any script to load it into the '''Configuration '''pane.
 +
# Edit the script if required
 +
# Press [[Image:AddRuleButton.png]] button to add the script to the rule stack.  
  
First, visit the User Forum and search for a suitable script. The Forum already has a large number of such scripts. Some of these scripts have embedded comments about how to customize the script.  
+
Alternatively, you can ''drag and drop'' an existing file from your desktop of favourite explorer straight into the script window.
  
If you cannot find a suitable script, you can request other users to write a script for you.  
+
Hold <tt>SHIFT</tt> key when opening a new script to insert it into the current script at the cursor position, instead of completely replacing the current script. This can be useful when you store your commonly used functions in separate script files, and with this feature they can be easily merged into the current script.
  
Once you find such a script, follow these simple steps:
+
== Borrowing readymade scripts ==
  
 +
Even if you do not know how to write a script, you can easily use scripts written by others.
  
{| class="prettytable"
+
There are two sources of such readymade scripts:</br>
! <center>Step</center>
+
1. The [http://www.den4b.com/wiki/ReNamer:Scripts '''Scripts repository''']</br>
! <center>Details</center>
+
2. The [http://www.den4b.com/forum/ '''User Forum''']
  
|-
+
Search for a suitable script.
| <center>1</center>
 
| '''Copy the script'''
 
  
Copy the script from the forum (ensure that nothing is left out)
+
Some of these scripts have embedded comments about how to customize the script. If you cannot find a suitable script, you can request other users to write the script for you (or customize an existing script).
  
|-
+
'''TIP:''' If you are looking for scripts only, try to use '''begin''' or '''end''' words in your search phrase as these are the words that are present in every single script.
| <center>2</center>
 
| '''Clear the ReNamer's Configuration pane'''
 
  
Open the Pascal Script Rule in ReNamer. Select the three lines you see in the '''Configuration''' pane, and press DEL. (Those lines are meant to begin a script from scratch).
+
Once you find such a script, follow these simple steps:
  
 +
{| class="wikitable"
 
|-
 
|-
| <center>3</center>
+
! Step
| '''Paste the script into ReNamer pane'''
+
! Details
 +
|-
 +
! 1
 +
| '''Copy the script'''  
 +
Copy the script from the forum (ensure that nothing is left out).
  
Use the '''CTRL+V''' shortcut or right-click and select '''Paste.'''
+
|-
 +
! 2
 +
| '''Clear the ReNamer's Configuration pane'''  
 +
Open the '''Pascal Script''' Rule in ReNamer. Select the three lines you see in the '''Configuration''' pane, and press DEL or paste the script while these lines are selected.
 +
*The three lines already provided in the window are meant to begin a script from scratch; but since you are pasting a ready-made script, they must be removed first, otherwise they will interfere with your script.
  
 
|-
 
|-
| <center>4</center>
+
! 3
| '''Compile the script'''
+
| '''Paste the script into ReNamer pane'''  
 
+
Use the '''CTRL+V''' shortcut or right-click and select '''Paste'''.
Press the [[Image:]] button.
 
 
 
* In case some error comes up, you can try and troubleshoot the problematic statement in the script using the [[Image:]] button. It pops up a window like this:[[Image:]]Now enter the line number in the window and press '''OK'''. It takes you to the faulty statement.
 
* If the script compiles successfully, this button is not required at all.
 
  
 +
|-
 +
! 4
 +
| '''Compile the script'''
 +
Press the [[Image:TryToCompileButton.png]] button.
  
 +
*In case some error comes up, the error message will identify the line number of the faulty statement.
 +
*:You can try and troubleshoot the problematic statement in the script using the [[Image:GotoButton.png]] button.
 +
*:ReNamer opens a window like this:
 +
*:<center>[[Image:GotoLineDialog.png]]</center>
 +
*:Now enter the line number in the window and press '''OK'''. It takes you to the faulty statement.
 +
*: Try to edit the statement and compile the script again.
 +
*: (Note that if the script compiles successfully, the [[Image:GotoButton.png]] button is not required at all.)
  
 
|-
 
|-
| <center>5</center>
+
! 5
| '''Saving the script and giving it a name:'''
+
| '''Saving the script and giving it a name:'''  
 +
The '''save '''button is hidden under the '''scripts '''menu. So first click on the [[Image:ScriptsButton.png]] button. It pops up a window like this:
 +
<center>[[Image:PascalScriptsMenu.png]]</center>
 +
Note that all the existing scripts are listed here. (When you save the new script, it will also be added to this list.)
  
The '''save '''button is hidden under the '''scripts '''menu. So first click on the [[Image:]] button. It pops up a window like this:
+
Select the '''Save script... '''option (at the very bottom of the menu). Another window pops up.
 +
<center>[[Image:SaveScriptDialog.png]]</center>
 +
Enter a name that suggests the function of your script. Press '''OK'''. The new name is added to the list of scripts. Now use it as described [[#Using_a_ready_script|above]].  
  
[[Image:]]Note that all the existing scripts are listed here. (Your new script will also be added to this list.)
+
|}
  
Select the '''Save script... '''option (at the very bottom of the menu). Another window pops up.
+
== Writing your own scripts ==
 
 
[[Image:]]
 
 
 
Enter a name that suggests the function of your script. Press '''OK'''. The new name is added to the list of scripts. Now use it as described before.
 
 
 
|}
 
=== Writing your own scripts ===
 
To write your own scripts, you must have knowledge of Pascal script.
 
  
Learning Pascal script is easy. Refer to the '''Pascal Script Manual'''.  
+
To write your own scripts, you must have knowledge of Pascal script. Learning Pascal script is easy. Refer to the [[ReNamer:Pascal Script|Pascal Script section]].
  
We will assume here that you already know how to write pascal scripts. The step-by-step procedure is as follows:
+
Here, we will assume that you already know how to write pascal scripts.  
  
# Click in the Configuration pane and enter the script directly. (You can also copy it from anywhere and paste it into the pane by pressing '''CTRL+V'''. Or right-click in the pane and select the '''Paste''' option from the context menu.)
+
The step-by-step procedure is as follows:  
# Compile the script by pressing the [[Image:]] button located below the Configuration pane.
 
  
*
+
# Click in the Configuration pane and enter the script directly. (You can also copy it from anywhere and paste it into the pane by pressing '''CTRL+V'''. Or right-click in the pane and select the '''Paste''' option from the context menu.)
** If an error message comes up, troubleshoot the script. The fault message usually includes the line number of the problematic statement in the script. Press the [[Image:]] button and enter that line number to locate the faulty statement quickly.  
+
# Compile the script by pressing the [[Image:TryToCompileButton.png]] button located below the Configuration pane.
** Repeat this till a '''''Compiled successfully!''''' message pops up..
+
#* If an error message comes up, troubleshoot the script. The fault message usually includes the line number of the problematic statement in the script. Press the [[Image:GotoButton.png]] button and enter that line number to locate the faulty statement quickly. Then correct the errors and press the [[Image:TryToCompileButton.png]] button again. Repeat this till a '''''Compiled successfully!''''' message pops up.  
 +
# Now you can add the script as a rule by pressing [[Image:AddRuleButton.png]] button or save it for later use.
 +
# To save the script press the [[Image:ScriptsButton.png]] button. A list pops up:
 +
#: <center>[[Image:PascalScriptsMenu.png]]</center>
 +
# Click on the '''Save Script...'''(the last option in the list). Now this script is added to the list (it appears above the line in the list).
 +
#* Now you can use that script as described [[#Using a ready script|above]].
  
# Press the [[Image:]] button. A list pops up:[[Image:]]
+
[[Category:ReNamer]]
# Click on the last option in the list ('''Save Script...''' ). Now this script is added to the list (it appears above the line in the list).
 

Latest revision as of 10:24, 20 May 2019

PascalScriptRule.png

This rule uses Pascal Script programming engine with syntax and conventions similar to Delphi/Pascal. ReNamer comes with some preloaded scripts. We will see how to use them, and how to add a new script.

Using a ready script

  1. Click on the ScriptsButton.png button (located just below the Configuration pane).
    A list of scripts appears.
    PascalScriptsMenu.png
  2. All available scripts are listed above the line. Click on any script to load it into the Configuration pane.
  3. Edit the script if required
  4. Press AddRuleButton.png button to add the script to the rule stack.

Alternatively, you can drag and drop an existing file from your desktop of favourite explorer straight into the script window.

Hold SHIFT key when opening a new script to insert it into the current script at the cursor position, instead of completely replacing the current script. This can be useful when you store your commonly used functions in separate script files, and with this feature they can be easily merged into the current script.

Borrowing readymade scripts

Even if you do not know how to write a script, you can easily use scripts written by others.

There are two sources of such readymade scripts:
1. The Scripts repository
2. The User Forum

Search for a suitable script.

Some of these scripts have embedded comments about how to customize the script. If you cannot find a suitable script, you can request other users to write the script for you (or customize an existing script).

TIP: If you are looking for scripts only, try to use begin or end words in your search phrase as these are the words that are present in every single script.

Once you find such a script, follow these simple steps:

Step Details
1 Copy the script

Copy the script from the forum (ensure that nothing is left out).

2 Clear the ReNamer's Configuration pane

Open the Pascal Script Rule in ReNamer. Select the three lines you see in the Configuration pane, and press DEL or paste the script while these lines are selected.

  • The three lines already provided in the window are meant to begin a script from scratch; but since you are pasting a ready-made script, they must be removed first, otherwise they will interfere with your script.
3 Paste the script into ReNamer pane

Use the CTRL+V shortcut or right-click and select Paste.

4 Compile the script

Press the TryToCompileButton.png button.

  • In case some error comes up, the error message will identify the line number of the faulty statement.
    You can try and troubleshoot the problematic statement in the script using the GotoButton.png button.
    ReNamer opens a window like this:
    GotoLineDialog.png
    Now enter the line number in the window and press OK. It takes you to the faulty statement.
    Try to edit the statement and compile the script again.
    (Note that if the script compiles successfully, the GotoButton.png button is not required at all.)
5 Saving the script and giving it a name:

The save button is hidden under the scripts menu. So first click on the ScriptsButton.png button. It pops up a window like this:

PascalScriptsMenu.png

Note that all the existing scripts are listed here. (When you save the new script, it will also be added to this list.)

Select the Save script... option (at the very bottom of the menu). Another window pops up.

SaveScriptDialog.png

Enter a name that suggests the function of your script. Press OK. The new name is added to the list of scripts. Now use it as described above.

Writing your own scripts

To write your own scripts, you must have knowledge of Pascal script. Learning Pascal script is easy. Refer to the Pascal Script section.

Here, we will assume that you already know how to write pascal scripts.

The step-by-step procedure is as follows:

  1. Click in the Configuration pane and enter the script directly. (You can also copy it from anywhere and paste it into the pane by pressing CTRL+V. Or right-click in the pane and select the Paste option from the context menu.)
  2. Compile the script by pressing the TryToCompileButton.png button located below the Configuration pane.
    • If an error message comes up, troubleshoot the script. The fault message usually includes the line number of the problematic statement in the script. Press the GotoButton.png button and enter that line number to locate the faulty statement quickly. Then correct the errors and press the TryToCompileButton.png button again. Repeat this till a Compiled successfully! message pops up.
  3. Now you can add the script as a rule by pressing AddRuleButton.png button or save it for later use.
  4. To save the script press the ScriptsButton.png button. A list pops up:
    PascalScriptsMenu.png
  5. Click on the Save Script...(the last option in the list). Now this script is added to the list (it appears above the line in the list).
    • Now you can use that script as described above.