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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output to Eventlog 1

Status
Not open for further replies.

billieT

MIS
Joined
Dec 11, 2001
Messages
107
Location
NZ
This is supposed to be a simple status report of some file copying that is called in a subroutine. I suspect my use of testing a variable for a "true" result may not be the proper method, or perhaps my syntax is simply wrong... %-)

Here's the code snippit:

Code:
if FileSize > 1024 then
    WshShell.LogEvent 4, "IMSS Archive folder greater than 1GB"
    MoveOK = MoveFiles IMSSFolder
        if MoveOK then
            WshShell.LogEvent 0, "IMSS files moved to archive location"
        else
            WshShell.LogEvent 1, "IMSS file move failed"
        end if
end if

sub MoveFiles(IMSSFolder)
        [moving folders stuff, works perfectly]
end sub

So, is it wrong to use the MoveOK variable to store a true/false result and test for it? or have I done a stupid typo? The error is "Expected end of statement", but I can't see what punctuation I may have wrong in my script (or do I need to "call" the sub, complete with parentheses?)
 
Hello billieT,

Make MoveFiles() a function, returning a boolean.
[tt]
function MoveFiles(IMSSFolder)
'operating the move
'set up some criteria for success or failure.
'pseudo-code
if success then MoveFiles=true else MoveFiles=false
end function
[/tt]
Then when calling, use parentheses:
[tt]
MoveOK = MoveFiles(IMSSFolder)
[/tt]
But, you know there are MoveFile and MoveFolder methods in fso. And the success or failure can reflect error trapping on the operation using "on error resume next" and "if err<>0 then" etc.

regards - tsuji
 
Hi tsuji:

Thanks for the tip!

And yes, I'm using the fso CopyFolder and DeleteFolder commands in my script. Doing it as a function makes sense, I can error-handle inside the function and write the results to the eventlog afterwards... I just need to get to better grips with vbscript error-handling (life is so much easier with perl ;-) )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top