Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTSGlobalVariable not setting

Status
Not open for further replies.

gillrowley

Programmer
Apr 2, 2004
59
US
I have code that I cannot figure out why it is not working. Basically it is an ActiveX Script that checks for the existence of a file, and if the file is newly found, set the flag, and send an email. if the file was there previously and still exists, do nothing. If the file was there, but is not now, send an email.

if the file does not exist, the global variable "myVar" should be zero. If it does exist, myVar should be 1.

Code:
Function Main()
	'file is still not there, continue normally
	If DTSGlobalVariables("myVar").Value = 0 Then
		Main = DTSTaskExecResult_Success
	Else 
	'myVar was set to 1, file is not there anymore.  Set myVar 
	' to zero, send an email
		DTSGlobalVariables("myVar").Value = 0
		Main = DTSTaskExecResult_Failure
	End If
End Function

- And -

Code:
Function Main()
	If DTSGlobalVariables("myVar").Value = 1 Then
	'file was there, is there, do nothing
		'MsgBox("Success")
		Main = DTSTaskExecResult_Success
	Else 
	'file wasn't there, is there, set flag
		DTSGlobalVariables("myVar").Value = 1 
		Main = DTSTaskExecResult_Failure
	End If
End Function

These two snippets of code do not set myVar to the desired value. Thus, I get an email everytime these are run rather than just one notification. The idea is to send out only one email when the file is missing, and then one more when the file is found, not 1 email everytime the process is run.

Thanks to anyone who can help.
Gill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top