Classes in process_globls

texwillerx

Member
Licensed User
Longtime User
I use a class in my code (clstrs). It contains lots of variables in class_globals. I use this class as

dim trs as clstrs

I can only declare this in globals module and not in process_globals. I want to declare this in process_globals so that all the variables in the class will keep their values during the process life cycle, i. e. I don't want them to be initialized for each activity create/resume.

Is there a solution for my problem?

Thanks in advance

Talat Oncu
 

texwillerx

Member
Licensed User
Longtime User
Thank you very much for your reply.

I use the followings

ByteConverter
ArraysExtra
RandomAccessFile
SQL
Cursor

Are these activity objects? Also I use procedures from some libraries (e. g. instr, mid from stringsubroutines and some functions from my subroutine libraries). Are these considered as activity objects?

Thanks

Talat
 
Upvote 0

texwillerx

Member
Licensed User
Longtime User
I am really sorry but I didn't understand what you mean by

"In the Initialize sub in your class, are you getting the Activity".

Would you please explain this a little bit.

Thanks a lot

Talat
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
In your class you have something like:

B4X:
Private Sub Class_Globals
     'Your dimmed vars here
End Sub
Public Sub Initialize(ActivityModule As Object, mAct As Activity)
     'Your initialize code here
End Sub

So what does your Inintialize sub line look like?

B4X:
Public Sub Initialize(ActivityModule As Object, mAct As Activity)

Can you post your class Initialize sub?
 
Upvote 0

texwillerx

Member
Licensed User
Longtime User
OK, I found the problem:

In order to track what is happening in the class module, I passed a Label parameter to the Inıtialize sub and save this value to a Label variable which is defined in Class_Globals. When I deleted this declaration and all references to it, I was able to declare this class in process_globals.

Now, I need help in another point:

How can I pass some messages from class module to the activity module so that these messages are displayed in a Label, so that I can track the execution of the class module:

Thank you for your extremely valueable help.

Regards

Talat
 
Last edited:
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
In your class use the code below and put it where you need it. MyModule is a variable holding the name of the calling Activity. Subname is the name of your sub in the Activity. The second block is how MyModule got it's value.


B4X:
If SubExists(MyModule, "SubName") Then
      CallSub2(MyModule, "SubName", "your message here")
End If

B4X:
Public Sub Initialize(Module As Object)
      MyModule = Module
End Sub
 
Last edited:
Upvote 0
Top