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

Welcome Forums General PowerShell Q&A Question regarding $result = $host.ui.PromptForChoice()

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 year, 4 months ago.

  • Author
    Posts
  • #74368

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    I think based on this link promptforchoice

    Results are system.init32. Just need to confirm

  • #74408

    Participant
    Points: 0
    Rank: Member

    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)
    

The topic ‘Question regarding $result = $host.ui.PromptForChoice()’ is closed to new replies.