Hello,
I am new to the ABBYY Flexicapture 11 product and I am having problems trying to set an environment variable using a VB Script in the AfterBatchCreated event handler.
The purpose of the Script is to change the default batch name to be something like
2016-05-17.0001
2016-05-17.0002
….
With the date changing each day.
When I tried something like:
me.Project.EnvironmentVariables.Set("LastBatchDate", "2016-05-17")
I get the error “Cannot user parentheses when calling a Sub”
I then tried adding the word Call in front and it then passed syntax checker, however still will not work.
Call me.Project.EnvironmentVariables.Set("LastBatchDate", "2016-05-17")
Below is my complete script:
LastBatchDate = me.Project.EnvironmentVariables.Get("LastBatchDate")
LastBatchSeqNumber = me.Project.EnvironmentVariables.Get("LastBatchSeqNumber")
If LastBatchDate = "" then
LastBatchDate = Year(Date) & "-" & Right("0" & Month(Date), 2) & "-" & Right("0" & Day(Date), 2)
LastBatchSeqNumber = 0
End If
If LastBatchDate <> Year(Date) & "-" & Right("0" & Month(Date), 2) & "-" & Right("0" & Day(Date), 2) then
LastBatchDate = Year(Date) & "-" & Right("0" & Month(Date), 2) & "-" & Right("0" & Day(Date), 2)
LastBatchSeqNumber = 0
End If
me.Name = LastBatchDate & Right("0000" & (LastBatchSeqNumber+1),4)
call me.Project.EnvironmentVariables.Set("LastBatchDate", LastBatchDate)
call me.Project.EnvironmentVariables.Set("LastBatchSeqNumber", LastBatchSeqNumber+1)
Thanks
Dirk
I am new to the ABBYY Flexicapture 11 product and I am having problems trying to set an environment variable using a VB Script in the AfterBatchCreated event handler.
The purpose of the Script is to change the default batch name to be something like
2016-05-17.0001
2016-05-17.0002
….
With the date changing each day.
When I tried something like:
me.Project.EnvironmentVariables.Set("LastBatchDate", "2016-05-17")
I get the error “Cannot user parentheses when calling a Sub”
I then tried adding the word Call in front and it then passed syntax checker, however still will not work.
Call me.Project.EnvironmentVariables.Set("LastBatchDate", "2016-05-17")
Below is my complete script:
LastBatchDate = me.Project.EnvironmentVariables.Get("LastBatchDate")
LastBatchSeqNumber = me.Project.EnvironmentVariables.Get("LastBatchSeqNumber")
If LastBatchDate = "" then
LastBatchDate = Year(Date) & "-" & Right("0" & Month(Date), 2) & "-" & Right("0" & Day(Date), 2)
LastBatchSeqNumber = 0
End If
If LastBatchDate <> Year(Date) & "-" & Right("0" & Month(Date), 2) & "-" & Right("0" & Day(Date), 2) then
LastBatchDate = Year(Date) & "-" & Right("0" & Month(Date), 2) & "-" & Right("0" & Day(Date), 2)
LastBatchSeqNumber = 0
End If
me.Name = LastBatchDate & Right("0000" & (LastBatchSeqNumber+1),4)
call me.Project.EnvironmentVariables.Set("LastBatchDate", LastBatchDate)
call me.Project.EnvironmentVariables.Set("LastBatchSeqNumber", LastBatchSeqNumber+1)
Thanks
Dirk
Comments
3 comments
Project.EnvironmentVariables is read only. Check help. You should save your data somewhere else , maybe a file.
Try this :
dim fso, fileName, txtFile, SeqNumber
set fso = CreateObject("Scripting.FileSystemObject")
if Not IsObject(fso) then
Processing.ReportError "Error Creating FSO"
End if
'Choose you path
fileName = "c:\temp"& Year(Date) & "-" & Right("0" & Month(Date), 2) & "-" & Right("0" & Day(Date), 2) & ".Txt"
If fso.FileExists(fileName) then
set txtFile = fs
SeqNumber = Cint(txtFile.ReadAll)
txtFile.Close
else
SeqNumber = 1
End if
Me.Name = Year(Date) & "-" & Right("0" & Month(Date), 2) & "-" & Right("0" & Day(Date), 2) & "-" & Right("00000" & SeqNumber,6)
set txtFile = fs
txtFile.Write SeqNumber + 1
txtFile.Close
Set fso = Nothing
Regards
Thank you for the information. I had referenced the help, however it was not clear to me. It said to use the IProperties.
- Environment variables of any type can be used in scripts. Use the EnviromentVariables property of IProperties, which is available in the IProject interface.
When I looked at IProperties:IProperties
What it does
Methods
It listed the above methods. Based on this I was attempting to used the Set method to set this value.
Even the context sensitive help in vb shows a set command under Project.EnviromentVariables.
After reading your post I also looked at IProject which did have the following
Properties
I am just confused why the Set and Delete methods are listed in the context sensitive help for a read only field.
Anyway, now that I know I will store this info in a Database or text file as you suggested.
Thanks again for you help.
Dirk
Glad to help. You can GET information from environment variables, but seems that setting is not possible.
I'm attaching help file information , the one i have, about the Project.EnvironmentVariables . I'm currently using Flexicapture 11.4 (StandAlone & Distributed).
Kind regards,
Please sign in to leave a comment.