# How do I campare numbers !!??

Get help using Construct 2

### » Sun Jun 29, 2014 11:58 am

i want to compare two numbers one is fixed and the other is variable
so i give a number and campared to the fixed until they will be equal
help me pleasseee
B
3
Posts: 9
Reputation: 193

### » Sun Jun 29, 2014 12:00 pm

"System" > "Compare Variable" when adding a condition.
B
6
S
1
Posts: 73
Reputation: 571

### » Sun Jun 29, 2014 12:08 pm

If none of them is a Global or Local Variable, like, if you want to compare the result of two equations, you may use System > Compare two values.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
22
S
6
G
3
Posts: 717
Reputation: 4,006

### » Sun Jun 29, 2014 12:34 pm

yes i trie it but i want to campare every chifre of the nomber with the the other one
exemple
m1=2365
m2=9517
iwant to compare 2 with 9 and 3 with 5 and 1 to 6
if the are equal a message appeare
B
3
Posts: 9
Reputation: 193

### » Sun Jun 29, 2014 1:11 pm

You can use an array to store the numbers of m1 and m2 in and then use a "For each" condition to check wether they are equal.
More on arrays can be found here:
https://www.scirra.com/manual/108/array
B
6
S
1
Posts: 73
Reputation: 571

### » Sun Jun 29, 2014 1:37 pm

Then you're not really comparing numbers, you're comparing strings.

You can use a repeat loop with a count of len(string1) and compare each item in the string with the corresponding value on the other using mid(string1, loopindex, 0) and mid(string2, loopindex, 0).

Example:

This example will return 1 if the numbers are the same or 0 if they're not.

You just need to check if "Function.Call("nameOfYourFunction", str(firstVariable), str(secondVariable)) is equal to 1 or 0 and show your message if it's 1.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
22
S
6
G
3
Posts: 717
Reputation: 4,006

thnks a lot
B
3
Posts: 9
Reputation: 193