Page 1 of 1

### How to calculate a variable that contains digits

Posted: 29 Jun 2019, 07:00
If I set the number into a variable or a message box,then AHk calculates them but if I copy the numbers and use the clipboard as variable,AHk will display them rather than calculate them

Var = 5+5
Msgbox,% var ; displays 5+5

var := 5+5
msgbox,% var ; displays 10

var := Clipboard ; the clipboard contains 5+5
msgbox,% var ; displays 5+5

Var1 = 5+5
var2 := var1
msgbox,% var2 ; displays 5+5

### Re: How to calculate a variable that contains digits

Posted: 29 Jun 2019, 08:43

### Re: How to calculate a variable that contains digits

Posted: 29 Jun 2019, 09:09
Yes I know that but why AHK can calculate variable with digits with no extra functions but need that code if the calculation is in a variable

Can calculate
Msgbox,% 5+5

Can't calculate and need that extra code to do the calculation
var = 5+5
msgbox,% var

### Re: How to calculate a variable that contains digits

Posted: 29 Jun 2019, 09:18

### Re: How to calculate a variable that contains digits

Posted: 29 Jun 2019, 09:27
https://www.autohotkey.com/docs/Variables.htm#Intro

Code: Select all

``````;var = TEXT
var = 5 + 5

MsgBox, % var

;var = % Experssion
var = % 5 + 5

MsgBox, % var

;var := "TEXT"
var := "5 + 5"

MsgBox, % var

var := 5 + 5

MsgBox, % var
``````