Sei sulla pagina 1di 23

DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

DCL – Dialog Control Language:


Introdução
João Manuel R. S. Tavares

Bibliografia
 Material disponível no AfraLisp.net em http://www.afralisp.net
 Programação em AutoCAD, Curso Completo
Fernando Luís Ferreira, João Santos
FCA
 Sistema de ajuda do AutoCAD

2 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 1


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Introdução
 A Dialog Control Language permite criar interfaces gráficas (caixas de
diálogo e de mensagens) para aplicações em AutoLISP/Visual Lisp
 Cada caixa de diálogo deve ser definida (dialog definition) em ficheiros
de definição com a extensão dcl
 Cada controlo de um diálogo necessita ser definido (tile definition) e é
referenciado no código lisp pelo seu nome (key)
 Cada propriedade (property) de um controlo (tile) é designada por
atributo do diálogo (attribute)
 Cada método de um controlo é designado por expressão de acção
(action expression)
 O Visual Lisp Editor possibilita a previsão de um diálogo definido num
ficheiro dcl (em Tools, Interface Tools)

3 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Introdução (cont.)
 No ficheiro base.dcl do AutoCAD existem definições e estruturas úteis que
podem ser usadas (para usar, incluir @include "base.dcl" no ficheiro
respectivo)
 Na definição dos diálogos (ficheiros dcl):
 São usados { } em vez de ( )
 Para definir propriedades usa-se o sinal =
 As linhas de atributos terminam com ;
 Comentários são indicados com // ou /* */
 As definições são iniciadas com :
 Criação
C i ã dde um diál
diálogo:
 Sintaxe: nome : dialog { conteúdo }

4 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 2


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Introdução (cont.)
 Exemplo (ficheiro hello.dcl):
hello : dialog { // é dado o nome "hello" à
// caixa de diálogo
label = "Primeira Caixa de Diálogo"; // título a aparecer na caixa
: text { // início de zona de texto
label = "Hello, world"; // texto a aparecer
} // fim da zona de texto
: button { // é criado um botão OK para terminar
key = "terminado"; // o valor da tecla
label = "OK"; // o nome da tecla
is_default = true; // declara que este é o botão por omissão
} // fim do botão "ok"
}
5 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Introdução (cont.)
 Exemplo (ficheiro hello.lsp):
(Defun c:hello ()

(setq dcl_id (load_dialog "hello.dcl")) ; o file é carregado


(if (not (new_dialog "hello" dcl_id)) ; verifica se existe o ficheiro
(exit) ; se não existe saí
)

(start_dialog)
d l ; é mostrada
d a caixa de
d
dialogo
(unload_dialog dcl_id) ; retira a recém-criada caixa
)

6 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 3


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Introdução (cont.)
 Definição de um controlo (tile):
 nome : item1 [ : item2 : item3 …]
{ atributo = valor ; … }
 Referência a um controlo predefinido:
 : nome {
atributo = valor ;

}

7 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Introdução (cont.)
 Exemplo (ficheiro hello1.dcl):
hello : dialog { // é dado o nome "hello" à
// caixa de diálogo
label = "Primeira Caixa de Diálogo"; // título a aparecer na caixa
: text { // início de zona de texto
label = "Hello, world"; // texto a aparecer
} // fim da zona de texto
ok_only; // botão "ok" predefinido
}

8 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 4


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Introdução (cont.)
 Exemplo (ok_cancel.dcl)
ex_cancel : dialog { // é dado o nome "ex_cancel" à
// caixa
i dde diál
diálogo
label = "Exemplo Ok_Cancel"; // título a aparecer na caixa
spacer_0; // espaçamento
ok_cancel; // botões "ok" e "cancel"
// predefinidos
}

9 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Introdução (cont.)
 Exemplo (ficheiro hello1.lsp):

(Defun c:hello ()
(setq dcl_id (load_dialog "hello1.dcl")) ; o ficheiro é carregado
(if (not (new_dialog "hello" dcl_id)) ; verifica se existe o ficheiro
(exit) ; se não existe saí
)

(start_dialog) ; é mostrada a caixa de diálogo


(unload_dialog dcl_id) ; retira a recém-criada caixa
)

10 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 5


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Controlos Predefinidos
 Exit Buttons e Error Tiles  Decorative e Informative Tiles
 ok_only
 image
 ok_cancel
 text
 ok_cancel_help
