Author Topic: menu problems...commands repeating or unrecognised.  (Read 1834 times)

0 Members and 1 Guest are viewing this topic.

DAMNGOOD

  • Guest
menu problems...commands repeating or unrecognised.
« on: August 22, 2012, 02:12:04 AM »
Hi,

First time poster here.  Newbie to the world of Autolisp.  I've been doing some editing of existing code while my systems manager is on long service leave.
My problem is such.  When I run my new lisps from the menu the first 2 or 3 getstrings execute 3 times.  Or sometimes unknown command, unpredictable.
If I load the same lisp in the Visual Lisp editor and run it, it works fine.  The lisp(s) I have written worked fine the day prior.  I have tried old version with the same problem mostly.  I'm wondering if I'm getting conflict with 2 versions of ACAD (2000 & 2012).

Here is a snapshot of my menu command that is causing me greif   and also a copy of the lisp that repeats getstring without waiting user input.

The problem lisps are NBNA1LayoutsTEST

line that seems to repeat without waiting for user

  (setq forf "X")
  (while (= (member forf '("FSAM" "FDA")) nil)
    (setq forf (strcase (getstring "FSAM or FDA")))
    )
This is what appears on command line.

Press ENTER to continue: FSAM or FDA
FSAM or FDA FSAM or FDA
 




Menu

***MENUGROUP=NBNCoP

***POP1

**NBNCo
[NBNCo]
[DXF 2 DWG]^C^C(load "Condxf")^P cxx;script;purgeall
[--]
[DXF 2 Rod N Rope]^C^C(load "TXT2")^P txt2;script;purgeall
[DXF 2 FIR]^C^C(load "TXT2")^P txt2;script;purgeall
[DXF 2 Missing]^C^C(load "Miss")^P miss;script;purgeall
[--]
[Frames]^C^C(load "VPLGrid")^P VPLGrid
[Frame Number Update]^C^C(load "Frame number UPdate")^P fup
[Layouts]^C^C(load "Layouts")^P layouts;script;purgeall
[--]
[Titleblock Update]^C^C(load "TITleblockS_UPdate_ALL")^P titsup
[--]
[Purgeall]^C^Cscript;purgeall
[--]
[Coord 2 Clipboard]^C^C(load "cliptxt")^P cliptxt
[--]
[DXF 2 Rod N Rope VPL ID]^C^C(load "TXT2vplid")^P txt2;script;purgeall
[--]
[New Dev Layouts]^C^C(load "NewDevLayouts")^P NewDevlayouts;script;purgeall
[--]
[NBNA1Frames]^C^C(load "NBNGrid")^P NBNGrid
[NBNA1Frame Number Update]^C^C(load "NBNA1Frame number UPdate")^P NBNA1fup
[NBNA1Layouts]^C^C(load "NBNLayouts")^P NBNlayouts;script;purgeall
[--]
[--]
[--]
[NBNA1LayoutsTEST DO NOT USE]^C^C(load "NBNLayoutsTEST")^P NBNlayoutsTEST;script;purgeall
[--]


cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: menu problems...commands repeating or unrecognised.
« Reply #1 on: August 22, 2012, 02:20:31 AM »
Have you test it to run your menu´functions in command line?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: menu problems...commands repeating or unrecognised.
« Reply #2 on: August 22, 2012, 06:33:29 AM »
Use an initget / getkword combination over the getstring, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. (initget 1 "FSAM FDA")
  2. (setq forf (getkword "\nFSAM or FDA?: "))

No need for a while loop.

DAMNGOOD

  • Guest
Re: menu problems...commands repeating or unrecognised.
« Reply #3 on: August 22, 2012, 06:50:37 PM »
Have you test it to run your menu´functions in command line?

Thanks, when I load them manually it works as it should. ie no skipping 2 x getstrings.
Also thanks Lee.   But I don't think thats the problem because when I comment out that code  it doesn't pause on the next 2 getstrings.
I proved this by adding an extra 2 dummy getstrings which were skipped??  This seems to be a menu issue.
eg.

Plan Type Preliminary/Engineering/Construction P/E/C:
State: Revision:

Code....

(setq plantype (strcase (getstring "Plan Type Preliminary/Engineering/Construction P/E/C:")))
  (cond
    ((= plantype "P") (setq plantype (strcat "PRELIMINARY PLAN - " (substr (getvar "dwgname") 1 4))))
    ((= plantype "E") (setq plantype (strcat "ENGINEERING PLAN - " (substr (getvar "dwgname") 1 4))))
    ((= plantype "C") (setq plantype (strcat "CONSTRUCTION PLAN - " (substr (getvar "dwgname") 1 4))))
    (T())
   );end cond
 (if (= t nil) (setq plantype ""))
(setq legendtitle (strcat plantype " - LEGEND")) 
(setq tbattlist (append (list (list "TITLE_4" plantype))tbattlist))
(setq tbattlist (append (list (list "STATE" (strcase (getstring "State:")))) tbattlist))
(setq tbattlist (append (list (list "REV" (strcase (getstring "Revision:")))) tbattlist))

DAMNGOOD

  • Guest
Re: menu problems...commands repeating or unrecognised.
« Reply #4 on: August 22, 2012, 07:09:58 PM »
Found it,  thanks guys.  Somehow the purgeall script was the culprit.  Don't know a lot about menus but I suspect its the 2 x ;;.
I removed this script call as I didn't require it.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: menu problems...commands repeating or unrecognised.
« Reply #5 on: August 23, 2012, 05:28:26 AM »
Also thanks Lee. But I don't think thats the problem because when I comment out that code it doesn't pause on the next 2 getstrings.

It may not be the problem, but its a better method for an option prompt in place of getstring  ;-)