Topic Options
#57130 - 06/26/19 05:26 AM Define a variable which is variable length ??
Andy1974 Offline
OL Guru

Registered: 03/26/08
Posts: 110
Loc: Hong Kong
Hello everyone,

I've another question in planetpress workflow.

Now I've below captured text data, the data format is
first field is company name, second field is company code,
third field is customer code. However, the length of
company name is not fixed, but the length of company code and customer code are fixed.

Captured text data :
--------------------
ABC COMPANY LTD A5850 DD1001
XYZ INTERNATIONAL COMPANY LTD A5860 DD1002
D-TEX GARMENT FTY,LTD B6560 DD1003
FIRST GREEN ART FACTORY LTD B6580 DD1004

And I want to define a variable in "Set Job Infos and Variable" to retrieve value of third field 'customer code', so how can I do it ?

Because the length of first field 'company name' is not fixed, so I cannot define the fixed format "@(page number,from line, to line, from column, to column)" to retrieve the value of customer code.

Anyone have idea of it ?

Many thanks !
Regards,
Andy...

Top
#57132 - 06/26/19 08:49 AM Re: Define a variable which is variable length ?? [Re: Andy1974]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 456
Loc: Québec, Canada
You could read the line from the end and stop at the first space found.

You would need to do this in a script.
You could use this regex expression in order to extract the last word of the line /\s(\w+)$

Top
#57135 - 06/26/19 09:26 PM Re: Define a variable which is variable length ?? [Re: Andy1974]
Andy1974 Offline
OL Guru

Registered: 03/26/08
Posts: 110
Loc: Hong Kong
Hello,

Sorry, I haven't so much knowledge on script,
do you mind to help me to make a example of my case for me ?

Thank you so much !

Regards,
Andy

Top
#57136 - 06/27/19 11:16 AM Re: Define a variable which is variable length ?? [Re: Andy1974]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 456
Loc: Québec, Canada
I first extracted a single line into Job Info 1 variable.

Then added a script (Javascript) using the following code:

Code:
Watch.SetJobInfo(2,/\s(\w+)$/g.exec(Watch.GetJobInfo(1))[1]);


After the script the value is in Job Info 2 variable.

Top
#57137 - 07/02/19 03:35 AM Re: Define a variable which is variable length ?? [Re: Andy1974]
Andy1974 Offline
OL Guru

Registered: 03/26/08
Posts: 110
Loc: Hong Kong
Hello Mr. Jean,

Many thanks your help on my question and I'll try your
suggestion on my workflow.

Thank you !

Regards,
Andy

Top