How to calculate a variable that contains digits

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

How to calculate a variable that contains digits

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
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: How to calculate a variable that contains digits

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
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: How to calculate a variable that contains digits

29 Jun 2019, 09:18

:wave: There is always more than one way to solve a problem. ;)
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: How to calculate a variable that contains digits

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 := Experssion
var := 5 + 5

MsgBox, % var
:wave: There is always more than one way to solve a problem. ;)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Mateusz53, Rohwedder and 168 guests