Author Topic: Fun : going Home ?  (Read 17975 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Fun : going Home ?
« on: December 14, 2005, 10:54:40 PM »
Just playing around ...

Code: [Select]
#region System using declarations
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;

using System.Text;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using System.ComponentModel;
using Microsoft.VisualBasic;
using System.Text.RegularExpressions;
#endregion

#region AutoCAD COM Interop using declarations
//// COM Interop References
//// AutoCAD 2006 Type Library
using Autodesk.AutoCAD.Interop;

//// AXDBLib AutoCAD/ObjectDBX Common 16.0 Type Library
using Autodesk.AutoCAD.Interop.Common;

#endregion

#region AutoCAD Managed Wrappers using declarations
//// Assembly acdbmgd .. ObjectDBX.NET Managed Wrapper
//// Assembly acmgd .. Autocad.NET Managed Wrapper
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Colors;
#endregion

#region Alias using declarations
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
#endregion

// codehimbelonga kwb : posted@TheSwamp 20051215

[assembly: ExtensionApplication(typeof(ClassLibrary20051215.StartApp))]
[assembly: CommandClass(typeof(ClassLibrary20051215.Commands))]

namespace ClassLibrary20051215
{
    #region CommandClass
    //-------------------------------------------------------------------------------
    public class
    Commands
    {
        [CommandMethod("myHelp", CommandFlags.Modal)]
        static public void
        TEMPLATEHelp()
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            ed.WriteMessage("\n  Testing Assembly [kwb v:20051215]");
            ed.WriteMessage("\n  Commands : GoHome");
        }
        //----------------------------

        [CommandMethod("GoHome", CommandFlags.Modal)]
        public static void Command_GoHome()
        {
            Class1 tester = new Class1();
            tester.Method001();
        }
        //----------------------------
    }
    #endregion


    #region MainApp core
    //-------------------------------------------------------------------------------
    public class Class1
    {
        public void Method001()
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
            DateTime dt = DateTime.Now;

            bool yesnoResult;

            PromptStatus promptStatus = LibTools.TellmeYesNo(string.Format(
                "\nIt's only {0}, are you sure you want to quit ?", dt.ToString("HH:mm")),
                false, out yesnoResult);
            if ((promptStatus != PromptStatus.OK) || (yesnoResult == false))
                MessageBox.Show("\n.. Well get back to work, slacker .. !", "I'm the boss of you, OK !");
            else
                MessageBox.Show("\ngoodbye, slacker .. ");
        }
    }
    #endregion


    #region LibraryTools
    //-------------------------------------------------------------------------------
    public class LibTools
    {
        public static PromptStatus
        TellmeYesNo(string message, bool useYesDefault, out bool yesnoResult)
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            yesnoResult = false;

            string defaultAnswer = (useYesDefault) ? "Yes" : "No";
            PromptKeywordOptions keywordOptions = new PromptKeywordOptions(message);
            keywordOptions.Keywords.Add("Yes");
            keywordOptions.Keywords.Add("No");
            keywordOptions.Keywords.Default = defaultAnswer;

            PromptResult keywordResult = ed.GetKeywords(keywordOptions);
            if (keywordResult.Status == PromptStatus.OK)
            {
                if (keywordResult.StringResult == "Yes")
                    yesnoResult = true;
            }
            return keywordResult.Status;
        }
    }
    #endregion


    #region Public class StartApp
    //-------------------------------------------------------------------------------
    /// <summary>
    /// The entry point for AutoCAD.
    /// </summary>
    public class
    StartApp : IExtensionApplication
    {
        public void
        Initialize()
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            Commands.TEMPLATEHelp();
            ed.WriteMessage("\n  Type 'myHelp' at the Command Line for assistance ...");
        }
        public void
        Terminate()
        {
            // Does Nothing ... can't unload NET assembly ...
        }
    }
    #endregion
}
« Last Edit: December 15, 2005, 12:33:29 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Fun : going Home ?
« Reply #1 on: December 15, 2005, 12:06:57 AM »
heh, shouldn't they both say "...get back to work slacker!" :D
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #2 on: December 15, 2005, 12:25:01 AM »
.. or :-

"Sure, you can go home. Grab a couple of beers from the frig' to take with you."

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #3 on: December 15, 2005, 01:17:39 AM »
We could add this in for you Mick .. !

Code: [Select]
        //--------------------------------------
        public void Method002()
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
           
            bool yesnoResult;
           
            PromptStatus promptStatus = TellmePerhaps("\n Like a cold beer Mick ?",
                out yesnoResult);
            if ((promptStatus == PromptStatus.OK) && (yesnoResult == true))
                MessageBox.Show("\n.. Help Yourself to a couple .. !", "It's beer o'clock !");
            else
                MessageBox.Show("\n too bad, so sad .. ");

        }
        //--------------------------------------
        public static PromptStatus
        TellmePerhaps(string message, out bool yesnoResult)
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
            yesnoResult = false;

            string[] options = { "Yes", "No", "Perhaps", "noSir" , "BloodyOathMate" };

            PromptResult keywordResult = ed.GetKeywords(message, options);
            if (keywordResult.Status == PromptStatus.OK)
            {
                if ((keywordResult.StringResult == "Yes")
                    || (keywordResult.StringResult == "BloodyOathMate"))
                    yesnoResult = true;
            }
            return keywordResult.Status;
        }

added: corrected the option of providing beverages if ESC was hit :-)
« Last Edit: December 15, 2005, 01:44:05 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Fun : going Home ?
« Reply #4 on: December 15, 2005, 01:45:08 AM »
heh, you have 4 too many key words now Kerry...... I s'pose you could set the 5th as the default  :laugh:
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #5 on: December 15, 2005, 01:50:57 AM »
They should all be default YES , heh.

It's Difficult using a keyword list like this though, there are no PromptKeywordOptions as far as I can tell ; so no default CAN be set.
 
Options are :
Quote
GetKeywords
Autodesk.AutoCAD.EditorInput.PromptResult

GetKeywords(
   System.String message,
   System.String[] globalKeywords)
or
Quote
GetKeywords
Autodesk.AutoCAD.EditorInput.PromptResult

GetKeywords(
   Autodesk.AutoCAD.EditorInput.PromptKeywordOptions options)

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Fun : going Home ?
« Reply #6 on: December 15, 2005, 01:59:25 AM »
I'm just about to venture into keywords so this topic will come in handy.

Have you tried to handle an 'esc' from the user yet (in mid command that is), I've noticed using Prompts and ed.get##### etc. that when you escape it goes on to the next prompt instead of exiting the function. I haven't had time to explore this as yet but it's worth discussion when using/getting user input.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #7 on: December 15, 2005, 02:07:03 AM »
I've done a little with that.

Have a look at Lab 02 Reworked  http://www.theswamp.org/forum/index.php?topic=7904.msg100396#msg100396

There's a couple of getxxx options there.

Code: [Select]
.....
case PromptStatus.Cancel:
...
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #8 on: December 15, 2005, 02:29:19 AM »
While discussing Keywords ...
If ANYONE knows of a way to add Keywords from a list,
rather than one at a time in the PromptKeywordOptions Class,
I'd be happy to hear about it  :lol:

I've tried a few variations, but gave up.


eg: There must me a better way than this  .. I'd enjoy being corrected.
Code: [Select]
            PromptKeywordOptions keywordOptions = new PromptKeywordOptions(message);
            keywordOptions.Keywords.Add("Yes");
            keywordOptions.Keywords.Add("No");
            keywordOptions.Keywords.Add("Perhaps");
            keywordOptions.Keywords.Add("Absolutely");
            keywordOptions.Keywords.Add("Never");
            keywordOptions.Keywords.Add("Sometimes");
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #9 on: December 15, 2005, 02:41:09 AM »
.. cont ..

Seems to not compile if the Options are :-
string[] options = { "Yes", "No", "Perhaps", "noSir" , "BloodyOathMate" };

and spit the dummy if a normal string ..  - --> System.ArgumentException: No bracketed keyword list

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #10 on: December 15, 2005, 02:47:09 AM »
I just had another try ...
The answer may be in the Exception Message.

I wonder what this PromptOptions.SetMessageAndKeywords(String messageAndKeywords, String globalKeywords) is ? ?
Time to look at the Object Browser .. < tomorrow>

Quote
************** Exception Text **************
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: No bracketed keyword list
   at Autodesk.AutoCAD.EditorInput.PromptParser.Parse(String promptAndKeywords, String globalKeywords)
   at Autodesk.AutoCAD.EditorInput.PromptOptions.SetMessageAndKeywords(String messageAndKeywords, String globalKeywords)
   at Autodesk.AutoCAD.EditorInput.PromptKeywordOptions..ctor(String messageAndKeywords, String globalKeywords)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Fun : going Home ?
« Reply #11 on: December 15, 2005, 03:20:27 AM »
How about a 'for' loop

Just a sketch

for(int i = 0; i <= options.Length; i++)
{
      KeywordOptions.Keywords.Add(keywords;
}
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #12 on: December 15, 2005, 03:27:16 AM »
I'm sure something like that would work Mick.

I'd just particularly like to know why the overloaded PromptKeywordOptions constructor is failing.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Fun : going Home ?
« Reply #13 on: December 15, 2005, 04:36:40 AM »
I've never tried but if it expected an array wouldn't the constructor be -

(string messageAndKeywords, string [] globalKeywords)

??
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #14 on: December 15, 2005, 04:43:19 AM »
yes. !

It's declared as a string.
The error message mentions a 'bracketed keyword list'.

I'm guessing that it expects a 'special' formatting.

Thats the problem .. I'm guessing. !
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Draftek

  • Guest
Re: Fun : going Home ?
« Reply #15 on: December 15, 2005, 07:46:57 AM »
cool, thanks.

I will be using this in the future too.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Fun : going Home ?
« Reply #16 on: December 15, 2005, 04:31:15 PM »
yes. !

It's declared as a string.
The error message mentions a 'bracketed keyword list'.

I'm guessing that it expects a 'special' formatting.

Thats the problem .. I'm guessing. !

Maybe the exception message is trying to say "Doesn't take bracketed keyword list" ??

From a logical point of view it couldn't take anything but a single string, how would it know where one keyword starts and the next and so on??
Also, from a design point of view it would be much clearer to the user and easier to declare it as taking a string[].
 I don't know ???
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #17 on: December 15, 2005, 05:16:04 PM »
I tried with a string. may have to be formatted or delimited in some way so that the parser can determine the keywords, though a space is a delimiter, yes.

I have passed the question on, so ....
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: Fun : going Home ?
« Reply #18 on: December 15, 2005, 07:28:10 PM »
Code: [Select]
[CommandMethod("Prompts")]
static public void test()
{
// Get a pointer to the editor...
Editor pEd = pAcadApp.DocumentManager.MdiActiveDocument.Editor;

// Set the prompt and keywords...
PromptKeywordOptions promptKwOpts = new PromptKeywordOptions("\nIs this what you want Kerry [Yes/No]", "Yes No");
// Set the default so the user can just hit 'ENTER'...
promptKwOpts.Keywords.Default = "Yes";

PromptResult promptRes = pEd.GetKeywords(promptKwOpts);

if (promptRes.Status == PromptStatus.Cancel)
return;

pEd.WriteMessage("\nPrompt result: {0}", promptRes.ToString());

// It's OK, but which keyword did they use?
if (promptRes.Status == PromptStatus.OK)
{
switch(promptRes.StringResult)
{
case "Yes" :
pEd.WriteMessage("\nYou entered 'Yes', so I take it it is!");
break;
case "No" :
pEd.WriteMessage("\nYou entered 'No', so it isn't!");
break;
}
}

}

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #19 on: December 15, 2005, 07:58:38 PM »
This is embarrassing !

May have been the bourbon ...

 :oops:
I thought I tried exactly that ..
 :oops:

I'll have another look tonight, thanks Glenn

If that works, it may be fairly simple to pass a keyword string to a generic helper and build the prompt with the bracketed options.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #20 on: December 15, 2005, 08:12:39 PM »
Thanks Sir  !!

Quote
Command: forMe
Is this what you want Kerry [Yes/No] <Yes>: yo
Invalid option keyword.
Is this what you want Kerry [Yes/No] <Yes>: y
Prompt result: (OK,Yes)
You entered 'Yes', so I take it it is!
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: Fun : going Home ?
« Reply #21 on: December 15, 2005, 08:17:40 PM »
Hehe...:-D... you're welcome.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #22 on: December 15, 2005, 08:26:22 PM »
Here's something comforting :
Note the additional   keywordOptions.Keywords.Add("Perhaps");

The Keyword is added automagically to the prompt as well .. How cool is that !

Code: [Select]
        public void Method003()
        {
            // Get a pointer to the editor...
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            // Set the prompt and keywords...
            PromptKeywordOptions keywordOptions = new PromptKeywordOptions(
                                          "\nIs this what you want Kerry [Yes/No]", "Yes No");
            // Set the default so the user can just hit 'ENTER'...

            keywordOptions.Keywords.Add("Perhaps");
            keywordOptions.Keywords.Default = "Yes";

            PromptResult promptRes = ed.GetKeywords(keywordOptions);

            if (promptRes.Status == PromptStatus.Cancel)
                return;

            ed.WriteMessage("\nPrompt result: {0}", promptRes.ToString());

            // It's OK, but which keyword did they use?
            if (promptRes.Status == PromptStatus.OK)
            {
                switch (promptRes.StringResult)
                {
                    case "Yes":
                        ed.WriteMessage("\nYou entered 'Yes', so I take it it is!");
                        break;
                    case "No":
                        ed.WriteMessage("\nYou entered 'No', so it isn't!");
                        break;
                }
            }

        }
« Last Edit: December 15, 2005, 08:31:35 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Fun : going Home ?
« Reply #23 on: December 15, 2005, 08:30:00 PM »
Very cool.

Thanks again Glenn, it even looks easy now :)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Glenn R

  • Guest
Re: Fun : going Home ?
« Reply #24 on: December 15, 2005, 09:17:50 PM »
No worries lads.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #25 on: December 15, 2005, 11:05:49 PM »
A bit more investigation, so the future calls wont be Monkey see, Monkey do ..

The constructors for the Autodesk.AutoCAD.EditorInput.PromptKeywordOptions class are :
Quote
PromptKeywordOptions(
    System.String message)

// and

PromptKeywordOptions(
    System.String messageAndKeywords,
    System.String globalKeywords)

The error exception message   ---> System.ArgumentException: No bracketed keyword list
referred to the format of the messageAndKeywords string, not the globalKeywords string as I assumed < yep, THAT word again >

SO :

This works
Code: [Select]
keywordOptions = new PromptKeywordOptions("\n Choose dude [Yes/No]", "Yes No");
This spits the dummy at run time
Code: [Select]
keywordOptions = new PromptKeywordOptions("\n Choose dude", "Yes No");
Hope that assists anyone following the breadcrumbs. :-)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #26 on: December 16, 2005, 06:06:51 AM »
I'm just about to venture into keywords so this topic will come in handy.

Have you tried to handle an 'esc' from the user yet (in mid command that is), I've noticed using Prompts and ed.get##### etc. that when you escape it goes on to the next prompt instead of exiting the function. I haven't had time to explore this as yet but it's worth discussion when using/getting user input.

Something like this to assert a valid Result prior to testing the value of the Result seems to work as a generic procedure ..
Code: [Select]
            //-----------------------------------------------------------------
            PromptKeywordOptions keywordOptions = new PromptKeywordOptions("messageAndKeywords", "globalKeywords");
            PromptResult promptResult = ed.GetKeywords(keywordOptions);
            switch (promptResult.Status)
            {
                case PromptStatus.Cancel:
                    ed.WriteMessage("\nUser cancelled.");
                    return;
                    break;
                case PromptStatus.Error:
                    ed.WriteMessage("\nUser input error.");
                    return;
                    break;
                case PromptStatus.OK:
                    break;
            }
            //-----------------------------------------------------------------
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fun : going Home ?
« Reply #27 on: December 16, 2005, 08:19:50 AM »
Just 'cause I needed to know, I ran a reflector over the PromptKeywordOptions constructor in the Autodesk.AutoCAD.EditorInput namespace of ACMGD.DLL.

.. in case anyone is interested, the Parse method was throwing the exception
'cause it failed this :
Quote
int num3 = promptAndKeywords.LastIndexOf("[");
 int num5 = promptAndKeywords.LastIndexOf("]");
 if ((num3 < 0) || (num5 <= (num3 + 1)))
{ Spit the DUMMY HERE

With the current absence of explicit documentation, deciphering the conditionals is the only way I can see to ensure the formatting is correct.

Code: [Select]
protected internal PromptOptions(string messageAndKeywords, string globalKeywords)
{
      this.CommonInit(null);
      this.SetMessageAndKeywords(messageAndKeywords, globalKeywords);
}
Code: [Select]
public void SetMessageAndKeywords(string messageAndKeywords, string globalKeywords)
{
      this.throwIfReadOnly();
      PromptParser parser1 = new PromptParser();
      parser1.Parse(messageAndKeywords, globalKeywords);
      this.m_message = parser1.Prompt;
      this.m_keywords = parser1.Keywords;
}
Code: [Select]
internal unsafe void Parse(string promptAndKeywords, string globalKeywords)
{
      int num3 = promptAndKeywords.LastIndexOf("[");
      int num5 = promptAndKeywords.LastIndexOf("]");
      if ((num3 < 0) || (num5 <= (num3 + 1)))
      {
            throw new ArgumentException(new string((sbyte*) &??_C@_0BK@PDCKAIIB@No?5bracketed?5keyword?5list?$AA@));
      }
      if (num3 > 0)
      {
            this.m_prompt = promptAndKeywords.Substring(0, num3).TrimEnd(null);
      }
      else
      {
            this.m_prompt = "";
      }
      int num6 = promptAndKeywords.Length - num5;
      if ((num6 > 0) && (promptAndKeywords.Substring(num5 + 1, num6 - 1).TrimEnd(null).Length > 0))
      {
            throw new ArgumentException("Invalid text trailing the bracketed keywords");
      }
      string[] textArray1 = promptAndKeywords.Substring(num3 + 1, (num5 - num3) - 1).Split("/".ToCharArray());
      string[] textArray3 = new string[textArray1.Length];
      int num2 = textArray1.Length;
      if (num2 <= 0)
      {
            throw new ArgumentException("Bracketed keyword list is empty");
      }
      int num4 = 0;
      if (0 < num2)
      {
            do
            {
                  textArray3[num4] = PromptParser.ParseLocalKeyword(textArray1[num4]);
                  num4++;
            }
            while (num4 < num2);
      }
      string[] textArray2 = PromptParser.SplitByWhitespace(globalKeywords);
      if (num2 != textArray2.Length)
      {
            throw new ArgumentException("Mismatched number of global and local keywords");
      }
      this.m_keywords = new KeywordCollection();
      int num1 = 0;
      if (0 < num2)
      {
            do
            {
                  this.m_keywords.Add(textArray2[num1], textArray3[num1], textArray1[num1]);
                  num1++;
            }
            while (num1 < num2);
      }
}
« Last Edit: December 16, 2005, 08:32:13 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.