Jump to content

Recommended Posts

Posted (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 by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Posted

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

 

Posted (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 by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

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