OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: cbaCAD on June 02, 2015, 11:13:49 PM

Title: Is it psossible to break previous command in a "dcl_sendstring"
Post by: cbaCAD on June 02, 2015, 11:13:49 PM
Is it psossible to break previous command in a "dcl_sendstring", like ^C^C in mnu-method?
Title: Re: Is it psossible to break previous command in a "dcl_sendstring"
Post by: roy_043 on June 03, 2015, 02:01:50 AM
Code (autolisp) Select
(progn (dcl_sendstring (strcat (chr 27) (chr 27))) (princ))
Title: Re: Is it psossible to break previous command in a "dcl_sendstring"
Post by: Fred Tomke on June 04, 2015, 08:39:34 AM
Hm, not bad, roy! Didn't know that yet. Thanks!
Regards, Fred
Title: Re: Is it psossible to break previous command in a "dcl_sendstring"
Post by: cbaCAD on June 11, 2015, 01:21:00 AM
Thanks a lot, roy.
It works very well.
for example my code to use old mnu-commands:

(defun SUB:cba_sendstring (cmdstr)
  (cond   ((vl-string-search "^C^C^P" cmdstr)
    (dcl_sendstring (strcat (chr 27) (chr 27)))
    (setq cmdstr (vl-string-subst " " ";" cmdstr))
    (dcl_sendstring (substr cmdstr 7))
   )
   ((vl-string-search "^C^C" cmdstr)
    (dcl_sendstring (strcat (chr 27) (chr 27)))
    (setq cmdstr (vl-string-subst " " ";" cmdstr))
    (dcl_sendstring (substr cmdstr 5))
   )
   (T (dcl_sendstring cmdstr))
  )
;;; Ende SUB:cba_sendstring
)
Title: Re: Is it psossible to break previous command in a "dcl_sendstring"
Post by: cbaCAD on June 11, 2015, 01:25:23 AM
It is a part of my Tablett-Emulator "cbaCAD TabEmu" powered by OpenDCL.
!!! I love OpenDCL !!!
Title: Re: Is it psossible to break previous command in a "dcl_sendstring"
Post by: roy_043 on June 11, 2015, 01:57:29 AM
@ cbaCAD:
I do not know the source of the cmdstr arguments. If you read them from a CUI you should be aware that not all macros end with a semicolon.
Example:
^c^c_line
Just using
Code (autolisp) Select
(dcl_sendstring "_line")
will not start the command. You will need to append a space (or any other white space character).

Some other considerations:
1.
(vl-string-search) is case-sensitive.
2.
Some macros begin with:
*^c^c
3.
Macros may look like this:
^c^c_line;\\^c_circle
4.
You should trim away trailing ^p and ^P portions.
5.
Use
Code (autolisp) Select
(progn (dcl_sendstring ...) (princ))
to suppress the T return value.