View Full Version : DCL question...
eriss
2008-03-18, 04:28 AM
I am trying create a routine to do many calcs, for example:
in DCL:
calculator:dialog {
:edit_box { label = "Height";
width = 15;
key = "height"
:edit_box { label = "Width";
width = 15;
key = "Width"
}
text {
label = "Result";
width = 15;
key = "result"
}
:button {
label ="Calculate";
key ="calculate";
width = 15;
}}}
..and whow I do to show the result on text field pushing "Calculate button"?
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)
sufferinyankeebastid
2008-03-18, 07:14 AM
button {
label ="Calculate";
key ="calculate";
width = 15;
action="(calfun)";
(defun calfun ( / cr)
...calcs...and type checking/conversion!!!
(set_tile "result" cr)
)
action can alternatively be set in your lsp:
(action_tile "calculate" "(calfun)")
Either include (get_tile "height"), etc. within (calfun)
OR
Edit boxes can set variables when changed:
(action="(setq ht $value)"; in DCL
(action_tile "height" "(setq ht $value)") in LSP
OR
(defun calfun (ht wdth / cr) with (calfun (get_tile "height") (get_tile "Width"))
Be careful to include error & formatting control in all of these functions & actions.
Users can be inadvertently very reckless, so your code should reject changes at will.
Bulletproof the sonofa...gun!
Keep Help open while you work this stuff; it ain't an everyday thing; ya know.:beer:
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)
eriss
2008-03-18, 04:04 PM
Thankyou guy ;D really I will use yor info...
eriss
2008-03-18, 05:59 PM
results aren't being displayed =( , calfun are not setting title for display results...on exact moment that I push Calculate button =/.
;Lisp-----------------------------
(DEFUN C:VCCALC (/ DCLVC)
(setq DCLVC (load_dialog "C:\\Documents and Settings\\User\\Desktop\\calc\\calc.DCL"));<-- your dcl name
(new_dialog "calc" DCLVC)
(action_tile "n1" "(setq n1 $value)")
(action_tile "n2" "(setq n2 $value)")
(action_tile "calcular" calfun )
(start_dialog)
)
(DEFUN calfun (/ cr)
(SETQ cr (+ n1 n2 ))
(set_tile "result" cr)
)
;DCL -----------------------------
calc:dialog {
label="Test";
:boxed_column {
label="Dados";
:edit_box {
label="n1";
key="n1";
width=15;
}
:edit_box {
label="n2";
key="n2";
width=15;
}
:text {
label="Total";
key="result";
width=15;
}
:button {
label="Calcular";
key="calcular";
width=15;
}
}
ok_cancel;
}
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)
sufferinyankeebastid
2008-03-18, 11:44 PM
Half the work with dialogs involves conversion to and from a string.
(DEFUN C:VCCALC (/ DCLVC calfun n1 n2)
(if (and (setq DCLVC (load_dialog "test.DCL"))
(new_dialog "calc" DCLVC))
(progn
(DEFUN calfun () (set_tile "result" (rtos (+ n1 n2) 2)))
(setq n1 0.0 n2 0.0)
(action_tile "n1" "(setq n1 (atof $value))")
(action_tile "n2" "(setq n2 (atof $value))")
(action_tile "calcular" "(calfun)")
(set_tile "n1" (rtos n1 2))
(set_tile "n2" (rtos n2 2))
(calfun)
(start_dialog)
(unload_dialog DCLVC)
)
)
(princ)
)
eriss
2008-03-19, 01:03 AM
Now its done thankyou guy ;D. Im starting with lisp programming.. I will use this example in my work to create calculators to use on my projects.
I work with Eng. civil creating structures of concrete ...
sufferinyankeebastid
2008-03-19, 03:01 AM
(DEFUN C:VCCALC (/ DCLVC tfun calfun n1 n2)
(defun tfun (n v r / alpha)
(defun alpha (s / c)
(or (not (and (<= 45 (setq c (ascii (substr s 1 1))) 57) (/= c 47)))
(if (< 1 (strlen s)) (alpha (substr s 2)))
)
)
(if (= n "accept") (done_dialog 1))
(if (= r 2) (if (alpha v) (set_tile n "") (set (read n) (atof v))))
)
(if (and (setq n1 0 n2 0 DCLVC (load_dialog "test.DCL"))
(new_dialog "calc" DCLVC "(tfun $key $value $reason)"))
(progn
(DEFUN calfun () (set_tile "result" (rtos (+ n1 n2) 2 2)))
(action_tile "calcular" "(calfun)") (mode_tile "n1" 2)
(start_dialog) (unload_dialog DCLVC)
)
)
(princ)
)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.