Sign in to follow this  
Followers 0
netegg

Case and ContinueCase confusion

6 posts in this topic

#1 ·  Posted (edited)

Today, I encountered a strange problem when i use the select. . .case statement. I really do not understand where there is an error.The following code is simplified, just to describe what the problem is.

Select
Case ProcessExists('explorer.exe')
  MsgBox(64, 0, 1)
  ContinueCase
Case ProcessExists('sys.su') ;this is not a real process. but....
  MsgBox(64, 0, 2)
  ContinueCase
Case ProcessExists('winlogon.exe')
  MsgBox(64, 0, 3)
EndSelect

That's why?Does the ContinueCase cause?Or the condition of 'case 0' is True? But the below is different.

Select
Case ProcessExists('sys.su') ;this is not a real process. and the msgbox will not show
  MsgBox(64, 0, 2)
  ContinueCase
Case ProcessExists('explorer.exe')
  MsgBox(64, 0, 1)
  ContinueCase
Case ProcessExists('winlogon.exe')
  MsgBox(64, 0, 3)
EndSelect
Edited by netegg

Share this post


Link to post
Share on other sites



Try removing ContinueCase from your script and check if it works


----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try removing ContinueCase from your script and check if it works

Removing 'continuecase' is not the same as the first code. And, Yes, I know that it can use 'if..then' to do this. I was just puzzled if the sequence causes the difference, and why. Edited by netegg

Share this post


Link to post
Share on other sites

From the helpfile:

Executing the ContinueCase will tell AutoIt to stop executing the current case and start executing the next case.

ContinueCase executes the next case, it does not continue the switch/select or run any conditionals. If you want all cases to run use three separate If's or something to that effect.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

From the helpfile:

ContinueCase executes the next case, it does not continue the switch/select or run any conditionals. If you want all cases to run use three separate If's or something to that effect.

Thanks, I get it! Edited by netegg

Share this post


Link to post
Share on other sites

There has been a discussion lately in a separate thread (can't find it at the moment) where you'll find an explanation how and why it works the way it does.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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