About Dcl_SendString....

Started by XDCAD, July 15, 2012, 10:44:36 AM

Previous topic - Next topic

XDCAD

My English is very poor, Try to explain the problem

Code (autolisp) Select

(defun test2()
    (setq a "OpenDcl is too powerful!!")
)
(defun c:test1()
    (dcl_SendString "(test2)\n")
    (setq a "OpenDcl is powerful!!")
)


Why after the completion of the c:test1,

variable a is "OpenDcl is too powerful!!" and not "OpenDcl is powerful!!".

How to let the variables A =  "OpenDcl is powerful!!", According to order execution of c:test1.

Thanks..





owenwengerd

If you want the function to be executed synchronously, you can just evaluate it directly:
Code (autolisp) Select

(defun test2()
    (setq a "OpenDcl is too powerful!!")
)
(defun c:test1()
    (test2)
    (setq a "OpenDcl is powerful!!")
)

XDCAD

Quote from: owenwengerd on July 15, 2012, 10:56:41 AM
If you want the function to be executed synchronously, you can just evaluate it directly:
Code (autolisp) Select

(defun test2()
   (setq a "OpenDcl is too powerful!!")
)
(defun c:test1()
   (test2)
   (setq a "OpenDcl is powerful!!")
)


thanks,owen.

I know you Idea. But sometimes I must use DCL_SENDSTRING to Solve some things.
For example,When my Modal Form is running and I want to write AUTOCAD Objet Database, Throw an exception of AUTOCAD.

eg.  In Modal Form is Running
Code (autolisp) Select

(defun c:MyTree_OnEndLabelEdit(NewValue Key)
  ....
  (setq MyXRecordData '((12 34)(3 4)))
  (if (setq e (xdrx_object_get "layer" "0"))   ; Get Layer 0 Object and Set Extend Record.
     (xdrx_object_set_xrecord e MyXrecordData)   ;Throw an exception
  )
  ....
)


however.

Code (autolisp) Select

(defun WriteXrecord(val)
  (if (setq e (xdrx_object_get "layer" "0"))   ; Get Layer 0 Object and Set Extend Record.
     (xdrx_object_set_xrecord e val)   ;OK, not Throw an exception
  )
)
(defun c:MyTree_OnEndLabelEdit(NewValue Key)
  ....
  (setq MyXRecordData '((12 34)(3 4)))
  (dcl_SendString "(WriteXrecord  MyXRecordData)\n") ; Ok
  ....
)



My English is very poor, But I think you could understand I want to express meaning.and I Just use OPENDCL soon, Perhaps there is a better way? Please advice, thanks....




owenwengerd

You must choose either synchronous or asynchronous execution. In your case, both should work if you implement your functions correctly. If you can post a complete example of your failing code, perhaps someone can help you resolve the problem.