Topic Options
#31364 - 06/12/09 10:00 AM Gloabal Variable VBS and Job Infos
John Price Offline
OL Expert

Registered: 10/07/03
Posts: 164
Loc: Wigan, UK
I want to create a process that will process between 1 and many files. Each file will in effect be a document.

I would like to use this to process to add a document number to the document to be used in a PressTalk object that also creates barcodes.

I have created a Global Variable in PW7 called PageCount which appears to be a string and has a default value of 1 and looks like a name of %(global.PageCount)

I then run a script to convert the PageCount variable to numberic but get errors. The showmessage line shows a null value which explains the failure to convert the value to an integer.

Code:
 

Option explicit
Dim IntPageCount
Dim StrPageCount
IntPageCount=1

StrPageCount = watch.GetVariable("global.PageCount")
watch.showmessage  watch.GetVariable("global.PageCount")
IntPageCount = CInt(StrPageCount)

 
I intend to expand this code to add to the page count for each document.

I then propose to add a PW Object to move the PageCount to Jobinfo 9 and pass it to the document.

What am a doing wrong and is there some documentation / examples I can look at to assist.

Thanks

Top
#31365 - 06/12/09 10:54 AM Re: Gloabal Variable VBS and Job Infos
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4953
Loc: Objectif Lune Montreal
John,

I tested your code, and the showmessage worked fine. I assigned "1" as the variable's default value, and the showmessage displayed "1".

What do you have before the Run Script action? The problem may be there, with some values that you try to assign to PageCount before running the script.

Regards,
Rapha

Top
#31366 - 06/12/09 10:58 AM Re: Gloabal Variable VBS and Job Infos
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1931
Loc: Objectif Lune, Montreal, Qc
John,

Some additional information:

VBScript doesn't require you to typecast or convert variables. They are all Variants to start with. Therefore, if your intention is to increment the variable within the script, you can do so with a simple
Code:
strPageCount=strPageCount+1
.
With PPress and PPWorkflow, all variables are always considered strings.

If the showmessage line shows a null value, it can only be that the global.PageCount variable doesn't exist or contains nothing.

Since it's a global variable (by the way, do you really need a global one, wouldn't a local one be enough?), you may want to double check whether other processes aren't modifying the contents of the variable.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#31367 - 06/12/09 01:23 PM Re: Gloabal Variable VBS and Job Infos
John Price Offline
OL Expert

Registered: 10/07/03
Posts: 164
Loc: Wigan, UK
I guess my understanding of GlobalVariables / Local Variables within Watch maybe the cause of the problem.

I have made some changes to the script but only Global Variables worked, the local variable appeared to be reset after every pass.

The script is simple as follows.

Code:
Option explicit

watch.setvariable "Global.Gpage", watch.GetVariable("global.Gpage") + 1
watch.setjobinfo 9, watch.GetVariable("global.Gpage")
watch.showmessage  Watch.GetVariable("global.Gpage")
I now need to reset the Global Variable every day before the process starts but I think I can work out how to do that, but its friday and its late in the UK.

Many thanks for your swift responce and pointing in the right direction.

PS

The showmessage is just for me for debugging.

Top
#31368 - 06/12/09 01:52 PM Re: Gloabal Variable VBS and Job Infos
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1931
Loc: Objectif Lune, Montreal, Qc
Yes, local variables (i.e. process variables) are always reset each time the process starts. So if you want persistent values (which seems to be the case here), you're right: you do need global variables, which only get reset if you shut down and restart the entire service.

If you want to set the Global variable to a specific value every time the entire Service restarts, take a look at the Startup Process: that's exactly the kind of application for it.

Hope that helps,
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top