kunkel321 Posted March 26, 2009 Report Share Posted March 26, 2009 I'm guessing that MacExp doesn't care whether I use ======================== IF variable %123% = foo Do this END IF IF variable %123% = bar Do this END IF IF variable %123% = zip Do this END IF IF variable %123% = bam Do this END IF ======================== or if I use ======================== SWITCH CASE variable %123% = foo Do this END CASE CASE variable %123% = bar Do this END CASE CASE variable %123% = zip Do this END CASE CASE variable %123% = bam Do this END CASE END SWITCH ======================== I haven't actually used the 'Switch' one so I'm not sure if this syntax is correct, but I think it is... I've looked in Visual Basic books and in VB it looks like the Select Case option is actually more compact than having multiple ifs (i.e. you do the same thing but with fewer lines of code). With MacExp though, it seems that the Case method actually uses *more* lines of code that just using If/End If over and over.... Are there other benefits to using "Case" that I'm missing??? Thanks. -steve Quote Link to comment Share on other sites More sharing options...
Cory Posted March 26, 2009 Report Share Posted March 26, 2009 You might want to search the forum before posting as I just started a similar post a few days back. The upshot was that there is no difference in functionality but Switch can make your macro easier to read in most cases. Quote Link to comment Share on other sites More sharing options...
terrypin Posted March 26, 2009 Report Share Posted March 26, 2009 I haven't actually used the 'Switch' one so I'm not sure if this syntax is correct, but I think it is... Nearly. The variable goes in the SWITCH and then doesn't need to appear again. Like this: SWITCH variable %123% CASE = foo Do this END CASE CASE = bar Do this END CASE CASE = zip Do this END CASE CASE = bam Do this END CASE END SWITCH And if you wanted to OR these, it can be done neatly like this: SWITCH variable %123% CASE = foo CASE = bar CASE = zip CASE = bam Do this END CASE END SWITCH I've looked in Visual Basic books and in VB it looks like the Select Case option is actually more compact than having multiple ifs (i.e. you do the same thing but with fewer lines of code). With MacExp though, it seems that the Case method actually uses *more* lines of code that just using If/End If over and over.... Are there other benefits to using "Case" that I'm missing??? Thanks. -steve I used SWITCH/CASE for the first time yesterday and despite its initial unfamiliarity I reckon it's easier to write & understand later, and probably on average more compact than IF/END IF. -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.