Topic Options
#44195 - 07/15/13 06:04 AM Question on Watch.ExpandString in VBscript ??
Andy1974 Offline
OL Guru

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


Dear all,

I've setup a VBscript in my planetpress flow, and want to set the location of local variable 'DbLookup', but after run VBscript, there is no value in 'DbLookup', so I don't know why
what wrong in it. Can anyone give me a suggestion ?

Local variable defined:
LineNum <--- default value is set 30
DbLookup
------------------------------------------------
Option explicit
Dim Ln

Ln = CInt(Watch.GetVariable("LineNum")) +1
Watch.SetVariable "LineNum", Ln

Watch.SetVariable "DbLookup", Watch.ExpandString("@(1," & Ln & "," & Ln & ",3,9,KeepCase,Trim)")
------------------------------------------------

Many thanks !
Best Regards,
Andy...

Top
#44197 - 07/15/13 08:18 AM Re: Question on Watch.ExpandString in VBscript ?? [Re: Andy1974]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1931
Loc: Objectif Lune, Montreal, Qc
There might simply be no data on that line. To check for that, add some logging to your script:
Code:
Option explicit
Dim Ln

Ln = CInt(Watch.GetVariable("LineNum")) +1
Watch.SetVariable "LineNum", Ln
Watch.Log "Line Num = " & Ln,2
Watch.Log "Expandstring = [" & Watch.ExpandString("@(1," & Ln & "," & Ln & ",3,9,KeepCase,Trim)") & "]",2

Watch.SetVariable "DbLookup", Watch.ExpandString("@(1," & Ln & "," & Ln & ",3,9,KeepCase,Trim)")
Watch.Log "DbLookup = [" + Watch.GetVariable("DbLookup") & "]",2



Run the process in step by step mode and monitor your messages. It should help you pinpoint the source of the issue.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#44246 - 07/17/13 06:03 AM Re: Question on Watch.ExpandString in VBscript ?? [Re: Andy1974]
Andy1974 Offline
OL Guru

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

Many thanks your reply !
I've tried your suggestion to add Watch.log in the script.
Then after run the process, "Line Num" can show line no,
but "Expandstring" & "DbLookup" are still blank.

Let me explain more detail of my flow as below :

Branch
------
|
|
Set Job Infos and Variable
[%{DbLookup}=@(1,%{LineNum},%{LineNum},3,9,KeepCase,Trim)]
[* Initial value of LineNum is 35]
|
Loop
[9 iterations]
|
PlanetPress Database
[SELECT * FROM [ITEMIMG] WHERE ITMCFR = '%{DbLookup}']
[*It retrieve access and then set item code into DbLookup]
|
Change Emulation
[Database]
|
Set Job Infos and Variable
[%{Imagepath}=field(1,0,0,'PATHFR',KeepCase,NoTrim)]
[*Get value(PATHFR) from access and keep in '%{Imagepath},
PATHFR is the image path which stored in access]
|
Change Emulation
[ASCII]
|
Run Script
[This script is used to get value %{Imagepath} and save into
JobInfo variable]
|
Run Script
[This script is the one which I posted it on above.]
[*It used to add 1 to LineNum on every loop and set item code
in %{DbLookup}]
|
Delete

In my probelm is, first loop, DbLookup can get the value, but
in second loop, DbLookup cannot get the value. Is it the loop
or emulation or VBscript problem ??

Sorry for ask so many questions !
Thanks & Best Regards,
Andy...

Top
#44253 - 07/17/13 10:07 AM Re: Question on Watch.ExpandString in VBscript ?? [Re: Andy1974]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1931
Loc: Objectif Lune, Montreal, Qc
It should work. I have re-created a very simple process here that does the same thing. It loops through the first 5 lines of a datafile, incrementing the data selection line each time:
Code:
INPUT task (irrelevant)
   |
   |
LOOP  (hard coded to 5 iterations)
   |
   |
RUN SCRIPT
  Watch.SetVariable "DBLookup",Watch.ExpandString("@(1,%{LineNum},%{LineNum},1,19,KeepCase,NoTrim)")
  Watch.Log "DBLookup = " & Watch.GetVariable("DBLookup"),2
  Watch.SetVariable "LineNum", cInt(Watch.GetVariable("LineNum"))+1
   |
   |
OUTPUT (irrelevant)

I created local variables LineNum and DBLookup in my process. Everything runs as expected.
Compare that process to your own, it should help you identify the differences that would account for the issue you're experiencing.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#44272 - 07/17/13 10:48 PM Re: Question on Watch.ExpandString in VBscript ?? [Re: Andy1974]
Andy1974 Offline
OL Guru

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

Many thanks your reply & help !

I find a strange problem is when I remove below steps in the
flow and just run only one VBscript(which I've posted above).

Then local variable 'DbLookup' can get the value of every lines in the loop, so is it the process of
read planetpress database & change emulation affect the result ?

=========================================================
Remove steps :
---------------------------------------------------------
PlanetPress Database
[SELECT * FROM [ITEMIMG] WHERE ITMCFR = '%{DbLookup}']
[*It retrieve access and then set item code into DbLookup]
|
Change Emulation
[Database]
|
Set Job Infos and Variable
[%{Imagepath}=field(1,0,0,'PATHFR',KeepCase,NoTrim)]
[*Get value(PATHFR) from access and keep in '%{Imagepath},
PATHFR is the image path which stored in access]
|
Change Emulation
[ASCII]
|
Run Script
[This script is used to get value %{Imagepath} and save into
JobInfo variable]
=========================================================

Once again, thanks a lot !

Best Regards,
Andy...

Top
#44291 - 07/18/13 09:41 AM Re: Question on Watch.ExpandString in VBscript ?? [Re: Andy1974]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1931
Loc: Objectif Lune, Montreal, Qc
After your PP-Database task runs, your data file is in database format, which is why you need to change the emulation. So far so good.

However, before you change the emulation back to ASCII, you must reload the original data file, otherwise you're using ASCII emulation on a database format... which explains why you're not getting the expected results.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#44305 - 07/19/13 01:52 AM Re: Question on Watch.ExpandString in VBscript ?? [Re: Andy1974]
Andy1974 Offline
OL Guru

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

Firstly, many thanks your help again !

Please forgive me to ask so much questions, you said that
I must reload the original data file before change emulation
back to ASCII. Do you mind to teach me how to reload
the original data file in the flow ??

Thank you so much !
Best Regards,
Andy...

Top
#44319 - 07/19/13 07:54 AM Re: Question on Watch.ExpandString in VBscript ?? [Re: Andy1974]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1931
Loc: Objectif Lune, Montreal, Qc
You have to save it somewhere first (with the Send To folder task) before the PP-Database task, then reload it with a Folder Capture Input task after the Set Jobinfo task.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#44334 - 07/21/13 10:55 PM Re: Question on Watch.ExpandString in VBscript ?? [Re: Andy1974]
Andy1974 Offline
OL Guru

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

Once again, thank you so much your great help !
I'll try to do it.

Best Regards,
Andy...

Top