Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Optimizing Code


  • Please log in to reply
2 replies to this topic
bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011

any intelligent way to make the following code segments as short as possible?:

IfInString, var, .com
GoTo, L1
Else
IfInString, var, .net
GoTo, L1
Else
IfInString, var, .org
GoTo, L1
Else
IfInString, var, .edu
GoTo, L1
Else
IfInString, var, .gov
GoTo, L1
Else
IfInString, var, .mil
GoTo, L1
Else
IfInString, var, .biz
GoTo, L1
Else
IfInString, var, .info
GoTo, L1
Else
GoTo, ERR2

and

IfInString, var, .com
Return
Else
IfInString, var, .net
Return
Else
IfInString, var, .org
Return
Else
IfInString, var, .edu
Return
Else
IfInString, var, .gov
Return
Else
IfInString, var, .mil
Return
Else
IfInString, var, .biz
Return
Else
IfInString, var, .info
Return


space
  • Members
  • 520 posts
  • Last active:
  • Joined: 12 Aug 2014
I'd use RegExMatch I think - you can find the meaning if i) \ . and | here http://ahkscript.org...Ex-QuickRef.htm
var=autohotkey.com
If RegExMatch(var,"i)\.(com|net|org|edu|gov|mil|biz|info)")
	Goto, L1
Else	
	Goto, ERR2

If RegExMatch(var,"i)\.(com|net|org|edu|gov|mil|biz|info)")
	Return


bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011

wow, thanks, space! that was a masterpiece. ;)