I have this line
CallSub3(Main, m_MainSub, "Start", "")
in version 2.70
I get red line which indicates "cannot access exclude:main" message,
but the call works fine.
what is the issue?
thanks
Erel,
Yes it does, here is the msg
Parsing code. 0.06
Compiling code. Error
Error compiling program.
Error description: Cannot access excluded module: main
Occurred on line: 171
CallSub3(Main, m_MainSub, "Start", "")
Word: main
Your library cannot have any dependence upon an external module and so cannot know about specific modules and their Subs. You can however pass the information to the module at runtime. For example a trivial code module
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim A As String
Dim S As String
End Sub
Sub Initialize(Act As String, Subname As String)
A = Act
S = Subname
End Sub
Sub CallMeBack(p1 As String, p2 As String)
CallSub3(A, S, p1, p2)
End Sub
Note that it is better to set the "target" type to Object:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim A As Object
Dim S As String
End Sub
Sub Initialize(Target As Object, Subname As String)
A = Act
S = Subname
End Sub
Sub CallMeBack(p1 As String, p2 As String)
CallSub3(A, S, p1, p2)
End Sub
Then when you initialize the object you should write:
I know this is old, but I have the same problem and I do not understand the help given by Erel and agraham. Can someone please elaborate?
In the menu module I have this:
B4X:
If KeyCode = KeyCodes.KEYCODE_BACK AND sm.isVisible = False Then
If Msgbox2("Exit Program?", "EXIT", "Yes", "", "No", Null) =DialogResponse.POSITIVE Then
Activity.Finish
Main.ExitProg = True
And then this in the main:
B4X:
Dim ExitProg As Boolean : ExitProg = False
Sub Activity_Resume
If ExitProg = True Then
ExitApplication
End If
End Sub
I apologize, I did not read the first posting before I said that I had the same problem. What I posted was actually my problem, I just seen his after searching the forum. The error reads :
B4X:
Parsing code. 0.02
Compiling code. Error
Error compiling program.
Error description: Cannot access excluded module: main
Occurred on line: 73
Main.ExitProg = True
Word: main
And in the keycode back statement before was where the error is :
B4X:
Main.ExitProg = True
Sorry for the misunderstanding, but I hope someone can help.