ok cancel help
 ok_cancel_help_errtile  spacer
 ok_cancel_help_info  spacer_0
 errtile  spacer_1
 Predefined Active Tiles  Text Clusters
 button
 ncatenation
 edit_box
 list_box  paragraph
 popup_list  text_part
 radio_button
 toggle
 slider
 image_button

11 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Controlos Predefinidos (cont.)


 Tile Clusters
 boxed_column
 boxed_radio_column
 boxed_radio_row
 boxed_row
 column
 dialog
 radio_column
 radio_row
 row

12 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 6


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Atributos de Controlos
 Globais
 alignment
 fixed_height
 fixed_width
fi d id h
 height
 width
 Aplicam-se a: All Tiles

 Action Tiles
 action
 is_enabled
 is_tab_stop
 key
 mnemonic
 Aplicam-se a: button; edit_box; image_button; list_box; popup_list;
radio_button; slider; toggle; radio_column; radio_row
13 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Atributos de Controlos (cont.)


 Tile Clusters
 children_alignment
 children_fixed_height
_ _ g
 children_fixed_width
 Aplicam-se a: row; column; radio_row; radio_column; boxed_row;
boxed_column; boxed_radio_row; boxed_radio_column
 Specific Tiles
 allow_accept
 Aplicam-se a: edit_box; image_button; list_box
 aspect_ration
 Aplicam-se a: image; image_button
 big_increment
 Aplicam-se a: slider

14 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 7


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Atributos de Controlos (cont.)


 Specific Tiles (cont.)
 color
 Aplicam-se a: image; image_button
 edit_limit
 Aplicam-se a: edit_box
 edit_width
 Aplicam-se a: edit_box; popup_list
 fixed_width_font
 Aplicam-se a: edit_box; popup_list
 initial_focus
initial focus
 Aplicam-se a: dialog
 is_cancel
 Aplicam-se a: button

15 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Atributos de Controlos (cont.)


 Specific Tiles (cont.)
 is_default
 Aplicam-se a: button
 label
 Aplicam-se a: boxed_row; boxed_column; boxed_radio_row;
boxed_radio_column; button; dialog; edit_box; list_box; popup_list;
radio_button; text; toggle
 layout
 Aplicam-se a: slider
 list
 Aplicam-se
A li a: list_box;
li t b popup_list
li t
 max_value
 Aplicam-se a: slider
 min_value
 Aplicam-se a: slider

16 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 8


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Atributos de Controlos (cont.)


 Specific Tiles (cont.)
 multiple_select
 Aplicam-se a: list_box
 password_char
 Aplicam-se a: edit_box
 small_increment
 Aplicam-se a: slider
 tabs
 Aplicam-se a: list_box; popup_list
 tab_truncate
tab truncate
 Aplicam-se a: list_box; popup_list
 value
 Aplicam-se a: text; todos active tiles (excepto buttons e image_buttons)

17 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Funções AutoLISP para diálogos DCL


 (load_dialog ficheiro.dcl) ; carrega file
 (new_dialog nome dcl_id acção ecrã) ; carrega diálogo
 ((start_dialog)
_ g) ; mostra diálogo
g
 (done_dialog saida) ; fecha diálogo e retorna saída
 (term_dialog) ; fecha todos diálogos abertos
 (unload_dialog dcl_id) ; descarrega diálogo
 (action_tile key expressão) ; estabelece acção para tile key
 (get_attr key atributo) ; obter valor do tile key (string)
 ( t til key)
(get_tile k ) ; obter
bt valorl ddo tile
til key
k (string)
(ti )
 (set_tile key valor) ; atribuir valor para o tile key (string)
 (mode_tile key modo) ; define modo (0 - activa, 1 - desactiva, 2 -
destaca, 3 - selecciona conteúdo, 4 - muda destaque de uma imagem)

18 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 9


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Funções AutoLISP para diálogos DCL (cont.)


 (start_list key operação indice) ; inicia lista
 (add_list string) ; adiciona string numa lista
 ( d li t)
(end_list) ; termina
t i lilista t
 (start_image key) ; inicia criação de imagem
 (dimx_tile key) ; dimensão de imagem em x
 (dimy_tile key) ; dimensão de imagem em y
 (vector_image xini yini xfim yfim cor) ; desenha vector
 (fill_image xini yini larg alt cor) ; desenha rectângulo
 (slide_image xini yini larg alt nomeslide) ; inserir slide
 (end_image) ; termina criação de imagem

