Author Topic: Dos_multilist with Lisp/DCL  (Read 1400 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Dos_multilist with Lisp/DCL
« on: October 26, 2023, 11:04:05 AM »
Has anyone done something similar to dos_multilist before? (I don't need the boxes Select All - Clear All)

(dos_multilist title prompt list [indices])
Parameters
title    A string containing the dialog box title.
prompt   A string containing the dialog box prompt.
list     A list of string values.
indices  A zero-based list of indices identifying pre-selected items.


Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Dos_multilist with Lisp/DCL
« Reply #2 on: October 27, 2023, 10:48:23 AM »
Perhaps -

http://lee-mac.com/listbox.html
http://lee-mac.com/filtlistbox.html
https://www.theswamp.org/index.php?topic=44909

Thanks Lee, looking at your very useful functions was the first thing I did... but I haven't yet found a function that allows you to preselect items
Like Dos_Multilist > "indices  A zero-based list of indices identifying pre-selected items."

kozmos

  • Newt
  • Posts: 114
Re: Dos_multilist with Lisp/DCL
« Reply #3 on: October 27, 2023, 12:21:43 PM »
Perhaps -

http://lee-mac.com/listbox.html
http://lee-mac.com/filtlistbox.html
https://www.theswamp.org/index.php?topic=44909

Thanks Lee, looking at your very useful functions was the first thing I did... but I haven't yet found a function that allows you to preselect items
Like Dos_Multilist > "indices  A zero-based list of indices identifying pre-selected items."

It is very easy and simple to add preselect based on Lee's function, here is an example
Code - Auto/Visual Lisp: [Select]
  1. ;; List Box  -  Lee Mac
  2. ;; Displays a DCL list box allowing the user to make a selection from the supplied data.
  3. ;; msg - [str] Dialog label
  4. ;; lst - [lst] List of strings to display
  5. ;; bit - [int] 1=allow multiple; 2=return indexes;
  6. ;; sel - [lst] Preselect indice, can be integer or list of integer if need preselect multiple items
  7. ;; Returns: [lst] List of selected items/indexes, else nil
  8.  
  9. (defun LM:listboxWithPreSelect (msg lst bit sel / dch des tmp rtn)
  10.   (cond
  11.     ((not
  12.        (and
  13.          (setq tmp (vl-filename-mktemp nil nil ".dcl"))
  14.          (setq des (open tmp "w"))
  15.          (write-line
  16.            (strcat "listbox:dialog{label=\""
  17.                    msg
  18.                    "\";spacer;:list_box{key=\"list\";multiple_select="
  19.                    (if (= 1 (logand 1 bit))
  20.                      "true"
  21.                      "false"
  22.                    )
  23.                    ";width=50;height=15;}spacer;ok_cancel;}"
  24.            )
  25.            des
  26.          )
  27.          (not (close des))
  28.          (< 0 (setq dch (load_dialog tmp)))
  29.          (new_dialog "listbox" dch)
  30.        )
  31.      )
  32.      (prompt "\nError Loading List Box Dialog.")
  33.     )
  34.     (t
  35.      (start_list "list")
  36.      (foreach itm lst (add_list itm))
  37.      (end_list)
  38.      (setq rtn
  39.             (set_tile "list"
  40.                       (cond
  41.                         ((= (type sel) 'int) (itoa sel))
  42.                         ((listp sel)
  43.                          (apply 'strcat
  44.                                 (mapcar '(lambda (x) (strcat (itoa x) " ")) sel)
  45.                          )
  46.                         )
  47.                         (t "0")
  48.                       )
  49.             )
  50.      )
  51.      (action_tile "list" "(setq rtn $value)")
  52.      (setq rtn
  53.             (if (= 1 (start_dialog))
  54.               (if (= 2 (logand 2 bit))
  55.                 (read (strcat "(" rtn ")"))
  56.                 (mapcar '(lambda (x) (nth x lst))
  57.                         (read (strcat "(" rtn ")"))
  58.                 )
  59.               )
  60.             )
  61.      )
  62.     )
  63.   )
  64.   (if (< 0 dch)
  65.     (unload_dialog dch)
  66.   )
  67.   (if (and tmp (setq tmp (findfile tmp)))
  68.     (vl-file-delete tmp)
  69.   )
  70.   rtn
  71. )
  72.  

You can test with (LM:listboxWithPreSelect "zcasfas/fs" '("fas.jfsa.f" "asfasf" "ASfasg" "r23523w" "dfasfgsaf") 1 '(0 4))
« Last Edit: October 30, 2023, 01:55:29 AM by kozmos »
KozMos Inc.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Dos_multilist with Lisp/DCL
« Reply #4 on: October 28, 2023, 03:44:49 AM »
...
It is very easy and simple to add preselect based on Lee's function, here is an example
...
You can test with (LM:LISTBOX "zcasfas/fs" '("fas.jfsa.f" "asfasf" "ASfasg" "r23523w" "dfasfgsaf") 1 '(0 4))
Thank you very much, it was what I was looking for, IMHO I think it is better to rename the function you modified so as not to generate doubts (rereading the post in a long time) whether it is the original one or not. Thanks again.

kozmos

  • Newt
  • Posts: 114
Re: Dos_multilist with Lisp/DCL
« Reply #5 on: October 30, 2023, 01:54:15 AM »
...
It is very easy and simple to add preselect based on Lee's function, here is an example
...
You can test with (LM:LISTBOX "zcasfas/fs" '("fas.jfsa.f" "asfasf" "ASfasg" "r23523w" "dfasfgsaf") 1 '(0 4))
Thank you very much, it was what I was looking for, IMHO I think it is better to rename the function you modified so as not to generate doubts (rereading the post in a long time) whether it is the original one or not. Thanks again.

you are right, I just modified the fucntion name so it will not make confuse in the future.
KozMos Inc.

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: Dos_multilist with Lisp/DCL
« Reply #6 on: October 30, 2023, 05:41:03 AM »
https://drive.google.com/file/d/1vrwg0uY0-yJnm9IgE5_gTFD6yy-ivN5o/view?usp=sharing

with OpenDCL everything is easier and there are many more possibilities

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Dos_multilist with Lisp/DCL
« Reply #7 on: October 30, 2023, 08:55:16 AM »
https://drive.google.com/file/d/1vrwg0uY0-yJnm9IgE5_gTFD6yy-ivN5o/view?usp=sharing

with OpenDCL everything is easier and there are many more possibilities
Thanks Domenico, but I'm trying to do as much as possible with standard AutoLisp.