Hi guys,
The last days I was thinking about putting some practice over the
mode_tile function.
The idea of this example won't go out of my head so just now I had some spare time to assemble it (my goal was to "visualise" how it works) :
; mode_tile Practice/Visualisation
; (mode_tile key mode)
; mode ; Type: Integer
; A numeric value that can be one of the following:
; 0 -- Enable tile
; 1 -- Disable tile
; 2 -- Set focus to tile
; 3 -- Select edit box contents
; 4 -- Flip image highlighting on or off
(defun C:test
( / *error* dcl des dch dcf rtn
)
); defun *error*
(
"ModeTile : dialog"
"{"
" label = \"Mode Tile Practice\";"
" : column"
" {"
" : edit_box"
" { label = \"BoxLabel\"; key = \"Box\"; value = \"BoxValue\"; edit_width = 16; width = 22; fixed_width = true; alignment = centered; }"
" spacer;"
" : button { label = \"Enable tile\"; key = \"Enable\"; edit_width = 36; width = 36; fixed_width = true; }"
" : button { label = \"Disable tile\"; key = \"Disable\"; edit_width = 36; width = 36; fixed_width = true; }"
" : button { label = \"Set focus to tile\"; key = \"Focus\"; edit_width = 36; width = 36; fixed_width = true; }"
" : button { label = \"Select edit box contents\"; key = \"Select\"; edit_width = 36; width = 36; fixed_width = true; }"
" : button { label = \"Flip image highlighting\"; key = \"Flip\"; edit_width = 36; width = 36; fixed_width = true; } "
" spacer;"
" ok_cancel;"
" }"
"}"
); strcat
des
); write-line / princ
); and
); not
(princ "\nUnable to write or load the DCL file.") )
(
(or ; actions for mode_tile (foreach x '
(("Enable" 0) ("Disable" 1) ("Focus" 2) ("Select" 3) ("Flip" 4)) ; (action_tile (car x) (vl-prin1-to-string '(mode_tile "Box" (cadr x)))) ; This won't work, why?
); foreach
(progn ; This progn block is redundant, just leaving it to see how (action_tile) is normally used, instead of the above (foreach) (action_tile "Disable" "(mode_tile \"Box\" 1)") ; check (action_tile "Select" "(mode_tile \"Box\" 3)") ; what this does ? (action_tile "Flip" "(mode_tile \"Box\" 4)") ; what this does ? ); progn
); or
); foreach
)
); progn
); not
(princ "\nUnable to display the dialog") )
); cond
(*error* nil)
); defun C:test
Obviously I used a DCL template thats from Lee Mac's DCL examples, because IMO it can't be written more perfectly otherwise.
( Even the variable names are matching - just wanted to make sure we talk on the same language
)
So.. back to the questions:
1. I had trouble understanding what this means:
; 3 -- Select edit box contents
; 4 -- Flip image highlighting on or offOr atleast this part of the code "didn't worked/visualised well":
(action_tile "Select" "(mode_tile \"Box\" 3)") ; what this does ? (action_tile "Flip" "(mode_tile \"Box\" 4)") ; what this does ?
2. This
action_tile part didn't worked correctly, why?
The code errors out, then I go to the
last break source and in a new source window displays:
;;; Copied to window at 11:49 PM 1/22/17
(lambda ($KEY $VALUE $DATA $REASON $X $Y
) )
;;; End of text
I assumed that the trouble might be because of the strcasing:
"(MODE_TILE \"Box\" 1)"
_$
But this works?! :