Author Topic: Variables  (Read 3660 times)

0 Members and 1 Guest are viewing this topic.

MichaelJ

  • Guest
Variables
« on: August 16, 2010, 09:47:22 AM »
Hello ,

I am Working since one day with Open DCL and i am happy about the possibilities.
I have a simple Question :

I would like to use a “Default” from Autolisp for a textfield or something else.
My Lists look like (setq UU (list “0” 1” “2”)).

For example , if ODCL is starting a textfield should be use (nth 0 UU).
How is the code for this ?

Thanks.

MichaelJ

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Variables
« Reply #1 on: August 16, 2010, 01:08:48 PM »
You may mean this ,

Code: [Select]
(setq UU (list "0" "1" "2"))
 (nth 0 UU) ; return 0
 (nth 1 UU) ; return 1
 (nth 2 UU) ; return 2

Best regards,

Tharwat

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Variables
« Reply #2 on: August 16, 2010, 01:36:10 PM »
 :-D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Variables
« Reply #3 on: August 17, 2010, 01:09:43 AM »
:-D

That's a very rude behavior, to laugh at people with no reason. whatever who might be meant by you.

MichaelJ

  • Guest
Re: Variables
« Reply #4 on: August 17, 2010, 04:05:29 AM »
No, thats not what i mean.
I mean the connection between the ODCL Name (Textfield or else) and the lisp-Variables. I want to have a variable Starting-Setting. In Acad are changing the Starting-Setting for the fields. ODCL must use the changing Defaults from Autocad.
My problem is, that I don’t know how to make the Connection.
Must I declare a VarName in ODCL ? And what I must do for the connection in Lisp that odcl ist using the changed Settings?
Michael

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Variables
« Reply #5 on: August 17, 2010, 04:49:27 AM »

MichaelJ

Do you have an ODCL dialog and code started??
Which variable values do you want to use in which controls ??

Please post the dialog code anfd Lisp code that you have so far.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Variables
« Reply #6 on: August 17, 2010, 06:12:02 AM »

See if this gives you any ideas ..

Code: [Select]

(vl-load-com)
(vl-cmdf "_OpenDCL")

(defun c:Doit () (Test0817) (princ))

(defun Test0817 (/ ComboList LBList TBValue dialogVariables)
  ;; Concept Example
  ;; CodeHimBelonga kdub@theSwamp
  ;; 2010.08.17
  ;;
  (setq ComboList       (list "A" "B" "C" "D" "E" "F")
        LBList          (list "1" "2" "3" "4")
        TBValue         "I'm a little TextBox, short and stout"
        dialogVariables (list (cons "ComboBox" "B")
                              (cons "OptionList" 1)
                              (cons "CheckBox" 1)
                        )
  )
  ;; Load the project (findfile "T0817.Odcl")
  (or (dcl_project_load "T0817" T) (exit))
  ;; show the main form
  (dcl_Form_Show T0817_Form 100 100)
  (princ)
)

;;=========================================
;; Event Handlers
;;=========================================
(defun c:T0817_Form_OnInitialize (/)
  (dcl_ListBox_AddList T0817_Form_ListBox1 LBList)
  (dcl_ComboBox_AddList T0817_Form_ComboBox1 ComboList)
  (dcl_Control_SetText T0817_Form_TextBox1 TBValue)
  (dcl_Control_SetValue T0817_Form_CheckBox1
                        (cdr (assoc "CheckBox" dialogVariables))
  )
  (dcl_OptionList_SetCurSel T0817_Form_OptionList1
                            (cdr (assoc "OptionList" dialogVariables))
  )
  (dcl_ComboBox_SelectString T0817_Form_ComboBox1
                             (cdr (assoc "ComboBox" dialogVariables))
  )
)
;;=========================================
(defun c:T0817_Form_TextButton1_OnClicked (/)
  (dcl_Control_SetText T0817_Form_TextBox1
                       "I've been changed by the buttonClicked Event"
  )
)
;;=========================================
(defun c:T0817_Form_CheckBox1_OnClicked (Value /)
  (if (zerop Value)
    (dcl_Control_SetEnabled T0817_Form_ComboBox1 nil)
    (dcl_Control_SetEnabled T0817_Form_ComboBox1 T)
  )
)
;;=========================================
(defun c:T0817_Form_ComboBox1_OnSelChanged (ItemIndexOrCount Value /)
  (dcl_ListBox_AddString T0817_Form_ListBox1 Value)
)
;;=========================================
(defun c:T0817_Form_OptionList1_OnSelChanged (ItemIndexOrCount Value /)
  (dcl_MessageBox Value "Test T0817")
)
;;=========================================
(princ)

 ;|«Visual LISP© Format Options»
