TheSwamp

Code Red => .NET => Topic started by: CrockettScience on April 29, 2019, 05:56:31 PM

Title: Editor.Command() and CommandAsync(): Help with input tokens
Post by: CrockettScience on April 29, 2019, 05:56:31 PM
When you call an editor command in .NET, you provide input tokens that either provide input to the prompts or defer to the user for input in the order they're asked for.

But this should drastically limit control structure. Say, for example, the command called is a conditional with several prompts based on the condition:

Code: [Select]
if(A){
     //Code with 3 prompts
}
else{
     //Code with 5 prompts
}

In my testing, code such as above will fail in some instances based on the amount of input tokens:

If A is true, but Command() is Executed with 5 prompts, the command seems like it ends, but if you CANCEL by pressing escape, control will return and throw an eUserBreak, which is expected.

if A is false, but Command() is Executed with 3 prompts, the whole application hangs on the 4th prompt call.

This seems intuitive, but inconvenient. Is there a way to better control these tokens?

Title: Re: Editor.Command() and CommandAsync(): Help with input tokens
Post by: Bryco on April 29, 2019, 08:20:44 PM
I rarely use Command, but you can use the editor to get all your prompts as strings  then feed that into the command.