Sign in to follow this  
Followers 0
glasglow

If Then Endif Infinity

8 posts in this topic

#1 ·  Posted (edited)

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 this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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 this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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 this post


Link to post
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
    Return "nada" 
EndFunc   ;==>_something

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

$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
    Return "nada" 
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

Share this post


Link to post
Share on other sites

Thanks, and your welcome!!!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thanks, and your welcome!!!

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0