(80 2 70 2 nil "end of " 100 70 0 0 0 nil nil nil T)
;*** DO NOT add text below the comment! ***|;


Code Attached
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Variables
« Reply #7 on: August 17, 2010, 10:50:57 AM »
:-D

That's a very rude behavior, to laugh at people with no reason. whatever who might be meant by you.

Actually Tharwat, it all comes down to interpretation.  I am sure MP interpreted what you posted as hilarious simply because you interpreted what MichaelJ posted different from what he was looking for.
Just as you are interpreting his  ' :-D ' icon to mean something rude when in all honesty, he is simply commenting on your post, which MP finds hilarious.

Please realize some of the guru's here at the swamp have been coding for a while and are very good at it, MP being one of them.  So thru interpretation of the posts, your post of
Code: [Select]
(setq UU (list "0" "1" "2"))
 (nth 0 UU) ; return 0
 (nth 1 UU) ; return 1
 (nth 2 UU) ; return 2
is actually quite funny considering the topic ODCL.

No offense intended, just some good, light humor.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

JohnK

  • Administrator
  • Seagull
  • Posts: 10655
Re: Variables
« Reply #8 on: August 17, 2010, 11:12:21 AM »
Um, MP is anything but rude. If you knew him...


NOTE: the `amount of time of coding' does not relate to `how well you code'.

Some one told me once that: *I* dont know anything until write at least 10,000 lines of code and until *I* wrote those lines i should shut-up. It didnt take me long (maybe a few months) to realize that 10,000 lines isnt nearly enough. 

I think it should be a pre-requisite for new members of this forum to read: "How to ask questions the smart way"

Quote
...
Dealing with rudeness

Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-bullshit communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy.

When you perceive rudeness, try to react calmly. If someone is really acting out, it is very likely a senior person on the list or newsgroup or forum will call him or her on it. If that doesn't happen and you lose your temper, it is likely that the person you lose it at was behaving within the hacker community's norms and you will be considered at fault. This will hurt your chances of getting the information or help you want.

On the other hand, you will occasionally run across rudeness and posturing that is quite gratuitous. The flip-side of the above is that it is acceptable form to slam real offenders quite hard, dissecting their misbehavior with a sharp verbal scalpel. Be very, very sure of your ground before you try this, however. The line between correcting an incivility and starting a pointless flamewar is thin enough that hackers themselves not infrequently blunder across it; if you are a newbie or an outsider, your chances of avoiding such a blunder are low. If you're after information rather than entertainment, it's better to keep your fingers off the keyboard than to risk this.

(Some people assert that many hackers have a mild form of autism or Asperger's Syndrome, and are actually missing some of the brain circuitry that lubricates “normal” human social interaction. This may or may not be true. If you are not a hacker yourself, it may help you cope with our eccentricities if you think of us as being brain-damaged. Go right ahead. We won't care; we like being whatever it is we are, and generally have a healthy skepticism about clinical labels.)

In the next section, we'll talk about a different issue; the kind of “rudeness” you'll see when you misbehave.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Variables
« Reply #9 on: August 17, 2010, 11:18:57 AM »
Um, MP is anything but rude. If you knew him...


NOTE: the `amount of time of coding' does not relate to `how well you code'.

Some one told me once that: *I* dont know anything until write at least 10,000 lines of code and until *I* wrote those lines i should shut-up. It didnt take me long (maybe a few months) to realize that 10,000 lines isnt nearly enough. 

I think it should be a pre-requisite for new members of this forum to read: "How to ask questions the smart way"

Quote
...
Dealing with rudeness

Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-bullshit communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy.

When you perceive rudeness, try to react calmly. If someone is really acting out, it is very likely a senior person on the list or newsgroup or forum will call him or her on it. If that doesn't happen and you lose your temper, it is likely that the person you lose it at was behaving within the hacker community's norms and you will be considered at fault. This will hurt your chances of getting the information or help you want.

