Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/12/2020 in all areas

  1. (Defun foot (lst / a b c d e f x nlst) (While (setq a (Car lst)) (setq x (Cdr lst)) (setq b (reverse a) c (Car b) d (cdr b) ) (while (setq e (car x)) (if (equal (cdr (reverse e)) d) (setq c (+ (last e) c)) (setq g (cons e g)) ) (setq x (cdr x)) ) (setq nlst (cons (append d (list c)) nlst) lst g g nil ) ) nlst ) Test (setq lst '((1 1 1 1 3) (2 2 2 2 3) (1 1 1 1 4))) _$ (foot lst) ((1 1 1 1 7) (2 2 2 2 3)) _$ (foo lst) ((1 1 1 1 7) (2 2 2 2 3)) _$ (F:S lst) ((1 1 1 1 7) (2 2 2 2 3)) _$ (F:G lst) ((1 1 1 1 7) (2 2 2 2 3)) _$ (setq lst '((1 1 1 1 3) (2 2 2 2 2 3) (1 1 1 1 4) (1 1 1 1 1 4)(2 2 2 2 2 7))) ((1 1 1 1 3) (2 2 2 2 2 3) (1 1 1 1 4) (1 1 1 1 1 4) (2 2 2 2 2 7)) _$ (foot lst) ((1 1 1 1 7) (2 2 2 2 2 10) (1 1 1 1 1 4)) _$ (foo lst) ((1 1 1 1 7) (2 2 2 2 2 10) (1 1 1 1 1 4)) _$ (F:S lst) ((1 1 1 1 8) (2 2 2 2 4)) _$ (F:G lst) ((1 1 1 1 7) (2 2 2 2 2 10) (1 1 1 1 1 4))
    1 point
  2. Rlx did such thing few years ago - Tokkie & SmartList - just some DCL lunch fun Lunch time fun : RLX Multi-Tokkie I would say "Hey, give this guy a lunch break!"
    1 point
  3. You can't actually program the DCL code to have a panel that scrolls. However - you can "fake" the scrolling by using a slider and altering the values of the boxes to "scroll" them. It's allot of work though. You have to do the following things: 1.) either have a dialog defined for each of 1 through 10 items, or define the dialog on the fly from within the lisp. (Alternatively - you could just use 1 dialog with 10 items and just use (mode_tile) to disable the slider and extra boxes.) 2.) If the list is over 10 items, use a predefined dialog with 10 items and a slider to the right of the column. Set the sliders "layout" attribute to "vertical". 3.) You have to set the "small_increment" attribute to 1, and the "big_increment" to 10 (or smaller) in the slider. 4.) To have the slider start at the top, you have to set the value of the slider (via "set_tile" in the lisp function) to the length of the list i.e. (set_tile "scroll1" (length lst1)). 5.) when the slider is used, you have to reverse the $value returned by the slider like (- (length lst1) $value) in the action_tile statement. 6.) in the action_tile statement, you have to define a callback function that will reset all the values from the list elements to start with the list item from the slider value after above step. 7.) also in the callback, you have to check for the $reason callback 3 to show the values scrolling, but reset the values if the user does not make a final selection ($reason value of 3 is returned). 8.) you have to record the altered value of the slider from step 5 and add that number to offset the "nth" value when changing items in your list elements, so that the correct item is edited. This is allot of code, but possible. I hope this helps. EDIT: Below is a DCL example I made with 10 rows and a slider. Let me know if you have questions. Note: 1) I used "text" tiles instead of labels for the boxes, so they can be independently updated, and the width is consistent. 2) I used a "max_value" attribute on the slider tile of 1000. this should be set to the longest list you think your going to have. It is even better if you write the DCL from within the LISP file, then you can set the "max_value" attribute to the exact length of the list every time. This makes the scrolling hit bottom when the list ends. Unfortunately - this attribute cannot be set at run-time. special_list1 : dialog { key = "sd1"; label = "Special List 1"; : row { : boxed_column { : row { : text {width = 10; key = "lbl1"; fixed_width = true; label = "Value 01";} : edit_box {width = 10; key = "edb1"; fixed_width = true;} : text {width = 10; key = "lbl1b"; fixed_width = true; label = "Option 01";} : popup_list {width = 12; key = "lst1"; fixed_width = true;} } : row { : text {width = 10; key = "lbl2"; fixed_width = true; label = "Value 02";} : edit_box {width = 10; key = "edb2"; fixed_width = true;} : text {width = 10; key = "lbl2b"; fixed_width = true; label = "Option 02";} : popup_list {width = 12; key = "lst2"; fixed_width = true;} } : row { : text {width = 10; key = "lbl3"; fixed_width = true; label = "Value 03";} : edit_box {width = 10; key = "edb3"; fixed_width = true;} : text {width = 10; key = "lbl3b"; fixed_width = true; label = "Option 03";} : popup_list {width = 12; key = "lst3"; fixed_width = true;} } : row { : text {width = 10; key = "lbl4"; fixed_width = true; label = "Value 04";} : edit_box {width = 10; key = "edb4"; fixed_width = true;} : text {width = 10; key = "lbl4b"; fixed_width = true; label = "Option 04";} : popup_list {width = 12; key = "lst4"; fixed_width = true;} } : row { : text {width = 10; key = "lbl5"; fixed_width = true; label = "Value 05";} : edit_box {width = 10; key = "edb5"; fixed_width = true;} : text {width = 10; key = "lbl5b"; fixed_width = true; label = "Option 05";} : popup_list {width = 12; key = "lst5"; fixed_width = true;} } : row { : text {width = 10; key = "lbl6"; fixed_width = true; label = "Value 06";} : edit_box {width = 10; key = "edb6"; fixed_width = true;} : text {width = 10; key = "lbl6b"; fixed_width = true; label = "Option 06";} : popup_list {width = 12; key = "lst6"; fixed_width = true;} } : row { : text {width = 10; key = "lbl7"; fixed_width = true; label = "Value 07";} : edit_box {width = 10; key = "edb7"; fixed_width = true;} : text {width = 10; key = "lbl7b"; fixed_width = true; label = "Option 07";} : popup_list {width = 12; key = "lst7"; fixed_width = true;} } : row { : text {width = 10; key = "lbl8"; fixed_width = true; label = "Value 08";} : edit_box {width = 10; key = "edb8"; fixed_width = true;} : text {width = 10; key = "lbl8b"; fixed_width = true; label = "Option 08";} : popup_list {width = 12; key = "lst8"; fixed_width = true;} } : row { : text {width = 10; key = "lbl9"; fixed_width = true; label = "Value 09";} : edit_box {width = 10; key = "edb9"; fixed_width = true;} : text {width = 10; key = "lbl9b"; fixed_width = true; label = "Option 09";} : popup_list {width = 12; key = "lst9"; fixed_width = true;} } : row { : text {width = 10; key = "lbl10"; fixed_width = true; label = "Value 10";} : edit_box {width = 10; key = "edb10"; fixed_width = true;} : text {width = 10; key = "lbl10b"; fixed_width = true; label = "Option 10";} : popup_list {width = 12; key = "lst10"; fixed_width = true;} } } : slider {key = "scroll1"; layout = vertical; small_increment = 1; big_increment = 10; value = 1000; max_value = 1000;} } ok_cancel; }
    1 point
  4. Providing that the functions are appropriately named when used in an application, defining the supporting function outside of the function in which it is called is more efficient, as if the supporting function is defined locally within the calling function, the supporting function is needlessly redefined for every evaluation of the calling function.
    1 point
  5. Yes, Lee, yours is better... (I am not sure if (vl-string-trim) would trim more characters than it should... If I may revise my version : (defun foo ( strlst / findpre itm pre suf a b ) (defun findpre ( strlst k / str ) (if (null itm) (setq itm (car strlst)) ) (setq str (substr itm 1 k)) (if (vl-every '(lambda ( x ) (wcmatch x (strcat str "*"))) strlst) (findpre strlst (1+ k)) (substr str 1 (1- (strlen str))) ) ) (setq pre (findpre strlst 1)) (setq itm nil) (setq strlst (mapcar 'vl-list->string (mapcar 'reverse (mapcar 'vl-string->list strlst)))) (setq suf (vl-list->string (reverse (vl-string->list (findpre strlst 1))))) (setq a (strlen pre)) (setq b (strlen suf)) (setq strlst (mapcar 'vl-list->string (mapcar 'reverse (mapcar 'vl-string->list strlst)))) (setq strlst (mapcar '(lambda ( x ) (substr x (1+ a) (- (strlen x) a b))) strlst)) ;;; This line is better (Thanks Lee) (list pre strlst suf) ) ;;; (foo '("Level 1 Floor Plan" "Level 2 Floor Plan" "Level 2b Floor Plan" "Level 3 Floor Plan")) ;;; ("Level " ("1" "2" "2b" "3") " Floor Plan")
    1 point
  6. How about: (defun foo ( l / a b ) (setq a (bar l) b (bar (mapcar '(lambda ( x ) (vl-list->string (reverse (vl-string->list x)))) l)) ) (list (substr (car l) 1 a) (mapcar '(lambda ( x ) (substr x (1+ a) (- (strlen x) a b))) l) (substr (car l) (- (strlen (car l)) b -1)) ) ) (defun bar ( l ) (apply 'min (mapcar '(lambda ( s ) (vl-string-mismatch (car l) s)) (cdr l))) ) _$ (foo '("Level 1 Floor Plan" "Level 2 Floor Plan" "Level 2b Floor Plan" "Level 3 Floor Plan")) ("Level " ("1" "2" "2b" "3") " Floor Plan") If you want case-insensitivity, simply include the ignore-case argument for the vl-string-mismatch function.
    1 point
  7. On this episode of RetroCAD, we're exploring one of the original AutoCAD-based solid modeling programs.
    1 point
  8. Presented for your enjoyment:
    1 point
×
×
  • Create New...