S SteveBee Member Licensed User Longtime User Jun 16, 2011 #1 I have read the tutorial re. Two Activities, but am having a problem implementing it. My Main is a ListView; I have this in the itemclick handler: Code: Copy Sub ListView1_ItemClick (Position As Int, Value As Object) JobViewID = value 'store the value in the process global object. StartActivity(JobForm) End Sub Note that JobViewID is a global: Code: Copy Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim parser As SaxParser, JobViewID As String End Sub So, when the listitem is touched, I expect the Jobform to load; in its create sub, I have: Code: Copy Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout(("JobForm") Activity.Title = Activity.Title & " " & JobViewID End Sub But when I try to compile I get a warning re. the 'global': Compiling code. Error Error parsing program. Error description: Undeclared variable 'jobviewid' is used before it was assigned any value. Occurred on line: 17 Activity.Title = Activity.Title & " " & JobViewID I thought I had emulated the example, and I did put my link var. ("JobViewID") in the global section, but it doesn't link. It did seem a strange way of doing things... but that was what it said in the tutorial (in my reading). Can you clear up my misunderstanding? Steve
I have read the tutorial re. Two Activities, but am having a problem implementing it. My Main is a ListView; I have this in the itemclick handler: Code: Copy Sub ListView1_ItemClick (Position As Int, Value As Object) JobViewID = value 'store the value in the process global object. StartActivity(JobForm) End Sub Note that JobViewID is a global: Code: Copy Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim parser As SaxParser, JobViewID As String End Sub So, when the listitem is touched, I expect the Jobform to load; in its create sub, I have: Code: Copy Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout(("JobForm") Activity.Title = Activity.Title & " " & JobViewID End Sub But when I try to compile I get a warning re. the 'global': Compiling code. Error Error parsing program. Error description: Undeclared variable 'jobviewid' is used before it was assigned any value. Occurred on line: 17 Activity.Title = Activity.Title & " " & JobViewID I thought I had emulated the example, and I did put my link var. ("JobViewID") in the global section, but it doesn't link. It did seem a strange way of doing things... but that was what it said in the tutorial (in my reading). Can you clear up my misunderstanding? Steve
agraham Expert Licensed User Longtime User Jun 16, 2011 #2 To access a Global in a module other than the one in which it is declared you need to prefix the module name - Main.JobViewID. Upvote 0
To access a Global in a module other than the one in which it is declared you need to prefix the module name - Main.JobViewID.
nfordbscndrd Well-Known Member Licensed User Longtime User Jun 16, 2011 #3 We just had this discussion on here in the last day or so, and it is now shown in the B4A Documentation Wiki. Upvote 0
We just had this discussion on here in the last day or so, and it is now shown in the B4A Documentation Wiki.
S SteveBee Member Licensed User Longtime User Jun 16, 2011 #4 Ah, I see. Tx, will try it out after dinner... Upvote 0