Author Topic: Editor.Command() and CommandAsync(): Help with input tokens  (Read 216 times)

0 Members and 1 Guest are viewing this topic.

CrockettScience

  • Mosquito
  • Posts: 12
Editor.Command() and CommandAsync(): Help with input tokens
« 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?

« Last Edit: April 29, 2019, 06:27:19 PM by CrockettScience »

Bryco

  • Water Moccasin
  • Posts: 1848
Re: Editor.Command() and CommandAsync(): Help with input tokens
« Reply #1 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.