Page 1 of 1
error in if
Posted: 24 Apr 2024, 11:56
by cimerio
I just can't understand why the code below shows error in line 13
Code: Select all
#SingleInstance force
SetKeyDelay, 4
#Include arquivoDados.ahk
Esc::ExitApp
#IfWinActive ahk_class Chrome_WidgetWin_1
{
!a::
if (%CurrentMonth% = "abr" or %CurrentMonth% = "jun" or %CurrentMonth% = "set" or %CurrentMonth% = "nov")
%qtdias% = "30"
else
%qtdias% = "31"
MsgBox, %qtdias%
return
}
Re: error in if
Posted: 24 Apr 2024, 12:03
by mikeyww
It's the following.
Explained:
Variables
Re: error in if
Posted: 25 Apr 2024, 12:55
by cimerio
the selected attachment doesn't exist anymore
Re: error in if
Posted: 25 Apr 2024, 13:37
by mikeyww
It looks like the forum has automatically provided a link to the image instead of an attachment. I have no idea why.
Re: error in if
Posted: 26 Apr 2024, 08:13
by cimerio
mikey, I changed to code below and the error disappearead. but now the result is wrong. always show '31', but the current month is apr. should be '30'
Code: Select all
#SingleInstance force
SetKeyDelay, 4
#Include arquivoDados.ahk
Esc::ExitApp
#IfWinActive ahk_class SciTEWindow
{
!a::
if (%CurrentMonth% = "abr" or %CurrentMonth% = "jun" or %CurrentMonth% = "set" or %CurrentMonth% = "nov")
qtdias := 30
else
qtdias := 31
MsgBox, %qtdias%
MsgBox, %CurrentMonth%
return
}
Re: error in if
Posted: 26 Apr 2024, 08:36
by mikeyww
I recommend reading about expressions and
If in the documentation. Ideas are below. This shows how to refer to expressions. In most situations,
% is not used to refer to variables in expressions.
Code: Select all
#Requires AutoHotkey v1.1.33.11
a := 1
If (a = 1)
b := 3
MsgBox % b
Code: Select all
#Requires AutoHotkey v1.1.33.11
qtdias := 31
If (A_MMM ~= "i)abr|apr|jun|set|sep|nov")
qtdias := 30
MsgBox 64, Result, % qtdias