Set a variable to capture variable PDF file for merging

I need to set a variable to capture variable PDF’s that will be merged by LIKE page counts. The Page counts # is in the PDF file name and (example: 12345_67890_D_T_2.pdf, 102900_666390_D_T_4.pdf, 104500_633390_D_T_4.pdf). In this example PDF there are 3 PDF’s and the PDF with _T_4 need to be merged and there will be 1000’s of PDF’s that need to be merged based on ‘like’ pages.

watch.setvariable “VARPAGES”, left(watch.expandstring(“%O”),instr(watch.expandstring(“%O”),“T”)-1)

I have the following variable and it gives me an error but i’m using the same VB script to parse another process I have setup and don’t receive any issues. I set me VARPAGES as a local variable under the process as well

WPROC: STAGE6- BATCHING (thread id: 24100) - 16:33:00

[0002] Starting plugin Run Script - 16:33:01
[0002] Run embedded script…
[0002] W3602 : Error 0 on line 1, column 1: Microsoft VBScript runtime error: Invalid procedure call or argument: ‘left’
[0002] W3603 : Error running script.
[0002] Run Script: W1603 : Plugin failed - 16:33:01 (elapsed time: 00:00:00.003)

Can’t say for sure, but it looks like instr() is returning nothing, which causes the left() method to fail. So perhaps the filename does not contain a “T” or perhaps it contains a lowercase “t”.

You should store the value of the instr() function in a variable and log it, then use that variable name as the second argument of your left() function. That should at least give you a bit more information on what to look for.

By the way, to perform a case-insensitive instr(), you have to specify 1 as the very last parameter (which in your case you didn’t specify, which means it has a default value of 0, which is case-sensitive).

Thanks for the follow up Phil. I’m going to run some tests breaking out both functions as you described and debug…just figured it was working for my other flow and maybe I was missing something simple…thanks again!