Jump to content

Case and ContinueCase confusion


Recommended Posts

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

Link to post
Share on other sites

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
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.

Link to post
Share on other sites

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
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 2021-11-10 - Version 1.6.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...