# How do i Write Exp if the Operator is a Variable

Get help using Construct 2

### » Mon Jan 25, 2016 10:56 am

Variable a = 5
Variable b = 5
Variable c = "+"
Variable d = +

Variable f = Variable a Variable c Variable b
answer is 10 how do i write the above formula

or

Variable f = Variable a Variable d Variable b
answer is 10 how do i write the above formula

it is simple but i cant solve i know how to write var a + var b = 10 but how to write it when the operator is also a variable?
B
9
S
2
Posts: 67
Reputation: 719

### » Mon Jan 25, 2016 11:05 am

Because variable c and variable d are not values but strings(texts) you couldn't do it directly..
To calculate the value variable f

You should first check the variable d:

System compare variable d = "+"
- set variable f = variable a + variable b

System compare variable d = "-"
- set variable f = variable a - variable b

System compare variable d = "x"
- set variable f = variable a * variable b

System compare variable d = ":"
- set variable f = variable a / variable b
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Mon Jan 25, 2016 11:00 pm

@LittleStain thanks i did not know var operator can only be string
B
9
S
2
Posts: 67
Reputation: 719