Android Question Populating sliders at startup

Christian Blackburn

Member
Licensed User
Longtime User
Hi Guys,

I'm still super new to B4A. I'm frustrated with the excessive rules for variable scope. I just want to populate a few spinner controls at application startup. One is the number of months 1 to 12 and the other is the number of days 1 to 31. When I run my program I get the following error:
B4A version: 5.20

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. Error
Unassigned variable: 'i'
Error File: data_input.bal

Go to the designer script page to debug this error.


Sub Process_Globals
Public i As Int
i = 0
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("Data_Input")
End Sub

Then in the Script - General in my designer for the "Data_Input" activity I have the following:
for i = 1 to 12
spnBirth_Month.Add(i)
spnBirth_Day.Add(i)

next

for intCounter = 13 to 31

spnBirth_Day.Add(i)
next

'All variants script
AutoScaleAll



Thank you very much for your help,
Christian Blackburn
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
I think that it would be worth you taking a moment to skim through the beginners guide https://www.b4x.com/android/files/guide.zip
It's obvious that you have some programming experience but B4A has subtle differences to other programming languages.

For starters, no code is allowed in Process Globals. Only declarations and assigning constants is allowed in this region.
With regard to the designer script, this is used to format your views to look good on a variety of different devices. Again it is not the place for general code. That should be done in one of your Activities or other Modules.

You'll gain far more from B4A if you spent an hour or two skimming through the user manual.
 
Upvote 0

Christian Blackburn

Member
Licensed User
Longtime User
Hi RandomCoder,

Thank you for your help and advice. I like to learn as I go and that will include the manual.

Thanks,
Christian Blackburn
 
Upvote 0
Top