Ask questions about how to create a script or swap scripts with other users.
-
kosthala
- Posts: 52
- Joined: 18 Feb 2014 21:36
Post
by kosthala »
Hello,
I have created a very simple Pascal script in order to remove trailing spaces:
Code: Select all
begin
Document.ReplaceAll('^[ \t]+','', false, false, true);
end.
But when i run the script nothing happens. In previous versions the script was working fine.
Can you help me?
-
Rickard Johansson
- Site Admin
- Posts: 6783
- Joined: 19 Jul 2006 14:29
Post
by Rickard Johansson »
To remove trailing white spaces you could use something like:
Code: Select all
Document.ReplaceAll("[ \\t]+$", "", false, false, true);
or
Document.ReplaceAll('[ \t]+$', '', false, false, true); // Pascal
-
kosthala
- Posts: 52
- Joined: 18 Feb 2014 21:36
Post
by kosthala »
I'm sorry, i meant leading spaces...which is not working
Code: Select all
begin
Document.ReplaceAll('^[ \t]+','', false, false, true);
end.
-
Rickard Johansson
- Site Admin
- Posts: 6783
- Joined: 19 Jul 2006 14:29
Post
by Rickard Johansson »
I can't see anything wrong. Maybe your not executing the script correctly...
For testing and developing:
1. Enable dual document view and open the script in the left pane.
2. Open a test file, to execute the script on, to the right.
Now, run the script.
-
kosthala
- Posts: 52
- Joined: 18 Feb 2014 21:36
Post
by kosthala »
I followed your instructions and i get the attached message
-
Attachments
-

- Capture.PNG (1.89 KiB) Viewed 21601 times
-
Rickard Johansson
- Site Admin
- Posts: 6783
- Joined: 19 Jul 2006 14:29
Post
by Rickard Johansson »
If you create a new pascal script from the script menu you should get something like this:
Code: Select all
// Pascal script
// Global variables
// Enter code here
begin
end.
Insert your code between the begin .. end block.
E.g.
Code: Select all
// Pascal script
// Global variables
// Enter code here
begin
Document.ReplaceAll('^[ \t]+','', false, false, true);
end.
-
kosthala
- Posts: 52
- Joined: 18 Feb 2014 21:36
Post
by kosthala »
Please see my first post, i have already include begin - end pair.
-
pjj
- Posts: 2236
- Joined: 13 Oct 2009 13:48
- Location: Kraków, Poland
Post
by pjj »
FWIW Rickard's script works for me well.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
-
kosthala
- Posts: 52
- Joined: 18 Feb 2014 21:36
Post
by kosthala »
This is very weird. I copy the code from Rickard's script's and now is working.
But my first post script was exactly the same as Rickard's.
