Can we get a time interval option added to send?

Here's where to post questions and suggestions regarding forum use. Requests for new forum topics should be posted here as well.

Can we get a time interval option added to send?

Postby tetsuo29 » Mon Jan 29, 2018 1:29 pm

I've recently been working on a project that needs to trigger actions at timed intervals. I've figured out how to do it with the idle handler but the idle handler seems to take unnecessary resources and also can be a bit erratic especially when your program is moved between the foreground and the background.

I think it would be really nice if SC could get a time interval option added to the send command. Something along the lines of:

send message to objectDescriptor in time interval

Have you ever thought of adding this? What are the odds that it could be added to a future release? Thanks.
tetsuo29
 
Posts: 17
Joined: Wed Nov 18, 2015 12:10 pm

Re: Can we get a time interval option added to send?

Postby codegreen » Mon Jan 29, 2018 4:21 pm

Timers are a bit harder than they sound in this kind of context. In practice neither a threaded nor a non-threaded implementation is going to allow for precise timing of script-level messages (if that's really what you're looking for) though they'll be more efficient than an idle handler.

I wrote a non-threaded version as an XRTN called Timers() about 25 years ago (which someone here must have a recent copy of), and even in that version IIRC you could sometimes get yourself into trouble. I think Terry wrote a threaded version (where I bet you can REALLY shoot yourself in the foot if you try) that's in the XCMD library here.

If you don't get any joy from his, I could dig up and UL mine. No promises though...

-Mark
codegreen
 
Posts: 1556
Joined: Mon Jul 14, 2008 11:03 pm

Re: Can we get a time interval option added to send?

Postby sctell » Mon Jan 29, 2018 11:43 pm

codegreen wrote:I think Terry wrote a threaded version (where I bet you can REALLY shoot yourself in the foot if you try) that's in the XCMD library here.


Wow, must be getting old, don't remember doing this one.

Please don't ask to update as I can't find the source code. It either works or it doesn't.

Here's the link.

http://forums.supercard.us/viewtopic.php?f=16&t=1484&p=7293&hilit=timer#p7293

All the best

Terry
sctell
 
Posts: 1150
Joined: Sun Jul 06, 2008 10:41 am

Re: Can we get a time interval option added to send?

Postby hodger » Thu Feb 15, 2018 7:26 pm

I expect Automator could be used to fire an AppleScript that sends messages to SC. I haven't tried automating a timer feature, but have created a watched folder that fires a URL off to a server that sends commands to a standalone.

Greg
hodger
 
Posts: 34
Joined: Mon Jul 26, 2010 8:19 pm

Re: Can we get a time interval option added to send?

Postby hodger » Fri Feb 16, 2018 12:42 am

I tried this recipe, which works. Create an AppleScript with something like this...

tell application "SuperCard 4.8"
do script "bozo"
end tell

Save this script as an app.
Make a Calendar event, set the alarm to a custom alert that opens a file, at time of event, and point it to the app you just made.
Your project needs an "on bozo" handler somewhere in the message path. I used this...

on bozo
put "BOZO received - " & the time
end bozo

When it's time for the script to run, Calendar runs it, which sends your message to SuperCard. If you want this daily etc, just adjust the event in Calendar.

The first time you run your AppleScript app, it may ask you to confirm saying it's the first time you've run the app.

G
hodger
 
Posts: 34
Joined: Mon Jul 26, 2010 8:19 pm


Return to Site News, Questions, and Feedback

Who is online

Users browsing this forum: No registered users and 0 guests

cron