BinaryBrother Posted August 1, 2025 Posted August 1, 2025 (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 August 1, 2025 by BinaryBrother SIGNATURE_0X800007D NOT FOUND
Solution ioa747 Posted August 1, 2025 Solution Posted August 1, 2025 [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 August 1, 2025 Author Posted August 1, 2025 Seems like that would trigger a syntax error. Thanks for the clarification. SIGNATURE_0X800007D NOT FOUND
orbs Posted August 1, 2025 Posted August 1, 2025 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 WinPose - simultaneous fluent move and resize 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 Magic Math - a math puzzle Demos: Title Bar Menu - click the window title to pop-up a menu
BinaryBrother Posted August 1, 2025 Author Posted August 1, 2025 (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 August 1, 2025 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