Simple math problem?

Get help using Construct 2

Post » Thu Mar 26, 2015 12:09 pm

Simple math problem?

Hello friends
I need to implement the following
In a "Tex Box" income numbers, pressing the button, each of these numbers (separately) is loaded into an ARRAY.
What I do is the following
If I enter the following number "123456"
Is loaded into the array:
Set value at 0 to mid (TextBox.Text, 0.1)
Set value at 1 to mid (TextBox.Text, 1.1)
Set value at 2 to mid (TextBox.Text, 2.1)
Set value at March to mid (TextBox.Text, 3.1)

Keep the number of characters in a variable "Char"

system -> Set char to len (TextBox.Text)

And then be added together and divided by the total number of characters, where I apply the following
Text2 -> Set Text -> "Sum:" & (Array.At (0) + Array.At (1) Array.At (2) + Array.At (3) + Array.At (4)) / char

But I manage to find the result as it always shows me = 1 :shock:

This is te .CAPX

https://dl.dropboxusercontent.com/u/19024090/Math.capx

In that I'm wrong?

Thank You
B
43
S
11
G
2
Posts: 111
Reputation: 3,858

Post » Thu Mar 26, 2015 12:43 pm

Have you tried making sure that the values you write to the array are ints?

i.e.

int(mid(TextBox.Text,0,1))

Seems to then work as expected.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
86
Posts: 5,483
Reputation: 59,752

Post » Thu Mar 26, 2015 1:51 pm

B
34
S
9
G
3
Posts: 517
Reputation: 5,246

Post » Thu Mar 26, 2015 2:06 pm

zenox98 wrote:Have you tried making sure that the values you write to the array are ints?

i.e.

int(mid(TextBox.Text,0,1))

Seems to then work as expected.


still does not work :(
B
43
S
11
G
2
Posts: 111
Reputation: 3,858

Post » Thu Mar 26, 2015 2:08 pm

Katala wrote:I think it would be easier to use loops.

https://dl.dropboxusercontent.com/u/104893773/C2%20examples/Math%20loops.capx


Works perfect.
I think I need to learn further programming.
The " LOOPS " are something new for me, the "ARRAY " bring me a headache .
Thank You
B
43
S
11
G
2
Posts: 111
Reputation: 3,858

Post » Fri Apr 03, 2015 1:10 pm

Message: Defender225 can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Katala wrote:I think it would be easier to use loops.

https://dl.dropboxusercontent.com/u/104893773/C2%20examples/Math%20loops.capx



Toinen how i can contact with you? please messagin me to [email protected]
B
4
Posts: 15
Reputation: 304


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 9 guests