Question regarding $result = $host.ui.PromptForChoice()

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Jonathan Warnken Jonathan Warnken 3 weeks ago.

  • Author
    Posts
  • #74368
    Profile photo of Goldy
    Goldy
    Participant

    Does my result switch statement have to be an indexed number or can it be words. The reason i'm asking is because if I have to make a change to the menu and insert a new option, I have to re-index the menu and its prone to error.

    Any guidance would be great.

  • #74372
    Profile photo of Goldy
    Goldy
    Participant

    I think based on this link promptforchoice

    Results are system.init32. Just need to confirm

  • #74408
    Profile photo of Jonathan Warnken
    Jonathan Warnken
    Participant

    You are correct

    $host.ui|get-member|Format-List

    has this for the PromptForChoice method. All of the definitions are outputting as [int]

    TypeName   : System.Management.Automation.Internal.Host.InternalHostUserInterface
    Name       : PromptForChoice
    MemberType : Method
    Definition : int PromptForChoice(string caption, string message,
                 System.Collections.ObjectModel.Collection[System.Management.Automation.Host.ChoiceDescription] choices,
                 int defaultChoice), System.Collections.ObjectModel.Collection[int] PromptForChoice(string caption, string
                 message, System.Collections.ObjectModel.Collection[System.Management.Automation.Host.ChoiceDescription]
                 choices, System.Collections.Generic.IEnumerable[int] defaultChoices),
                 System.Collections.ObjectModel.Collection[int]
                 IHostUISupportsMultipleChoiceSelection.PromptForChoice(string caption, string message,
                 System.Collections.ObjectModel.Collection[System.Management.Automation.Host.ChoiceDescription] choices,
                 System.Collections.Generic.IEnumerable[int] defaultChoices)
    

You must be logged in to reply to this topic.