Skip to content

Commit 398b17d

Browse files
authored
Merge pull request livecode#4565 from trevordevore/tkd-support-callback-with-no-target
[Bug 18470] Don't require target for libURLSetStatusCallback
2 parents b041013 + c6ea510 commit 398b17d

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

docs/dictionary/command/libURLSetStatusCallback.lcdoc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name: libURLSetStatusCallback
22

33
Type: command
44

5-
Syntax: libURLSetStatusCallback [<messageName>, <objectLongID>]
5+
Syntax: libURLSetStatusCallback [<messageName>[, <objectLongID>]]
66

77
Summary:
88
Sets up a <callback|callback message> to be sent periodically during
@@ -24,6 +24,9 @@ libURLSetStatusCallback "putPercentage",the long ID of me
2424
Example:
2525
libURLSetStatusCallback myAction,the long ID of button "Upload"
2626

27+
Example:
28+
libURLSetStatusCallback "putPercentage" -- sends message to url library. Handle the message in a frontscript, backscript, or stack in use.
29+
2730
Example:
2831
libURLSetStatusCallback -- turns off status callback messages
2932

@@ -33,7 +36,10 @@ The name of a message to be sent whenever the URLStatus function is
3336
updated.
3437

3538
objectLongID:
36-
The long ID of the object to send the message to.
39+
The long ID of the object to send the message to. If <messageName> is
40+
not empty and <objectLongID> is not specified then the message will be sent to
41+
the revLibURL library stack. The message can be handled in a frontscript,
42+
backscript, or library stack.
3743

3844
Description:
3945
Use the <libURLSetStatusCallback> <command> if you want to do periodic
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# libURLSetStatusCallback no longer requires a target object for the message
2+
3+
Passing an object reference as a second parameter to libURLSetStatusCallback
4+
is no longer required. If no object is passed in then the message will be sent
5+
to revLibURL itself and you can handle the message anywhere in the message path.

ide-support/revliburl.livecodescript

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3562,7 +3562,13 @@ end libUrlSetLogField
35623562
---------------------------
35633563
on libUrlSetStatusCallback pMessage,pObject
35643564
##pObject must be a long ID
3565-
if pMessage <> empty and exists(pObject) then
3565+
##Allow empty value in which case we use send to self.
3566+
if pMessage is not empty and the paramCount is 1 then
3567+
put pMessage & comma into lvStatusCallback
3568+
else if pMessage is not empty and the paramCount is 2 then
3569+
if not exists(pObject) then
3570+
return "invalid callback target object" for error
3571+
end if
35663572
put pMessage & comma & pObject into lvStatusCallback
35673573
else
35683574
put empty into lvStatusCallback
@@ -3936,15 +3942,20 @@ on ulSendMessage pUrl
39363942
end ulSendMessage
39373943
----------------------------
39383944
on ulSendCallback pUrl, pStatus
3939-
local tMessage,tObject
3945+
local tMessage,tObject,tSendStr
39403946

39413947
if lvStatusCallback is empty then exit ulSendCallback
39423948
put item 1 of lvStatusCallback into tMessage
39433949

39443950
put item 2 to -1 of lvStatusCallback into tObject ##modified dc 220905
3951+
put tMessage && "pURL, pStatus" into tSendStr
3952+
39453953
if exists(tObject) then
39463954
## need quotes for the url formatting and the possibility of multiple items in second argument
3947-
send tMessage && quote & pUrl & quote & comma & quote & pStatus & quote to tObject in 0 milliseconds
3955+
send tSendStr to tObject in 0 milliseconds
3956+
else
3957+
# If no target then just send to self so it propagates through message path.
3958+
send tSendStr to me in 0 milliseconds
39483959
end if
39493960
end ulSendCallback
39503961
-----------------------------

0 commit comments

Comments
 (0)