Zvoni your code seems fine in Lazarus Syntax check OK.
When I compile get succes but 1 warning.
I saved your file as .pas
Copy to Pascal Scripts folder in Subtitle Workshop
and when i want to use it i get SystemUtils not identified.
This Subtitle Workshop is very tricky with pascal scripts. Some pascal scripts works fine in 2.51 version but not good in other versions. 6.0a and 6.0b/e