Hello guys. I'm trying to build a dialog box with a slider, the number of which is variable; I enclose the result of my efforts hoping it will be useful to someone.
There is still something that I can not explain.
1) I think the statement in line 56 is wrong, and that the correct one is in the line 57, but it happens exactly the opposite, and I can not explain such behavior!
2) If I substitute the block 55-67 with the block 42-54 (that I thinked was correct), the function doesn't work!!
3) Why the function runs correctly, even without the instruction in line 68, that close the DCL?
Can anyone suggest to me why "action_tile" doesn't work as I think?
(defun SLIDER
-DCL
(Title$ valin@ sld@@ nomsl@ dir_slider$
/ cnt1# cnt2# keybsl$ keypar@ keypar@@ varsl@ keysl@ keysl@@ ptxt@ slin@ fin@ Return#
) ;;----------------------------------------------------------------------------------------------------------------------------
(defun ADEG_VALORI
-VARIABILI
(in@ ng@
/ ng# fin@
) ;;------------------------------------------------
;;------------------------------------------------
(defun SET_PARAGR
(kpar$ ptxt$ val$
) ;;----------------------------------------------------------------------------------------------------------------------------
cnt2# 0)
(setq keybsl$
(strcat "Slider" dir_slider$
)) ;_ nome base chiave variabili slider (per distinguere se verticale o orizzontale) (setq varsl@
(mapcar '
(lambda (nom
) (strcat nom
"$")) keysl@
)) ;_ nomi delle variabili usate per letture e settaggi chiavi slider (setq keypar@
(append keypar@
(list (strcat "txt" (itoa cnt2#
)))))) ;_ chiave progressiva tile txt del paragrafo ("txt1" "txt2" etc.) nomsl@))
sld@@) ;_ costruzione chiavi per slider e testi dei paragrafi
(setq valin@
(ADEG_VALORI
-VARIABILI valin@ nomsl@
));_ replicazione valori iniziali di riempimento per adeguarlo al numero di slider (repeat (length sld@@
) (setq ptxt@
(append ptxt@ nomsl@
)));_ lista dei prefissi di testo da anteporre al riempimento (IS o LF) ripetuta per il numero di slider (mapcar '
(lambda (varsl$ in$
) (set (read varsl$
) in$
)) varsl@ valin@
);_ settaggio variabili slider ai valori iniziali (CR_DLG_SLIDER fname sld@@ keypar@ keysl@ "" )
(exit)) ; Set Dialog Initial Settings ;;;------Settaggi iniziali DCL
(set_tile "Title" Title$
) ;_ titolo dcl scritto settando sempre la chiave della finestra di dialogo che si chiama sempre "Title" ;;; (mapcar '(lambda (ksl$ sl$ /) (set_tile ksl$ sl$)) keysl@ slin@) ;_ settaggio di ciascun slider al valore iniziale
;;; (mapcar '(lambda (ptxt$ kpar$ txt$ /) (set_tile kpar$ (strcat ptxt$ ":" txt$ "%"))) ptxt@ keypar@ slin@) ;_ settaggio di ciascun paragrafo al valore della slider
;;------Azioni
;;; (mapcar '(lambda (ksl$ varsl$ kpar$ ptxt$ / slset$ par$ parset$ aux$)
;;;
;;; (setq par$ (strcat ptxt$ ": " (rtos (atof (eval (read varsl$))) 2 0) "%"))
;;;
;;; (set_tile kpar$ par$ ) ;_ scrittura testo relativo nel paragrafo)
;;; (set_tile ksl$ (strcat (rtos (atof (eval (read varsl$))) 2 0) "%")) ;_ settaggio tile slider al valore rappresentato da varsl$
;;; (action_tile ksl$ "(setq aux$ $value)") ;_ il valore della tile slider ksl$ setta la variabile ausiliaria
;;; (set (read varsl$) aux$);_ la variabile varsl$ assume il valore della variabile ausiliaria
;;; )
;;; keysl@
;;; varsl@
;;; keypar@
;;; ptxt@)
(mapcar '
(lambda (ksl$ varsl$ kpar$ ptxt$
/ slset$ par$ parset$
) (setq slset$
(strcat "(setq " varsl$
" $value)"));_ funzione interpretata correttamente da action_tile???!!! ;;; (setq slset$ (strcat "(set (read " varsl$ ") $value)"));_ dà un errore quando letta da action_tile, perché al posto della var. varsl$ viene passato il suo valore???
(setq parset$
(strcat "(SET_PARAGR \"" kpar$
"\" \"" ptxt$
"\" $value)")) (set_tile kpar$ par$
) ;_ scrittura testo relativo nel paragrafo) (action_tile ksl$
(strcat slset$ parset$
)) ;_ il valore della tile slider ksl$ lancia le istruzioni a e b )
keysl@
varsl@
keypar@
ptxt@)
;;; (action_tile "accept" "(done_dialog 1)")
(setq Return#
(start_dialog)) ;_ var. Return# restituisce il valore di done_dialog (in questo caso dovrebbe essere solo e sempre 1, visto che c'è solo tasto ok!) (unload_dialog dcl_id
) ;_ scarico programma con il valore di done_dialog );_ fine defun
(defun CR_DLG_SLIDER
(fname cvd@@ keypar@ keysl@ subtitle$
/ keypar@@ keysl@@ dlg@ ckey# fn
) ;;--------------------------------------------------------------------------------------------------------------------------------------
(defun GROUPBYNUM
(lst n
/ r
) r))
(GROUPBYNUM lst n))))
;;-------------------------------------
(defun DCL_STARTDLG
(width#
/ width$
) (if width#
;_ se la larghezza effettiva totale della finestra di dialogo è passata da funzione chiamante... (setq width$
(strcat "width= " (itoa width#
) " ;")) ;_ ... larghezza effettiva passata da funzione chiamante (setq width$
"width= 40 ;")) ;_ oppure (list (strcat "temp : dialog {key = \"Title\"; label = \"\"; " width$
))) ;;-------------------------------------
(defun DCL_SLIDER
(keysl$ slmin# slmax#
/ keysl$
) ((wcmatch keysl$
"*V*") (setq layout$
"layout = vertical"))) layout$
"; key = \""
keysl$
"\"; min_value = "
"; max_value = "
"; small_increment = "
(itoa (/ (- slmax# slmin#
) 10)) "; big_increment = "
(itoa (/ (- slmax# slmin#
) 4)) ";
height = 8.43; fixed_height = true; is_tab_stop = false;}")))
;;-------------------------------------
(defun DCL_PARGRPH_ANON
(str@ key@
/ maxstr$ startpar$ fin@ txt@
) (setq startpar$
(list (strcat ": paragraph {width= " maxstr$
" ;"))) ;_ riga iniziale paragrafo (larghezza calcolata pari al numero massimo di caratteri) (setq fin@
(append fin@ startpar$
)) ;_ prima riga lista finale key@)) ;_ righe di testo raggruppate in lista
(setq fin@
(append fin@ txt@
)) ;_ aggiunta righe di testo a fin@ (setq fin@
(append fin@ '
("}"))) ;_ aggiunta parentesi graffa chiusura paragrafo )
;;--------------------------------------------------------------------------------------------------------------------------------------
'(keypar@@ keysl@@)
(setq dlg@
(DCL_STARTDLG
nil)) ;_ istruzioni iniziali di apertura (var. Title non interessata poiché chiave della DCL è sempre "Title", passata solo var. larghezza a nil) (setq dlg@
(append dlg@ '
(": column {"))) ;_ apertura colonna generale unica per contenimento di tutte le istruzioni, compreso OK finale (setq dlg@
(append dlg@
(list (strcat ": boxed_row { label = \"" subtitle$
"\" ;")))) ;_ apertura riga di inserimento slider e paragrafo, con sottotitolo tipsld$
(cdr cvd@
)) ;_ fissiamo il tipo di slider anche se per ora non lo usiamo (setq dlg@
(append dlg@
(list (strcat ": boxed_column { label = \"" cvd$
"\" ;")))) ;_ colonna di ogni singola gola con nome tipo cunicolo) (setq dlg@
(append dlg@ '
(": column {"))) ;_ prima riga, con slider (setq dlg@
(append dlg@
(DCL_SLIDER keysl$
0 100))) ;_ nome chiave (direzione slider "V" o "H" inserita in esso) + valori min. e max slider (setq dlg@
(append dlg@ '
("}")))) ;_ chiusura colonna singola slider keysl@)
(setq dlg@
(append dlg@ '
(": column {"))) ;_ prima riga, con slider (setq dlg@
(append dlg@
(DCL_PARGRPH_ANON
(list "IS 100%") (list keypar$
)))) ;_ istruz. paragrafo con stringa-tipo max e chiave in forma di lista (setq dlg@
(append dlg@ '
("}")))) ;_ chiusura colonna singola slide keypar@)
(setq dlg@
(append dlg@ '
("}")))) ;_ chiusura colonna cunicolo cvd@@
keypar@@
keysl@@)
(setq dlg@
(append dlg@ '
("}"))) ;_ chiusura rigo unico (setq dlg@
(append dlg@ '
("spacer; ok_only;"))) ;_ inserimento tasto OK (setq dlg@
(append dlg@ '
("}"))) ;_ chiusura colonna generale (setq dlg@
(append dlg@ '
("}"))) ;_ parentesi graffa chiusura dialogo (close fn
));_ fine defun DCL_STARTDLG
(setq Title$
"COEFF. RIEMPIM. MAX PROGETTO") (list "CUNICOLI" "TUBI & CORR." "CUN. ESISTENTI" "FUNI" "CUN. OPERE CIV.") (list "true" "true" "false" "false" "false"))) (setq nomsl@ '
("IS" "LF"))
(setq res@
(SLIDER
-DCL Title$ crin@ sld@@ nomsl@
"V" )) [/code