My question is: Can I use wildcards in the case statement? I tried but wasn't getting anywhere.
Code: Select all
var = "all ok"
switch var
{
case "*ok*" : some command
case "?ok?": some command
}
Code: Select all
var = "all ok"
switch var
{
case "*ok*" : some command
case "?ok?": some command
}
Code: Select all
var = all ok
Switch Instr(var, "ok")
{
Case 0 : MsgBox, Nope!
Default: MsgBox, Found it!
}
Code: Select all
var := "all ok"
InStr(var, "ok") ? SomeCommand("a")
: (var > 7 && var < 10) ? SomeCommand("b")
: (var = "an exact phrase") ? SomeCommand("c")
: "" ;default (do nothing)
SomeCommand(param){
msgbox % param
}
No.netaware wrote:so the CASE command can only contain a text string?
Yes...and more...it is an expression:netaware wrote:can it contain a variable too?
Code: Select all
var = "all ok"
switch
{
case (var ~= "i).+ok.+"): some command
case (var ~= "i).ok."): some command
}