How to set Text for TextBox in Lisp?

Started by MiD-AwE, October 15, 2013, 02:01:51 PM

Previous topic - Next topic

MiD-AwE

Hi all,

I've been bummin' around here for a long time. I search for answers but I need very basic understanding now and cannot find how to do what I need. My ignorance is to blame.

I have a TextBox that I need to always display the value of a Global variable. When the user edits the text in the TextBox, I want to change the Global variable to the value set by the user and the TextBox needs to continue displaying the value from the Global.

I have tried to follow the tutorial but I do not know what I'm needing to do to set the Text in the TextBox OnInitialize.

I got the code from the "Control Browser" but it looks like jargon and I have not been able to interpret what I must customize to make it work.

(dcl_Control_SetProperty CNTRL-PNL_CPL-CAD_AccessTextBox PropertyApiName [as String] NewValue [as Varies])

The tutorial leads me to believe I need to change "PropertyApiName [as String]" but what must go there? And, What do I do with "NewValue [as Varies]".

My global is *ACCESS*.

Also, how do I trigger a regen on my drawing if/when the TextBox is edited.

Thank you for any suggestions/advice/help.

Peter2

Quote from: MiD-AwE on October 15, 2013, 02:01:51 PM
....(dcl_Control_SetProperty CNTRL-PNL_CPL-CAD_AccessTextBox PropertyApiName [as String] NewValue [as Varies])....
"dcl_Control_SetProperty ...... PropertyApiName" is the base command where you can set "all properties". In your case you should try the function for modifying the caption
Code (autolisp) Select

a) with text:
(dcl_Control_SetCaption CNTRL-PNL_CPL-CAD_AccessTextBox "hello, this is a test")
b) with variable:
(dcl_Control_SetCaption CNTRL-PNL_CPL-CAD_AccessTextBox myVariable)

Try it - no guarantee.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

MiD-AwE

Thank you Peter2.

So if I'm understanding this better, "PropertyApiName [as String]" is all one thing, not "PropertyApiName" with "[as String]" being separate, and; "NewValue [as Varies]" is also only one thing? Therefore, "PropertyApiName [as String]" is only asking for a string nothing more?

Let me run with that and see if I'm jumping to conclusions.

Thanks again.

MiD-AwE

Ok,

I now have:

(defun c:CNTRL-PNL_CPL-CAD_OnInitialize (/)
  (dcl_Control_SetProperty CNTRL-PNL_CPL-CAD_AccessTextBox "Text" *ACCESS*)
)

And, that appears to work as expected. Also, I have:

(defun c:CNTRL-PNL_CPL-CAD_AccessTextBox_OnReturnPressed (/)
  (vlax-ldata-put "JOB" "ACCESS" (DCL_CONTROL_GETTEXT CNTRL-PNL_CPL-CAD_AccessTextBox))
  (SETQ *ACCESS* (DCL_CONTROL_GETTEXT CNTRL-PNL_CPL-CAD_AccessTextBox))
  (vlax-invoke-method (vla-get-ActiveDocument (vlax-get-Acad-Object)) 'SendCommand "regen")
)

That appears to be working correctly as well. Should I be doing this differently?

Thank you very much for the clarifying comment Peter2.

Peter2

Quote from: MiD-AwE on October 16, 2013, 08:28:21 AM
...Therefore, "PropertyApiName [as String]" is only asking for a string nothing more?...
In your second post I see that you have understand, and yes

- the text [inside the brackets] is a description (of the format) what should be used before the [brackets]. You have to delete all things that are [inside the brackets]

- the text 'before the brackets' [] is a placeholder for the function / command / feature which you have to define.

Easy, isn't it?
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

MiD-AwE

Thank you.

Yeah it's pretty easy once the initial understanding is overcome. Since I work with A/VLISP in VLIDE I'm used to every jot and tittle, including spaces, representing the exact syntax.

I'm on my way now!  :)

Again Thank you, this is a big help.