19 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Funções AutoLISP para diálogos DCL (cont.)

20 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 10


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Funções AutoLISP para diálogos DCL (cont.)

21 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Funções AutoLISP para diálogos DCL (cont.)

22 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 11


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Funções AutoLISP para diálogos DCL (cont.)

23 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Funções AutoLISP para diálogos DCL (cont.)

24 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 12


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Funções AutoLISP para diálogos DCL (cont.)

25 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Funções AutoLISP para diálogos DCL (cont.)

26 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 13


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: file TEST_DCL1.DCL


//DCL CODING STARTS HERE
test_dcl1
: dialog
{
label = "Test
Test Dialog No 11";;
: text // controlo de texto
{
label = "This is a Test Message";
alignment = centered;
}
: button // definição de um botão
{
key = "accept"; // nome do botão
label = "Close"; // etiqueta
q do botão
is_default = true; // controlo por defeito
fixed_width = true;
alignment = centered; // alinhamento
}
}
//DCL CODING ENDS HERE

27 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL1.LSP


; AUTOLISP CODING STARTS HERE
(prompt "\nType TEST_DCL1 to run.....") ; indicação no prompt do autocad após load do programa
(defun C:TEST_DCL1 ()
(setq dcl
dcl_id
id (load
(load_dialog
dialog "test
test_dcl1.dcl
dcl1 dcl"))
)) ; load do ficheiro de definição
(if (not (new_dialog "test_dcl1" dcl_id)) ; carregamento do diálogo em memoria
(exit)
) ; if
(action_tile "accept" "(done_dialog)") ; action_tile – quando carrega no botão, fecha o diálogo
(start_dialog) ; mostrar diálogo
(unload_dialog dcl_id) ; descarregar o diálogo da memoria
(princ)
) ; defun
(princ)
; AUTOLISP CODING ENDS HERE

28 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 14


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: Notas
 Cada linha de atributo no ficheiro de definição do diálogo
termina com ;
 Comentários indicados com //
 Sensível a maiúsculas e a minúsculas
 Sequência de utilização:
 Load do ficheiro do diálogo
 Load da definição do diálogo
 Executar instrução(ões)
ç ( ) action_tile
 Iniciar o diálogo
 Descarregar o diálogo da memória

29 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL2.DCL


//DCL CODING STARTS HERE alignment = centered;
test_dcl2 edit_limit = 3; // input max. 3 chars
: dialog edit_width = 3; // largura max. 3 chars
{ value = ""; // valor inicial
label = "Test Dialog No 2"; }
: edit_box : button
{ {
label = "Enter Your Name :"; key = "accept";
mnemonic = "N"; // char sublinhado label = "OK";
key = "name"; is_default = true;
alignment = centered; fixed_width = true;
edit_limit = 30; // max. 30 chars alignment = centered;
edit width = 30; // larg.
edit_width larg max.
max 30 chars }
} : errtile // para mensagem de erro
: edit_box {
{ width = 34;
label = "Enter Your Age :"; }
mnemonic = "A"; }
key = "age"; //DCL CODING ENDS HERE
30 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 15


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: file TEST_DCL2.LSP


; AUTOLISP CODING STARTS HERE
(prompt "\nType TEST_DCL2 to run.....")
(defun C:TEST_DCL2 (/ dcl_id)
(setqq dcl_id (load_dialogg "test_dcl2.dcl"))
(if (not (new_dialog "test_dcl2" dcl_id))
(exit)
) ; if
(set_tile "name" "Enter Name Here") ; define conteúdo em run-time
(mode_tile "name" 2) ; permite override
(action_tile "name" "(setq name $value)") ; após selecção atribui valor à variável name
(action_tile "age" "(setq age $value)") ; após selecção atribui valor à variável age
(action_tile "accept" "(val1)") ; após selecção chama subprograma
(
(start_dialog)
d l ) ; mostra ddiálogo
ál
(unload_dialog dcl_id)
(alert (strcat "Your name is " name ; message box
"\nand you are " age
" years of age."
)
)
31 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL2.LSP (cont.)


(princ)
) ; defun
;-----------------------
(defun val1 ()
(if (= (get_tile "name") "Enter Name Here") ; receber valor no controlo
(progn
(set_tile "error" "You must enter a name!") ; por valor no controlo
(mode_tile "name" 2)
) ; progn
(val2) ; chama subprograma
) ; if
) ; defun
;-------------------
(defun val2 ()
(if (< (atoi (get_tile "age")) 1) ; receber valor no controlo
(progn
(set_tile "error" "Invalid Age - Please Try Again!!") ; por valor no controlo
(mode_tile "age" 2)
)
32 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 16


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: file TEST_DCL2.LSP (cont.)


; progn
(done_dialog) ; fecha diálogo
) ; if
) ; defun
(princ)
;AUTOLISP CODING ENDS HERE

33 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL3.DCL


afra : dialog { }
label = "A" ; }
: column { : row {
: row { : button {
: button { label = "Save";
label = "OK"; key = "save";
key = "accept"; mnemonic = "S";
mnemonic = "O"; alignment = centered;
alignment = centered; width = 12;
width = 12; }
is_default = true; // tem de existir um : button {
// default label = "Load";
} key = "load";
load ;
: button { mnemonic = "L";
label = "Cancel"; alignment = centered;
key = "cancel"; width = 12;
mnemonic = "C"; }
alignment = centered; }
width = 12;
34 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 17


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: file TEST_DCL3.DCL (cont.)


: row {
: button {
label = "Help...";
key = "help";
mnemonic = "H";
alignment = centered;
width = 12;
}
: button {
label = "About...";
key = "About";
mnemonic = "H";
alignment = centered;
width = 12;
}
}
}
}

