Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code seems to execute twice
Message
 
 
To
14/05/2007 20:35:43
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01225415
Message ID:
01225418
Views:
21
Hi Rich,

Unrelated observation, but this is the first that I noticed in this code:

Why do you create oshell = CREATEOBJECT("wscript.shell") in the SCAN loop? Seems to me you need to do it once outside and then simply run the commands.

I'll look closer to the code.

Also this
FOR I = 1 TO lnRecips
>        oWWIP.cRecipient = ALLTRIM(aRecips[i])
>        oWWIP.SendMail()
>      ENDFOR
may send multiple e-mails.

In addition, do you have timer running? Do you disable the timer before running this code?

>I have the following function (parts have been snipped for convenience)
>DEFINE CLASS RunTasks as Custom
>  FUNCTION Run_scheduled_tasks()
>    oWWIP = CREATEOBJECT("wwIPStuff")
>             .
>             .
>    lcTime = TIME()
>    oMySQLData.Get_Scheduled_Tasks('zSchld_tasks')
>    SELECT what I need INTO CURSOR 'zTasks_toRun'
>    SELECT zTasks_toRun
>    SCAN
>      IF NOT EMPTY(ALLTRIM(zTasks_toRun.cParameters)) THEN
>        lcCommand = ALLTRIM(zTasks_toRun.cRunCmd) + ' ' + ALLTRIM(zTasks_toRun.cParameters)
>      ELSE
>        lcCommand = ALLTRIM(zTasks_toRun.cRunCmd)
>      ENDIF
>      oshell = CREATEOBJECT("wscript.shell")
>      oshell.run(lcCommand,1,.t.)
>      oMySQLData.Update_Task_LastRun(zTasks_toRun.CID)
>      oWWIP.cSubject = zTasks_toRun.ScheduleName + ' completed.'
>      oWWIP.cAttachment = TRIM(zTasks_toRun.cAttachments)
>      ** semi-colons not allowed.  In case users try them
>      ** Separate Notify email list items with either comma or semi-colon
>      lnRecips = ALINES(aRecips,zTasks_toRun.cNotify,",",";")
>      FOR I = 1 TO lnRecips
>        oWWIP.cRecipient = ALLTRIM(aRecips[i])
>        oWWIP.SendMail()
>      ENDFOR
>    ENDSCAN
>  ENDFUNC
>ENDDEFINE
>
>I've created a program which has several messageboxes.
>
>When I step through this code in the VFP Debugger the oshell.run() line takes effect, the second program runs and I respond to all the messageboxes, and then the email gets sent.
>
>When the program runs unattended via an exe, the oshell.run() line executes, an email is immediately sent, I respond to the messageboxes, and a second email is sent.
>
>I'm perplexed, confused, etc.
>
>Can anybody point me to what I might have set up incorrectly that would result in this behavior?
>
>Thanks to all..........Rich
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform