Author Topic: acedGetKWord examples  (Read 4090 times)

0 Members and 1 Guest are viewing this topic.

MickD

  • Gator
  • Posts: 3310
  • (x-in)->[process]->(y-out)
acedGetKWord examples
« on: January 29, 2008, 04:39:25 PM »
Does anyone have any get keyword examples, there's some tricky mojo going on in there I haven't grasped yet and I can't find very much in the doc's.

The code below (which is what's left after a fried brain cell or 2) is what I'm trying to do but the keywords are not getting picked up. I've tried moving the brackets & <>'s to all kinds of places, there's atrick to this I'm sure so any help would be great.
thanks.

Code: [Select]
void Settings()
{
// Allows the user to change the global variables for the drilling
// and polycut routines, offsets to be added later.
// Steps:
// ----- 1. Create the prompts and keywords for the settings:
int stat;
ads_real x = gDrillDia;
ACHAR kw[20];

// Null input is not allowed.
acedInitGet(RSG_NONULL, _T("Drill-Diameter Hole-depth Polycut-length"));
if ((stat = acedGetReal(_T("\n Enter new Drill-diameter[Hole-depth/Polycut-length]: "),&x) == RTNORM))
{
if (stat == RTKWORD && acedGetInput(kw) == RTNORM)
{
if (_tcscmp(kw, _T("Hole-depth")) == 0)
{
acutPrintf(_T("User entered H"));
stat = RTNORM;
}
else if (_tcscmp(kw, _T("Polycut-length")) == 0)
{
acutPrintf(_T("User entered P"));
stat = RTNORM;
}
}
}
if (stat != RTNORM)
{
acutPrintf(_T("DCS Error: in settings input.\n"));
}
else
{
gDrillDia = x;
}
return;
}

What I'd really like is to be able to just change the drill diameter as default so top avoid another 'enter' but have the other two settings as a choice which then need to be edited.
« Last Edit: January 29, 2008, 04:56:27 PM by MickD »
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

MickD

  • Gator
  • Posts: 3310
  • (x-in)->[process]->(y-out)
Re: acedGetKWord examples
« Reply #1 on: January 29, 2008, 05:28:21 PM »
Ok, got something working after taking a long fresh look at it (dang'd logic :roll:)

Code: [Select]
void Settings()
{
// Allows the user to change the global variables for the drilling
// and polycut routines, offsets to be added later.
// Steps:
// ----- 1. Create the prompts and keywords for the settings:
int stat;
ads_real x = gDrillDia;
ACHAR kw[20];

// Null input is not allowed.
acedInitGet(RSG_NONULL, _T("Drill-Diameter Hole-depth Polycut-length"));
[color=blue]stat = acedGetReal(_T("\n Enter new Drill-diameter[Hole-depth/Polycut-length]: "),&x);
if (stat == RTKWORD)
{
acedGetInput(kw);[/color]
if (_tcscmp(kw, _T("Hole-depth")) == 0)
{
acutPrintf(_T("User entered H"));
stat = RTNORM;
}
else if (_tcscmp(kw, _T("Polycut-length")) == 0)
{
acutPrintf(_T("User entered P"));
stat = RTNORM;
}
}
if (stat != RTNORM)
{
acutPrintf(_T("DCS Error: in settings input.\n"));
}
else
{
gDrillDia = x;
}
return;
}
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: acedGetKWord examples
« Reply #2 on: January 29, 2008, 05:57:51 PM »
(dang'd logic :roll:)

And here I was thinking you were occa...shame on you Mr. Mick...shame, shame shame! :)
Me

MickD

  • Gator
  • Posts: 3310
  • (x-in)->[process]->(y-out)
Re: acedGetKWord examples
« Reply #3 on: January 29, 2008, 06:13:01 PM »
(dang'd logic :roll:)

And here I was thinking you were occa...shame on you Mr. Mick...shame, shame shame! :)

hehe, I couldn't say what I really wanted too :D
(p.s. Thanks Derryn ;))

Here's a much better solution - and it works :)

Code: [Select]
void Settings()
{
// Allows the user to change the global variables for the drilling
// and polycut routines, offsets to be added later.
// Steps:
// ----- 1. Create the prompts and keywords for the settings:
int stat;
ads_real x;
ACHAR kw[20];
ACHAR prompt[256];

// Null input is not allowed.
swprintf(prompt,_T("\n Enter new Drill-diameter[Hole-depth/Polycut-length]<current=%.2f>: "),gDrillDia);
acedInitGet(RSG_NONULL | RSG_NOZERO, _T("Drill-Diameter Hole-depth Polycut-length"));
stat = acedGetReal(prompt,&x);
switch(stat)
{
case RTKWORD:
acedGetInput(kw);
if (_tcscmp(kw, _T("Hole-depth")) == 0)

swprintf(prompt,_T("\n Enter new hole depth<current=%.2f>: "),gDrillDepth);
acedInitGet(RSG_NONULL | RSG_NOZERO, _T(""));
stat = acedGetReal(prompt, &x);
if(stat == RTNORM) gDrillDepth = x;
}
else if (_tcscmp(kw, _T("Polycut-length")) == 0)
{
swprintf(prompt,_T("\n Enter new polycut length<current=%.2f>: "),gPolyCutDepth);
acedInitGet(RSG_NONULL | RSG_NOZERO, _T(""));
stat = acedGetReal(prompt, &x);
if(stat == RTNORM) gPolyCutDepth = x;
}
break;
case RTCAN: //user pressed cancel.
return;
break;
case RTNORM: // input ok from first prompt.
gDrillDia = x;
break;
default: // something went wrong!
acutPrintf(_T("DCS Error: in settings input.\n"));
}
return;
}

<edit> added float formatting
« Last Edit: January 29, 2008, 06:18:40 PM by MickD »
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6942
  • AKA Daniel
Re: acedGetKWord examples
« Reply #4 on: January 29, 2008, 11:39:06 PM »
Whew! Welcome back to the land of curly braces, I thought we had lost you  :lol:

MickD

  • Gator
  • Posts: 3310
  • (x-in)->[process]->(y-out)
Re: acedGetKWord examples
« Reply #5 on: January 29, 2008, 11:55:21 PM »
Whew! Welcome back to the land of curly braces, I thought we had lost you  :lol:

Naahhh, just needed a break and nut out some things in a more user friendly environment. The downside though was that there's a LOT of functionality I need not (easily) available in vba so it's back to old faithful :)

I've actually punched out a couple of thousand lines of C/C++ over the last week or so and I'm starting to get back into the swing of it, it's re-learning the api that's the slowest part now but it's coming back pretty fast ;)
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6942
  • AKA Daniel
Re: acedGetKWord examples
« Reply #6 on: January 29, 2008, 11:59:00 PM »
Cool ARXDBG has a pretty good sample class on handling prompts,
also It might be cool to make a class that acts similar to .NET’s PromptOption classes