×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DTSGlobalVariable not setting

DTSGlobalVariable not setting

DTSGlobalVariable not setting

(OP)
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
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close