35 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL3.LSP


; AUTOLISP CODING STARTS HERE
(prompt "\nType TEST_DCL3 to run.....")
(defun C:TEST_DCL3 (/ dcl_id)
(setqq
dcl_id (load_dialog
" TEST_DCL3.DCL"
)
)
(if (not (new_dialog "afra" dcl_id))
(exit)
) ; if
(start_dialog) ; sai do diálogo quando seleccionar o botão OK
( l d d l ddcl_id)
(unload_dialog l d)
(princ)
) ; defun

36 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 18


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: file TEST_DCL4.DCL


samp : dialog { //dialog name
label = "Structural Holes" ; //give it a label
: row { //define row
: boxed_radio_column { //define radio column
label = "Type" ; //give it a label
: radio_button { //define radion button
key = "rb1" ; //give it a name
label = "Bolt Holes &Site" ; //give it a label
value = "1" ; //switch it on
} //end definition
: radio_button { //define radio button
key = "rb2" ; //give it a name
l b l = "B
label "Bolt
l Holes
H l Sho&p"
Sh "; //
//give it a llabel
b l
} //end definition
: radio_button { //define radio button
key = "rb3" ; //give it a name
label = "Bolt Holes &Hidden" ; //give it a label
} //end definition
37 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL4.DCL (cont.)


: radio_button { //define radio button
key = "rb4" ; //give it a name
label = "Bolt Holes &Ctsnk" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb5" ; //give it a name
label = "Bolt Holes &Elevation" ; //give it a label
} //end definition
: radio_button { //define radion button
key = "rb6" ; //give it a name
label = "Bolt Holes &Slotted" ; //give it a label
} //end definition
} // d radio
//end d column
l
: boxed_column { //define boxed column
label = "&Size"; //give it a label
: popup_list { //define popup list
key = "selections"; //give it a name
value = "5”; //initial value
}
38 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 19


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: file TEST_DCL4.DCL (cont.)


} //end boxed column
} //end row
: edit_box { //define edit box
keyy = "eb1" ; //give
g it a name
label = "Slot &Length (O/All Slot)" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
: slider { //defin slider
key = "myslider" ; //give it a name
max_value = 100; //upper value
min_value = 0; //lower value
value = "50"; //initial value
} // d slider
//end ld
: boxed_row { //*define boxed row
: toggle { //*define toggle
key = "tog1"; //*give it a name
label = "Ortho On/Off"; //*give it a label
}
39 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL4.DCL (cont.)


: toggle { //*define toggle
key = "tog2"; //*give it a name
label = "Snap On/Off"; //*give it a label
} //*end definition
} //*end boxed row
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //define image tile
key = "im" ; //give it a name
height = 1.0 ; //and a height
width = 1.0 ; //and now a width
} //end image
: paragraphh { //d f paragraphh
//define
: text_part { //define text
label = "Designed and Created"; //give it some text
} //end text
: text_part { //define more text
label = "by Kenny Ramage"; //some more text
} //end text
40 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 20


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: file TEST_DCL4.DCL (cont.)


} //end paragraph
} //end row
} //end dialog

41 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL4.LSP


(defun C:samp () ; define function
(setq lngth 50.0) ; preset slot length
(setq hole "site") ; preset hole type
(setqq siz "M20") ; ppreset hole size
(setq NAMES '("M6" "M8" "M10" "M12" "M16" "M20" "M24" "M30“) ; define list
)
(setq ; setq
dcl_id (load_dialog
" TEST_DCL4.DCL"
)
) ; load dialog
(if (not (new_dialog "samp" dcl_id) ; test for dialog
) ; not
(exit) ; exit if no dialog
) ; if
(setq w (dimx_tile "im") ; get image tile width
h (dimy_tile "im") ; get image tile height
) ; setq
42 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 21


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: file TEST_DCL4.LSP (cont.)


(start_image "im") ; start the image
(fill_image 0 0 w h 5) ; fill it with blue
(end_image) ; end image
(start_list "selections") ; start the list box
(mapcar 'add_list NAMES) ; fill the list box
(end_list) ; end list
(set_tile "eb1" "50") ; put dat into edit box
(mode_tile "eb1" 1) ; disable edit box
(mode_tile "myslider" 1) ; disable slider
(setq orth (itoa (getvar "orthomode"))) ; *get orthomode value
(set_tile "tog1" orth) ; *switch toggle on or off
(setq sna (itoa (getvar "snapmode"))) ; *get snap value
(
(set_tile
l ""tog2"
2" sna)) ; *switch
* h toggle
l on or off
ff
(action_tile
"myslider" ; if user moves slider
"(slider_action $value $reason)"
) ; pass arguments to slider_action

43 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL4.LSP (cont.)


(action_tile
"eb1" ; is user enters slot length
"(ebox_action $value $reason)"
) ; ppass arguments
g to ebox_action
(defun slider_action (val why) ; define function
(if (or (= why 2) (= why 1)) ; check values
(set_tile "eb1" val)
)
) ; update edit box
(defun ebox_action (val why) ; define function
(if (or (= why 2) (= why 1)) ; check values
(set_tile "myslider" val)
)
) ; update slider
(action_tile "tog1" "(setq orth $value)") ; *get ortho toggle value
(action_tile "tog2" "(setq sna $value)") ; *get snap toggle value
(action_tile "rb1" "(setq hole \"site\")") ; store hole type
(action_tile "rb2" "(setq hole \"shop\")") ; store hole type
44 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 22


DCL - Dialog Control Language: Introdução 2009@FEUP/DEMec-SDI

Exemplo: file TEST_DCL4.LSP (cont.)


(action_tile "rb3" "(setq hole \"hid\")") ; store hole type
(action_tile "rb4" "(setq hole \"ctsk\")") ; store hole type
(action_tile "rb5" "(setq hole \"elev\")") ; store hole type
(action_tile
"rb6"
"(setq hole \"slot\") ; store hole type
(mode_tile \"eb1\" 0) ; enable edit box
(mode_tile \"myslider\" 0) ; enable slider
(mode_tile \"eb1\" 2)"
) ; switch focus to edit box
(action_tile
"cancel" ; if cancel button pressed
"(d
"(done_dialog)
d l ) ((setq userclick
l k nil)"
l)" ; close
l ddialog,
l set flflag
) ; action_tile
(action_tile
"accept" ; if O.K. pressed
(strcat ; string 'em together
"(progn
45 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

Exemplo: file TEST_DCL4.LSP (cont.)


(setq SIZ (atof (get_tile \"selections\")))" ; get list selection
"(setq lngth (atof (get_tile \"eb1\")))" ; get slot length
"(setvar \"orthomode\" (atoi orth))" ; *ortho on/off
"(setvar \"snapmode\"
p (atoi sna))" ; *snapp on/off
" (done_dialog)(setq userclick T))" ; close dialog, set flag
) ; strcat
) ; action tile
(start_dialog) ; start dialog
(unload_dialog dcl_id) ; unload
(if userclick ; check O.K. was selected
(progn
(setq SIZ (fix SIZ)) ; convert to integer
(
(setq SIZ ((nthh SIZ NAMES)) ; get the
h size
) ; progn

) ; if userclick
(princ)
) ; defun C:samp
(princ)
46 CFAC: DCL - Dialog Control Language: Introdução 2009@João Tavares

João Manuel R. S. Tavares 23

Potrebbero piacerti anche