This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathcancel.lcdoc
More file actions
80 lines (58 loc) · 2.28 KB
/
cancel.lcdoc
File metadata and controls
80 lines (58 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Name: cancel
Type: command
Syntax: cancel <messageQueueID>
Summary:
Removes a <message> that was queued with the <send> <command>
and is waiting to be sent.
Introduced: 1.0
OS: mac, windows, linux, ios, android
Platforms: desktop, server
Example:
cancel 2298
Example:
cancel item 1 of last line of the pendingMessages
Example:
# Assume these two handlers in a card script.
# Call scheduleBeep to queue a message
# Call cancelBeep to cancel the pending message
local sMessageID
on scheduleBeep
send "beep" to this card in 20 seconds
put the result into sMessageID
end scheduleBeep
on cancelBeep
cancel sMessageID
end cancelBeep
Parameters:
messageQueueID (integer):
The ID number of the message.
Description:
Use the <cancel> <command> to get rid of <message|messages> that were
set up but are no longer required.
The ID number of the message is returned by the <send> <command> that
sent the <message>. This number is also the first <item> of the line
corresponding to the message in the <pendingMessages> <function>.
All <pendingMessages|pending messages> are automatically canceled when
the application quits.
It is common to need to <cancel> a number of <message|messages> when
leaving a <card> or <stack>, if the <message|messages> only pertain to
that card or stack. For example, you might have queued a number of
<message|messages> that create an animated display on the current
<card>, and need to <cancel> them when the user goes to another <card>.
The best solution in a case like this is to place each <messageQueueID>
in a <script local variable>, a <global> <variable>, or a
<custom property> at the time the <message> is sent. Then you can
<cancel> all those <message|messages> in a <repeat> <loop> :
global gMyPendingMessages # you've stored the message IDs here
on closeCard
repeat for each line tThisMessageID in gMyPendingMessages
cancel tThisMessageID
end repeat
end closeCard
References: send (command), function (control structure),
repeat (control structure), flushEvents (function),
pendingMessages (function), result (function), command (glossary),
custom property (glossary), global (glossary), loop (glossary),
message (glossary), script local variable (glossary),
variable (glossary), item (keyword), card (object), stack (object)
Tags: messages