
Quote from sghoshnbu on May 3, 2022, 2:19 pmHi nerds,
Trying to calculate the array of item values from list boxes but got stuck. Would you please mind to point me the errors?
Hi nerds,
Trying to calculate the array of item values from list boxes but got stuck. Would you please mind to point me the errors?
Uploaded files:
Quote from luishp on May 3, 2022, 5:36 pm@sghoshnbu please clarify the problem. I can't understand what do you intend to achive, sorry.
@sghoshnbu please clarify the problem. I can't understand what do you intend to achive, sorry.

Quote from sghoshnbu on May 3, 2022, 6:02 pmThe first column is the range of values for grouped data. It takes lower value, class width and last lower value and this makes ranges. As for example if lower value is 10, class width is 10 and lower value of the last class is 60 , it will make
10-20
20-30
30-40
40-50
50-60
60-70
The second list box loops with the arraylength of first list box and takes frequencies in [frequency] array . The third list box is the midvalue of each iterations of first list box ( i.e 10+20= 30/2 = 15.)
I need to multiply each arrayitem values of [midvalues] with each arrayitem values in [frequency] array and to populate that under listbox 4 that is [fx] array.
I need to calculate the product of [frequency (0)] * [midvalues(0)].
I am unable to find the way of calculating a numeric value(frequency) with midvalues which seem as string values.
Hope I am clear.
The first column is the range of values for grouped data. It takes lower value, class width and last lower value and this makes ranges. As for example if lower value is 10, class width is 10 and lower value of the last class is 60 , it will make
10-20
20-30
30-40
40-50
50-60
60-70
The second list box loops with the arraylength of first list box and takes frequencies in [frequency] array . The third list box is the midvalue of each iterations of first list box ( i.e 10+20= 30/2 = 15.)
I need to multiply each arrayitem values of [midvalues] with each arrayitem values in [frequency] array and to populate that under listbox 4 that is [fx] array.
I need to calculate the product of [frequency (0)] * [midvalues(0)].
I am unable to find the way of calculating a numeric value(frequency) with midvalues which seem as string values.
Hope I am clear.

Quote from luishp on May 3, 2022, 6:22 pm@sghoshnbu have you tried the Math command? It allows calculations over mathematical string based formulas just like:
SetVar [monthlyRent] 1200 Math "([monthlyRent]*12)/52" 2 [weeklyRent]Where are you getting the problem exactly?
Looping the items?
Getting or setting array values?
Calculations?
Can you please isolate the problem?Regards.
@sghoshnbu have you tried the Math command? It allows calculations over mathematical string based formulas just like:
SetVar [monthlyRent] 1200 Math "([monthlyRent]*12)/52" 2 [weeklyRent]
Where are you getting the problem exactly?
Looping the items?
Getting or setting array values?
Calculations?
Can you please isolate the problem?
Regards.
Quote from Gaev on May 4, 2022, 1:44 am@sghoshnbu
I am not sure why you have the vertical bars (|) at the end of each array item in the [frequency] and [midvalues] arrays, but this is what was causing the problem in the code for the button labelled fx
Here is the modified code (transforming the string values of the array items to numbers before doing the Math ...
CreateEmptyArray [fx] ArrayLen [frequency] [sarray] ...AlertBox "sarray" "... [sarray]" "" Loop 0 [sarray] [aloop] SetVar [var1s] [frequency([aloop])] ToNumber "[var1s]" [var1] SetVar [var2s] [midvalues([aloop])] ToNumber "[var2s]" [var2] ...AlertBox "var1,var2" "... [var1] ... [var2]" "" Math "[var1]*[var2]" 2 [fx1] ...AlertBox "var1,var2,frequency,midvalues" "[aloop] ... [var1] ... [var2]" "" ArrayAddItem [fx] "[fx1]|" EndloopI have left the (now commented) AlertBox commands that I used to diagnose the problem.
I am not sure why you have the vertical bars (|) at the end of each array item in the [frequency] and [midvalues] arrays, but this is what was causing the problem in the code for the button labelled fx
Here is the modified code (transforming the string values of the array items to numbers before doing the Math ...
CreateEmptyArray [fx] ArrayLen [frequency] [sarray] ...AlertBox "sarray" "... [sarray]" "" Loop 0 [sarray] [aloop] SetVar [var1s] [frequency([aloop])] ToNumber "[var1s]" [var1] SetVar [var2s] [midvalues([aloop])] ToNumber "[var2s]" [var2] ...AlertBox "var1,var2" "... [var1] ... [var2]" "" Math "[var1]*[var2]" 2 [fx1] ...AlertBox "var1,var2,frequency,midvalues" "[aloop] ... [var1] ... [var2]" "" ArrayAddItem [fx] "[fx1]|" Endloop
I have left the (now commented) AlertBox commands that I used to diagnose the problem.

Quote from sghoshnbu on May 4, 2022, 6:47 am@Gaev,
Thank you for the code. It works flawlessly. I did the same with VisualNeoWin but got stuck with the tweaking required for VNWeb. Setvar and ToNumber, I didn't even think of. Learning is always a continuum.
Thank you for directing me to the goal. Keep fine.
SG
Thank you for the code. It works flawlessly. I did the same with VisualNeoWin but got stuck with the tweaking required for VNWeb. Setvar and ToNumber, I didn't even think of. Learning is always a continuum.
Thank you for directing me to the goal. Keep fine.
SG