# If Then Endif Infinity

## Recommended Posts

I have found myself in a very very very long file with for example:

```If
\$something = "something"
Then
_something(\$something,\$ship)
Endif
If
\$something2 = "something"
Then
_something(\$something2,\$ship)
Endif
If
\$something3 = "something"
Then
_something(\$something3,\$ship)
Endif
If
\$something4 = "something"
Then
_something(\$something4,\$ship)
Endif
If
\$something5 = "something"
Then
_something(\$something5,\$ship)
Endif```

Can I array this? Make it shorter?

Edited by glasglow

##### Share on other sites

well for starters it would be easier if you gave more info on what your trying to achieve.

and also..

if \$something ="what" then

whatever

elseif \$something = "what2" then

whatever

elseif \$something = "what3" then

whatever

endif

Edited by Aceguy

##### Share on other sites

dim \$something[50]

for \$count = 1 to \$something[0]

if \$something[\$count]= "Whatever" then

dosomething

endif

next

##### Share on other sites

dim \$something[50]

for \$count = 1 to \$something[0]

if \$something[\$count]= "Whatever" then

dosomething

endif

next

Yes this is closer to what I am looking for.. Could I array it? I'm looking for a match for example: (pardon the code but I hope you get the idea)

```IF
\$something = ("one" OR "two" OR "three" OR "four")
Then
Do Something```

I know it's rediculous code but it seems I shoul be able to do it with an array.

Edited by glasglow

##### Share on other sites

```\$something = StringSplit("This,That,The other,This way,That way,The other way", ",")
\$return = StringSplit("Not,Nat,Nope,Dope,Pope,Rope", ",")

; match found
MsgBox(0x0, "answer", "Something = " & _something("That way"))

; no match
MsgBox(0x0, "answer", "Something = " & _something("Thats way"))

Func _something(\$info)
For \$x = 1 To \$something[0]
If \$something[\$x] = \$info Then Return \$return[\$x] ; return what ever you want
Next
EndFunc   ;==>_something```

8)

##### Share on other sites

```\$something = StringSplit("This,That,The other,This way,That way,The other way", ",")
\$return = StringSplit("Not,Nat,Nope,Dope,Pope,Rope", ",")

; match found
MsgBox(0x0, "answer", "Something = " & _something("That way"))

; no match
MsgBox(0x0, "answer", "Something = " & _something("Thats way"))

Func _something(\$info)
For \$x = 1 To \$something[0]
If \$something[\$x] = \$info Then Return \$return[\$x] ; return what ever you want
Next
EndFunc   ;==>_something```

8)

Man that's a great one. The Return will be written as a DO but it's a nice, very nice thank you. You had a Filesearch on here.. also a very nice example. We can all learn a lot from you.

Edited by glasglow

8)

##### Share on other sites

8)

Haha you returned before I finished editing..dictionary became filesearch.. I mixed up the gui's.. filesearch pop's out a "valuater"...thanks again.

## Create an account

Register a new account