BinaryBrother Posted 10 hours ago Posted 10 hours ago (edited) $Var = 4 Switch $Var Case 1 ConsoleWrite("1") Case 2 Or 3 ConsoleWrite("2 or 3") Case 4, 5 ConsoleWrite("4 or 5") Case Else ConsoleWrite("Else") EndSwitch Console Output: "2 or 3" I'm missing something here... No matter what $Var is, console writes "2 or 3". Except for $Var = 1, which works as expected. Edit: Is the case matching because 3 is 3? Edited 10 hours ago by BinaryBrother SIGNATURE_0X800007D NOT FOUND
ioa747 Posted 10 hours ago Posted 10 hours ago [Case <value> [To <value>] [,<value> [To <value>] ...] It doesn't say anything about 'οr' $Var = 4 Switch $Var Case 1 ConsoleWrite("1") Case 2 To 3 ConsoleWrite("2 or 3") Case 4, 5 ConsoleWrite("4 or 5") Case Else ConsoleWrite("Else") EndSwitch I know that I know nothing
BinaryBrother Posted 10 hours ago Author Posted 10 hours ago Seems like that would trigger a syntax error. Thanks for the clarification. SIGNATURE_0X800007D NOT FOUND
orbs Posted 10 hours ago Posted 10 hours ago the number 0 equals the boolean False any other number equals the boolean True so: 2 = True 3 = True (2 Or 3) = (True or True) = True so the condition is always met. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
BinaryBrother Posted 10 hours ago Author Posted 10 hours ago (edited) I figured it was something like that. You'd think after all the years on this forum I would have ran into this before. X) Edit: I'm getting older. I've probably forgotten more than I've learned. Thanks for the speedy responses! ^.^ Edited 10 hours ago by BinaryBrother SIGNATURE_0X800007D NOT FOUND
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now