SetTimer and functions in v1 Topic is solved

Share your ideas as to how the documentation can be improved.
wineguy
Posts: 9
Joined: 03 Dec 2019, 16:26

SetTimer and functions in v1

Post by wineguy » 19 Oct 2021, 18:09

Hi,
Currently if you reference a function name (or func object I think) from SetTimer, the fuction must have either no paramteters, or an optional parameter ie SetTimerFunc(param:=""), otherwise you get an error

Code: Select all

Error:  Target label does not exist.
If it is in the documentation elsewhere I couldn't find it sorry, but at very least this info should be on the SetTimer page under the Label section.

safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: SetTimer and functions in v1

Post by safetycar » 21 Oct 2021, 11:19

Maybe the text of the error could be different.
The error itself is related to SetTimer not being able to pass any parameters, so not fulfilling the requirement of non-optional parameters.
You might want to read a thread that explains how to pass parameters through timers: viewtopic.php?t=13010

iseahound
Posts: 1434
Joined: 13 Aug 2016, 21:04
Contact:

Re: SetTimer and functions in v1

Post by iseahound » 21 Oct 2021, 23:05

Use ObjBindMethod for classes. This is one of those v1 gotchas that make the language hard to use.

wineguy
Posts: 9
Joined: 03 Dec 2019, 16:26

Re: SetTimer and functions in v1

Post by wineguy » 24 Oct 2021, 16:45

safetycar wrote:
21 Oct 2021, 11:19
The error itself is related to SetTimer not being able to pass any parameters, so not fulfilling the requirement of non-optional parameters.
Thanks @safetycar. I realise that and perhaps didn't make myself clear, but I don't actually want to pass a parameter to the function from SetTimer. I just want to call a function that takes parameters (which I use elsewhere in my script) and so the documentation could be updated to help others A moot point in V2 obviously. 👍

safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: SetTimer and functions in v1

Post by safetycar » 25 Oct 2021, 09:03

Let's wait for @Ragnar I think that maybe this part of the could be changed:
[v1.1.20+]: If not a valid label name, this parameter can be the name of a function that accepts being called without parameters, or a single variable reference containing a function object. For example, SetTimer %FuncObj%, 1000 or SetTimer % FuncObj, 1000. Other expressions which return objects are currently unsupported. See the class example for more details.

User avatar
Ragnar
Posts: 611
Joined: 30 Sep 2013, 15:25

Re: SetTimer and functions in v1  Topic is solved

Post by Ragnar » 28 Oct 2021, 07:32

Thanks for reporting. Changes added in PR #527.

Post Reply

Return to “Suggestions on Documentation Improvements”