Switch to desktop version  
ONDATE and ONSTATUS issues. - Printable Version

+- Ewon Technical Forum (https://techforum.ewon.biz)
+-- Forum: Development (https://techforum.ewon.biz/forum-50.html)
+--- Forum: BASIC Script (https://techforum.ewon.biz/forum-52.html)
+--- Thread: ONDATE and ONSTATUS issues. (/thread-461.html)



ONDATE and ONSTATUS issues. - Boris D. - 04-12-2017

Hi,

I'm trying to send a mail with an attached CSV file each week. When I try manually, the mail is sending correctly.


Code:
ONCHANGE "Sendthemail", "GOTO Sendmail_LABEL"

But when I use ONDATE, nothing happens. I've tried some synthax and command, though.


Code:
ONDATE 1,"0 22 * * 5","GOTO Sendmail_LABEL"



So, maybe I've missed  something and I need to change something in the Task Planner?

I don't want to use the Task Planner to send the mail, because I use dynamic name and I want to delete the file after it is sent.

About the ONSTATUS, I don't understand how to use it. When I go to "Sendmail_LABEL", I've tried to delete the file after the mailing. But if I use "ERASE" after the "SENDMAIL", the file is deleted before the sending, so I get an empty file. I know I need to use the "ONSTATUS" function to know when the mail is sending, but with the syntaxe and the example writing in the programming reference guide, I don't know how to link the ONSTATUS to the SENDMAIL.


Code:
ONSTATUS "goto Erase_LABEL"

Erase_LABEL:
ERASE "/usr/Test.csv"
END
 
Any help will be appreciated.

Boris.


RE: ONDATE and ONSTATUS issues. - simon - 04-12-2017

Boris,

You have to use the ActionID parameter to detect in the ONSTATUS that it has well been fired by the call of the sendmail function.

See example :


Code:
ONSTATUS "GOTO ScheduledActionEnd"
SENDMAIL "test@test.com","","subject","msg"
a% = GETSYS Prg,"ACTIONID" : REM Save ActionId of Sendmail
END

ScheduledActionEnd:
REM Get ActionID that fired the ONSTATUS and compare with the one saved
   b% = GETSYS Prg,"EVTINFO"
    IF a% = b% THEN
        SETSYS Prg, "ACTIONID", b%
                REM Read Status of the Action
        c% = GETSYS Prg,"ACTIONSTAT"
                REM if = 0 --> Success
        IF c% = 0 THEN
            ERASE "/usr/file.txt"
        ENDIF
    ENDIF
END



RE: ONDATE and ONSTATUS issues. - Boris D. - 05-12-2017

Simon,

You saved me again ! It works fine, and I've find why ONDATE wasn't working.

Thank you for all,

Boris