Jump to content

Two questions...


Recommended Posts

Just curious how many ElseIf statements can I have within an If statement? Also would like to know about some keystroke recorder macro software...ones that actually can recognize how long you have held down a certain key for and display the time in milliseconds...basically anything that I could use with AutoIt and if not, be able to convert so I can implement that into AutoIt. I looked at two creations of this subject on the forums, but neither could tell me how long I held down my keys for. Thanks a lot.

Link to comment
Share on other sites

Just curious how many ElseIf statements can I have within an If statement?

You can have as many as you would like. Sometimes it ends up being eaisier to read if you use Select-Case blocks instead. Here's an example of this alternative approach:

$input = Number(InputBox("User Input", "Please enter a number: "))
Select
  Case $input = 1
    MsgBox(0, "1", "You entered the number 1")
  Case $input = 0
    MsgBox(0, "0", "You entered the number 0, or a string which was interperted as 0")
  Case Else
    MsgBox(0, "Other", "You neither entered a 1 or a 0")
EndSelect

Sometimes this format is eaisier to read when you have a lot of different choices.

Minor edit

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

No clue there. You could try google for a search and see what comes up. I've never had the need for such an application.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

In some languages it has been true that multiple elseif statements are less efficient than case statements because following the case match the code branches to the end of the select statement while elseif statements continue to be evaluated. I do not know if this is true for AutoIt.

My $00.02

Link to comment
Share on other sites

In some languages it has been true that multiple elseif statements are less efficient than case statements because following the case match the code branches to the end of the select statement while elseif statements continue to be evaluated.  I do not know if this is true for AutoIt.

I'm not trying to claim it is faster or more efficient to use If ElseIf. However, I personally find Select Case blocks to be eaisier to read when there are a lot of choices. For one thing, all the Case commands end up on an identical indent level, and the If verses the ElseIf verses the Else end up on slightly different indent levels due to the length of the phrase. This makes quickly looking at the conditions slightly harder IMO.

Typo edited

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...