Author Topic: Under dialog how can I start them  (Read 1870 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Under dialog how can I start them
« on: May 07, 2013, 09:55:08 AM »
Hi!

I have no idea how I can start a underdialog in DCL
In my example I have two dialogs

In first page  "CHAN" (menu) I want see somthing in listbox or select.
In second page "ADD" I want paste somthing to can see that in menu "CHAN"

Here my try:

Code: [Select]
;;;(defun LM:ListBox ( title data multiple / file tmp dch return )
  ;; © Lee Mac 2011

(defun c:test ( / file tmp dch return)
  (cond
    (
      (not
        (and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w"))
          (write-line "
  CHAN : dialog {label = \"NOTES\";
       : list_box {label = \"Choose Selection :\";key = \"selections\";height = 12;}
       : list_box {label = \"Preview :\";key = \"preview\";width = 50;height = 5;}
       : boxed_row {
                 : button {key = \"Okay\";label = \" Okay \";is_default = true;}
         : button {key = \"Cancel\";label = \" Cancel \";is_default = false;is_cancel = true;}
         : button {key = \"Add\";label = \" Add \";is_default = false;is_cancel = true;}
         }
         
       }
   ADD : dialog {label = \"Add\";
       : row {
       : edit_box {key = \"Selection\";label = \"Selection:\";edit_width = 25;height = 1;value = \"\";}
            }
       : edit_box {key = \"Preview\";label = \"Preview:\";edit_width = 25;height = 1;value = \"\";}
       ok_cancel;
       } "
                      file
                      )
             (not (close file))
             (< 0 (setq dch (load_dialog tmp)))
             (new_dialog "listbox" dch)

             )
        )
      )
    )
 
  ;; Run Dcl menu dialog
  (if (<= (setq dcl_id (load_dialog tmp)) 0)
    (alert "Error loading DCL file.")
    )
  (if (not (new_dialog "CHAN" dcl_id))
    (alert "Error loading  dialog.")
    )
  (princ)
  )


cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Under dialog how can I start them
« Reply #1 on: May 23, 2013, 02:18:24 AM »
My next try show that I get a dialog, where I can "Add" something in the dialog. But if I press than ok the dialog close with "error: bad argument type: stringp nil"
I want that the dialog still show new adding things.

Code: [Select]
;; function trims text lines
(defun _strtrim (s delims / len s1 i c lst)
  (setq delims (vl-string->list delims)
len (strlen s)
s1 ""
i (1+ len))
  (while (> (setq i (1- i)) 0)
    (setq c (substr s i 1))
    (if (member (ascii c) delims)
      (if (/= s1 "") ; no null tokens
        (setq lst (cons s1 lst)
      s1 "")
)
      (setq s1 (strcat c s1))
      )
    )
  (if (/= s1 "")
    (cons s1 lst)  ; no ("" "1" "2")!
    lst
    )
  )

;; function read csv-files
(defun _ReadCSV ( filename / _csv->lst file line)

  (defun _csv->lst ( str / pos )
    (if (setq pos (vl-string-position 44 str))
      (cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
      (list str)
      )
    )

  (if (setq file (open filename "r"))
    (progn
      (while (setq line (read-line file))
        (setq lst (cons (_csv->lst line) lst))
        )
      (close file)
      )
    )
  (setq lst (reverse lst))
  )



(defun c:test ( / file tmp dch return)
  (cond
    (
      (not
        (and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w"))
          (write-line "
  CHAN : dialog {label = \"NOTES\";
       : list_box {label = \"Choose Selection :\";key = \"selections\";height = 12;}
       : list_box {label = \"Preview :\";key = \"preview\";width = 50;height = 5;}
       : boxed_row {
                 : button {key = \"Okay\";label = \" Okay \";is_default = true;}
         : button {key = \"Cancel\";label = \" Cancel \";is_default = false;is_cancel = true;}
         : button {key = \"Add\";label = \" Add \";is_default = false;is_cancel = true;}
         }
       }
   ADD : dialog {label = \"Add\";
       : row {
       : edit_box {key = \"Selection\";label = \"Selection:\";edit_width = 25;height = 1;value = \"\";}
            }
       : edit_box {key = \"Preview\";label = \"Preview:\";edit_width = 25;height = 1;value = \"\";}
       ok_cancel;
       } "
                      file
                      )
             (not (close file))
             )
        )
      )
    )
 
  ;; Run Dcl menu dialog
  (if (<= (setq dcl_id (load_dialog tmp)) 0)
    (alert "Error loading DCL file.")
    )
  (if (not (new_dialog "CHAN" dcl_id))
    (alert "Error loading  dialog.")
    )
  (princ)
 
 
  ;; function selects tabell
  ;; read in dialog
  (if (null NAMES)
    (setq NAMES (list '("1" "TEST1") '("2" "TEST2") '("3" "TEST3"))) ;testweise
    )
   
  (start_list "selections")
  (mapcar ' add_list (mapcar 'car NAMES))
  (end_list)
  (action_tile "selections" (strcat "(progn (setq SIZ $value)"
                                    "(start_list \"preview\")"
                                    "(mapcar ' add_list (setq txt (cdr (assoc (nth (atoi siz)(mapcar 'car NAMES))NAMES))))"
                                    "(end_list)"
                                    "(mode_tile \"accept\" 2))"
                            )
  )
  (action_tile "Okay" (strcat "(progn "
"(setq txt (car txt))"
"(done_dialog 1))"
                        )
  )
  (action_tile "cancel" "(done_dialog 0)")
 
  (action_tile "Add" (strcat "(if (<= (setq dcl_id (load_dialog tmp)) 0)
                               (alert \"Error loading DCL file.\")
                               )"
                             "(if (not (new_dialog \"ADD\" dcl_id))
                               (alert \"Error loading  dialog.\")
                               )
                             (start_dialog)"
                     )
  )

  (setq res (start_dialog))
  (unload_dialog dcl_id)
  (if (= res 1)
    (progn
      (SETVAR "ORTHOMODE" 0)
      (SETVAR "OSMODE" 512)
      (SETVAR "DIMTAD" 0) 
;;;      (PRINC "\nSelect  1ST & 2nd point of leader")
;;;      (COMMAND "DIM" "LEADER"  PAUSE PAUSE "" txt "EXIT")
      (initget "t l ")
      (if (setq a (getkword "\nDo you want a [T]ext or a [L]eader ? "))
        (cond ((= a "l")
               (while (setq pt (getpoint "\nPick a Leader Insert Point ! "))
                 (command "._mleader" "_non" pt pause txt)
                 )
               )
              (T (while (setq pt (getpoint "\nPick a Text Insert Point ! "))
                   (command "mtext" pt "w" "0" txt "" )
                   )
               )
              )
            )
      (SETVAR "DIMTAD" 1)
      (SETVAR "OSMODE" 107)))
  (vl-file-delete fname)
  (princ)
  )
(prompt "\n\t---\tStart command with TEST\t---")
(prin1)




[Edit]
Type in "test", it must open dialog "Notes" and than try to add something. Here I need help.
After typing new values in Add-dialog I want show values in dialog "Notes" (how).
« Last Edit: May 23, 2013, 04:01:34 AM by cadplayer »

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Under dialog how can I start them
« Reply #2 on: May 24, 2013, 09:55:25 AM »
It could be helpfully for me, if somebody have a example how I can import values from a dialog to annother dialog ?

kruuger

  • Swamp Rat
  • Posts: 637
Re: Under dialog how can I start them
« Reply #3 on: May 24, 2013, 10:55:54 AM »
It could be helpfully for me, if somebody have a example how I can import values from a dialog to annother dialog ?
will this help ?
Code: [Select]
(defun _notes (/ *lst)
  (setq *lst (list "TEST2" "TRAD"))
  (action_tile "ADD" "(go to (_add)) (set_tile \"Choose Selection\" *lst)")
)

(defun _add (/ val)
  (setq val (get Selection from user))
  (setq *lst (append *lst (list val)))
  Back to (_notes)
)
k.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Under dialog how can I start them
« Reply #4 on: May 24, 2013, 10:56:08 AM »
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.