On the other hand, you will occasionally run across rudeness and posturing that is quite gratuitous. The flip-side of the above is that it is acceptable form to slam real offenders quite hard, dissecting their misbehavior with a sharp verbal scalpel. Be very, very sure of your ground before you try this, however. The line between correcting an incivility and starting a pointless flamewar is thin enough that hackers themselves not infrequently blunder across it; if you are a newbie or an outsider, your chances of avoiding such a blunder are low. If you're after information rather than entertainment, it's better to keep your fingers off the keyboard than to risk this.

(Some people assert that many hackers have a mild form of autism or Asperger's Syndrome, and are actually missing some of the brain circuitry that lubricates “normal” human social interaction. This may or may not be true. If you are not a hacker yourself, it may help you cope with our eccentricities if you think of us as being brain-damaged. Go right ahead. We won't care; we like being whatever it is we are, and generally have a healthy skepticism about clinical labels.)

In the next section, we'll talk about a different issue; the kind of “rudeness” you'll see when you misbehave.
Se7en, Thanks for posting that particular quote. It's point is exactly what I have attempted to explain many times over when 'some' accuse me of 'doing' something to other users.  When in fact my focus has been to either solve some problem or forward the disscussion of some problem to consider alternate approaches to the solution for same and not 'do' anything to anyone.

Now back to the discussion at hand.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Variables
« Reply #10 on: August 17, 2010, 01:57:26 PM »
Se7en, Thanks for posting that particular quote.

Ditto:

Quote
Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-bullshit communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy.

Pretty much hits the nail on the head...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Variables
« Reply #11 on: August 17, 2010, 03:51:10 PM »

Quote from: 8ben


< snip > and are actually missing some of the brain circuitry that lubricates “normal” human social interaction. This may or may not be true. < snip >

I have no problem .. I use bourbon as a lubricant.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Variables
« Reply #12 on: August 17, 2010, 04:03:05 PM »
Michael,

   What exactly is it you're trying to achieve?

  From what you've said, it looks like you want to present your user with a list of possible options to pick from, and have one of these as the default answer.

   If that *is* the case, you want to use INITGET to define your list of options and GETKWORD to get your user to select one of these, and COND to tell your routine what do with the selected option.

  An example of this might be:

Code: [Select]
(DEFUN c:WhatsUU ()
(INITGET "0" "1" "2" "3" "4");define the list of options
(SETQ
uu (GETKWORD "\nSelect an option [0, 1, 2, 3, 4]<0>: ");Prompt your user to select an option.  <0> indicates that "0" is the default
);SETQ
(COND
((= uu "0")(SETQ multiplier 0))
((= uu "1")(SETQ multiplier 1))
((= uu "2")(SETQ multiplier 2))
((= uu "3")(SETQ multiplier 3))
((= uu "4")(SETQ multiplier 4))
);COND

(SETQ result (* 10 multiplier))
(ALERT multiplier)



);DEFUN

   You would further use If and NOT to set your default value:
   
   
Code: [Select]
(DEFUN c:WhatsUU ()
(INITGET "0" "1" "2" "3" "4");define the list of options
(SETQ
uu (GETKWORD "\nSelect an option [0, 1, 2, 3, 4]<0>: ");Prompt your user to select an option.  <0> indicates that "0" is the default
);SETQ

(IF
(NOT uu)
(SETQ uu 0)
);IF

(COND
((= uu "0")(SETQ multiplier 0))
((= uu "1")(SETQ multiplier 1))
((= uu "2")(SETQ multiplier 2))
((= uu "3")(SETQ multiplier 3))
((= uu "4")(SETQ multiplier 4))
);COND


(SETQ result (* 10 multiplier))
(ALERT multiplier)



);DEFUN


I hope that this *is* what you're trying to do.  If not, ignore it!

If it is, I hope it helps.

dJE
===
dJE

MichaelJ

  • Guest
Re: Variables
« Reply #13 on: August 18, 2010, 03:35:31 AM »
Hello @all,
My english is not so good, so that I have problems to describe the problem exactly. But the first post from Kerry with the example “Test0817” included all the things what I need.
Afterwards I mean only this connection:

(defun Test0817 (/ ComboList LBList TBValue dialogVariables)
…..
(setq ComboList       (list "A" "B" "C" "D" "E" "F")
…..
); END DEFUN

(defun c:T0817_Form_OnInitialize (/)
(dcl_ComboBox_AddList T0817_Form_ComboBox1 ComboList)
)

It was a little problem with a great discussion, which I don’t want.
Thanks for help.
Michael

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Variables
« Reply #14 on: August 18, 2010, 04:00:41 AM »

You're welcome Michael,
glad I could help.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.