Android Question [Solved] call a sub in codemodule with callsubdelayed fails

Pflichtfeld

Active Member
Licensed User
Must I not use CallsubDelayedX for subs in a codemodule?
I get this error:

CallSubDelayed(CalcAndDraw,\
shell\src\Test\TH\main_subs_0.java:57: error: cannot find symbol
parent.mostCurrent.__c.runVoidMethod ("CallSubDelayed",main.processBA,(Object)((parent.mostCurrent._calcanddraw.getObject())),(Object)(RemoteObject.createImmutable("test")));


when calling
B4X:
CallSubDelayed(CalcAndDraw,"test")
from main-activity, where CalcAndDraw is a codemodule

Or is it simply rubbish, to call a sub in a codemodule with callsubdelayed?
(sorry about my frequent postings, I try to approach to this language from VB.Net and there is so much to learn...)
 
Last edited:

JohnC

Expert
Licensed User
Longtime User
Subs in Code Modules are always available, so you don't need to use CallSubDelayed.

CallSubDelayed is used when calling subs in services or activities because they may not be loaded at the time you call them, so callsubdelayed gives them time to load and then runs the sub.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
There's no problem with frequent postings. Anyway, it's always useful using the search feature of the forum, because there's a lot of answered questions.
Note that this is an advice, I'm not telling you off :-D


The CallSubDelayed tutorial, metions this too:

Note that you cannot use CallSubDelayed (or CallSub) with code modules.
CallSubDelayed can be used with class instances. However the containing module will not be started if it is not already running

EDIT: hum, re-reading your question, I'm not sure if my answer is wrong. Maybe I've understood it the other way round
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
It should work. Post an example project that recreates the issue.
Subs in Code Modules are always available, so you don't need to use CallSubDelayed.
That depends. Sometimes you need to let the system do something and therefore you use callsubdelayed to place your call onto the queue, let the system process something and then execute your code. This is a terrible explanation, but callsubdelayed has its place in inter activity/module usage.
 
Upvote 0
Top