Hi all
It's been a while since i posted something in the community. But here i'm stuck with some understanding of how to use a multidimensional array as a matix.
Let me explain.. I have a multidimensional array like that Dim nTotals = Array as int(2,13,53,8)
What the dimension represent firts element is 0 to 2 is the values of counter for a year 0 = 2024 and 1 = 2025
the second Dimension is the month 0 to 12 where 0 is january,1 is february and so on
The third Dimension is the week number of the same year from 0 to 52 weeks
the last Dimension is the day number from 0 to 7 where 0=sunday,1=monday and so on
In the code i define an array like this Dim nTotals(2,13,53,8) the number of element in each dimension is equal the number of elements plus 1 as the array system work like that as it need one more element for not having error when you access the last element since it is all 0 base declaration for array
IN javascript you can assign values for each dimension using a standard defenition per example
so if i want to access values for year 0, month 7, week 31, day 1 i simply tell wich dimension element number i want to access and it give me a value for let say month 7 got 12
week number 32 got value of 20, day number 3 got value of 10, and i do that for each element in each dimension, and that what i call a matrix
So far it only return the value for the last dimension wich is the day value not the month. so there is something i don't understand about array in B4X.
Do you think it is possible to do that using array only. ??
The functions return an integer value for each elements and the currentxxx is the current index of the array
So if i define an array in B4X, it seems like i can't assign value in the dimension and the values returned when i iterate thrue the dimensions and elemnts, always return the values that are stored in getDayValue(currentDay) it dos not store the values for each dimension separately.
I use this in javascript to create a matrix of value for each year, month, week, and day as for example if i want to get the values for year 0, month 7, week 30, and day 1 it return the value of day not the month, week
The idea behind this is to store values for each month, week and day separately withing a specific year
So if someone have an idea on how to create an array or maybe a map or a type that can store and access the different values store in each dimension for specific elements, i welcome some example or explanation on how to do this in B4X for android.
Thanks guys..
It's been a while since i posted something in the community. But here i'm stuck with some understanding of how to use a multidimensional array as a matix.
Let me explain.. I have a multidimensional array like that Dim nTotals = Array as int(2,13,53,8)
What the dimension represent firts element is 0 to 2 is the values of counter for a year 0 = 2024 and 1 = 2025
the second Dimension is the month 0 to 12 where 0 is january,1 is february and so on
The third Dimension is the week number of the same year from 0 to 52 weeks
the last Dimension is the day number from 0 to 7 where 0=sunday,1=monday and so on
In the code i define an array like this Dim nTotals(2,13,53,8) the number of element in each dimension is equal the number of elements plus 1 as the array system work like that as it need one more element for not having error when you access the last element since it is all 0 base declaration for array
IN javascript you can assign values for each dimension using a standard defenition per example
B4X:
nTotals[1,3,30,1] = 10
nTotals[1,3,30,2] = 20
nTotals[0,1,10,3]= 12
' In my code in javascript i use a function to assign values to elements like
[ getYearValue(currentYear), getMonthValue(CurrentMonth), getWeekValue(currentWeek),getDayValue(CurrentDay) ]
' currentYear, currentMonth, currentWeek, currentDay
' refers to the values as integer for the dimension i want to set or read from
' 0, 4, 31, 1 Some return values for each function in the dimensions elements
so if i want to access values for year 0, month 7, week 31, day 1 i simply tell wich dimension element number i want to access and it give me a value for let say month 7 got 12
week number 32 got value of 20, day number 3 got value of 10, and i do that for each element in each dimension, and that what i call a matrix
So far it only return the value for the last dimension wich is the day value not the month. so there is something i don't understand about array in B4X.
Do you think it is possible to do that using array only. ??
The functions return an integer value for each elements and the currentxxx is the current index of the array
So if i define an array in B4X, it seems like i can't assign value in the dimension and the values returned when i iterate thrue the dimensions and elemnts, always return the values that are stored in getDayValue(currentDay) it dos not store the values for each dimension separately.
I use this in javascript to create a matrix of value for each year, month, week, and day as for example if i want to get the values for year 0, month 7, week 30, and day 1 it return the value of day not the month, week
The idea behind this is to store values for each month, week and day separately withing a specific year
So if someone have an idea on how to create an array or maybe a map or a type that can store and access the different values store in each dimension for specific elements, i welcome some example or explanation on how to do this in B4X for android.
Thanks guys..