Autohotkey 检查可变数量的If语句
我从Ini文件到数组中检索具有一系列文件扩展名的字符串。 本质上,我想检查变量%ext%是否等于数组中的任何文件扩展名。为了澄清,我不知道提前会有多少项目 我知道我解释得很糟糕,所以我将尝试用伪代码来阐明这一点Autohotkey 检查可变数量的If语句,autohotkey,Autohotkey,我从Ini文件到数组中检索具有一系列文件扩展名的字符串。 本质上,我想检查变量%ext%是否等于数组中的任何文件扩展名。为了澄清,我不知道提前会有多少项目 我知道我解释得很糟糕,所以我将尝试用伪代码来阐明这一点 ext := jpg ;(for example) IniRead, extsFromFile, data.ini, Images, Extensions StringSplit, allExts, extsFromFile, `, If (ext = <any of the el
ext := jpg ;(for example)
IniRead, extsFromFile, data.ini, Images, Extensions
StringSplit, allExts, extsFromFile, `,
If (ext = <any of the elements in the array allExts>)
doStuff()
ext:=jpg;(例如)
InRead、extsFromFile、data.ini、图像、扩展名
StringSplit、allExts、extsFromFile、`、,
如果(ext=)
多斯塔夫()
我对如何用自动热键解决这个问题一无所知。我对这门语言不太熟悉 代码:
ext := "jpg"
found := "false"
Loop, read, ExtsList.txt ;this loops reads each line of the file...
{
If ext = %A_LoopReadLine% ; A_LoopReadLine is the value of the current line...
{
msgbox, Found "%ext%" in "ExtsList.txt" at line "%A_Index%"...
;call function "dostuff()"
found := "true"
}
}
if found = false
{
msgbox, Did not find "%ext%" in "ExtsList.txt"...
}
ExtsList.txt
png
svg
xml
jpg
html
txt
祝你好运D代码:
ext := "jpg"
found := "false"
Loop, read, ExtsList.txt ;this loops reads each line of the file...
{
If ext = %A_LoopReadLine% ; A_LoopReadLine is the value of the current line...
{
msgbox, Found "%ext%" in "ExtsList.txt" at line "%A_Index%"...
;call function "dostuff()"
found := "true"
}
}
if found = false
{
msgbox, Did not find "%ext%" in "ExtsList.txt"...
}
ExtsList.txt
png
svg
xml
jpg
html
txt
祝你好运DStringSplit以OutputVar0的形式为您提供最后一个元素的索引(或长度,取决于您对它的看法)。您可以使用内置的A_索引变量循环检查每个元素是否匹配
ext := "jpg" ;(for example)
IniRead, extsFromFile, data.ini, Images, Extensions
; For debugging/testing purposes
extsFromFile = png,bmp,tiff,jpg
StringSplit, allExts, extsFromFile, `,
Loop %allExts0%
If (ext = allExts%A_Index%)
MsgBox Match! We have %allExts0% extensions and "%ext%" was the %A_Index%th
给予
比赛!我们有4个扩展,“jpg”是第4个
StringSplit以OutputVar0的形式为您提供最后一个元素的索引(或长度,取决于您对它的看法)。您可以使用内置的A_索引变量循环检查每个元素是否匹配
ext := "jpg" ;(for example)
IniRead, extsFromFile, data.ini, Images, Extensions
; For debugging/testing purposes
extsFromFile = png,bmp,tiff,jpg
StringSplit, allExts, extsFromFile, `,
Loop %allExts0%
If (ext = allExts%A_Index%)
MsgBox Match! We have %allExts0% extensions and "%ext%" was the %A_Index%th
给予
比赛!我们有4个扩展,“jpg”是第4个
谢谢,但不是我想要的。我在INI文件中存储了更多的内容,因此不想对其进行完整的分析。好的,我会研究一下。。我可以看一下ini文件吗?我的电子邮件在我的个人资料中。:)谢谢,但不是我想要的。我在INI文件中存储了更多的内容,因此不想对其进行完整的分析。好的,我会研究一下。。我可以看一下ini文件吗?我的电子邮件在我的个人资料中。:)