Author Topic: DCL Question - Plus and Minus buttons modify Edit_Box value  (Read 2746 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
DCL Question - Plus and Minus buttons modify Edit_Box value
« on: September 16, 2005, 05:46:18 PM »
Here's the basic layout of my DCL file:

+ - [total]

There's a plus button, a minus button, and a total using an edit_box. Basic function would be the +/- increase/decrease the edit_box value, which starts at 0. I tried to modify the following code I found on AutoDesk's DG, but I know there's more to it.

Code: [Select]
(defun add (key val)
(cond ((= key "add")
(set_tile "total" (+ val 1)))
)
);defun

(action_tile "add" "(add $key $val")

I know this doesn't work because it's not grabbing the 'total' edit_box for the val. Any ideas?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: DCL Question - Plus and Minus buttons modify Edit_Box value
« Reply #1 on: September 16, 2005, 09:56:25 PM »
Here is a starter, done quickly.


Code: [Select]
(defun C:addTEST (/ dcl_id action total)
  (cond
    ;;  open the dcl file
    ((not (setq dcl_id (load_dialog "addbox.dcl")))
     (alert "DCL File not found. - Aborting.")
     (exit)
    )
    ;;  verify the dialog name is in the dcl file
    ;;  here we are using "main_dialog_name"
    ((not (new_dialog "add_dialog" dcl_id))
     (alert "DCL Label not found. - Aborting.")
     (exit)
    )
  ) ; end cond stmt


  (defun math (op / total)
    (setq total (atoi (get_tile "total")))
    (setq total (apply op (list total 1)))
    (set_tile "total" (itoa total))
  )

  (defun addhelp ()
    (alert (strcat "There is no help for this dialoh box.\n"
                   "           YET"
           )
    )
  )

  (set_tile "total" "1")
  (action_tile "add" "(math '+)")
  (action_tile "subtract" "(math '-)")
  (action_tile "help" "(addhelp)")
  (action_tile "ok" "(setq total (atoi(gettile \"total\")))(done_dialog 2)")
  (action_tile "cancel" "(setq total nil)(done_dialog 1)")

  (setq action (start_dialog))
  (unload_dialog dcl_id)


  (if (= action 2)
    (prompt "\nOK was pressed")
  )

  total
) ; END DEFUN

Code: [Select]
dcl_settings : default_dcl_settings { audit_level = 3; }

add_dialog : dialog {
    label = "  Add Box ";
  : row {
     spacer_1;
     : edit_box {
        key = "total" ;
        width = 10;
     }
     spacer_1;
     : column {
       : button {
          label = "&Add";
          key = "add";
       }
       : button {
          label = "&Subtract";
          key = "subtract";
       }
     }
  }
   
  spacer_1;
  ok_cancel_help;
  spacer_1;
}
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: DCL Question - Plus and Minus buttons modify Edit_Box value
« Reply #2 on: September 17, 2005, 09:47:18 AM »
Thanks CAB...I'll get crackin' on it!

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: DCL Question - Plus and Minus buttons modify Edit_Box value
« Reply #3 on: September 20, 2005, 04:08:07 PM »
Awesome CAB...finally had a chance to take a look at it.  Up next: implementation!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: DCL Question - Plus and Minus buttons modify Edit_Box value
« Reply #4 on: September 20, 2005, 04:11:29 PM »
Glad it worked for you.
Let us know how you make out.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: DCL Question - Plus and Minus buttons modify Edit_Box value
« Reply #5 on: September 20, 2005, 04:17:27 PM »
Let us know how you make out.

Well, that's kinda personal, but if you must know..

I start off by running my fingers thru her hair to the back of her head where I grasp a handfu....uh...wrong kind of 'make out'  :?

ronjonp

  • Needs a day job
  • Posts: 7531
Re: DCL Question - Plus and Minus buttons modify Edit_Box value
« Reply #6 on: September 20, 2005, 04:33:58 PM »
Quote
I start off by running my fingers thru her hair to the back of her head where I grasp a handfu....

 :-D :-D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC