Author Topic: can Min and Max value in Slider dialog box, assigned as variable ?  (Read 1276 times)

0 Members and 1 Guest are viewing this topic.

CatDance

  • Newt
  • Posts: 57
Becos I have several nos of min and max value. I thought of saving some space by assigning the min and max as variable.


My Dcl and lisp as below. It is the value of 100 and 1000 (at line 14 and 15 as shown below). I have many mins and max and thought of only using one edit box for all.
Is it possible to do that ?

Code - Auto/Visual Lisp: [Select]
  1.  
  2. //Slider dcl
  3. Slider : dialog {                               //dialog name
  4.           label = "slider";                     //give it a label
  5.  
  6.         : edit_box {                            //define edit box
  7.          key = "eb1";                           //give it a name
  8.          label = "Amount value: ";              //give it a label
  9.          edit_width = 6;                        //6 characters only
  10.         }                                       //end edit box
  11.  
  12.         : slider {                              //define slider
  13.         key = "myslider";                       //give it a name
  14.         max_value = 1000;                       //upper value
  15.         min_value = 100;                        //lower value
  16.         value = "50";                           //initial value
  17.         }                                       //end slider
  18.  
  19.         ok_cancel;                              //predefined OK/Cancel button
  20.  
  21.         }                                       //end dialog
  22.  
  23.  
  24. ;-----------------------
  25.  
  26. ;slider and edit box lisp
  27. ;-----------------------
  28.  
  29. (defun C:SliderBox ()
  30.   (setq Amount 250)  ;preset
  31.   (setq Dcl_Id% (load_dialog "SlideEditBox.dcl"))       ;load dialog
  32.   (new_dialog "Slider" Dcl_Id%)
  33.  
  34.   (set_tile "eb1" (itoa Amount))        ;put data into edit box
  35.   (set_tile "myslider" (itoa Amount))
  36.   (mode_tile "eb1" 2)           ;switch focus to edit box
  37.   (action_tile "myslider" "(slider_action $value $reason)")     ;if user moves slider then pass arguments to slider_action
  38.   (action_tile "eb1" "(ebox_action $value $reason)")            ;if user enters slot length then pass arguments to ebox_action
  39.  
  40.   ;if O.K. pressed then string 'em together
  41.   (action_tile "accept" (strcat "(progn (setq Amount (get_tile \"eb1\")) (done_dialog) (setq userclick T))"))
  42.  
  43.   ;if cancel button pressed then close dialog
  44.   (action_tile "cancel" "(done_dialog) (setq userclick nil)")
  45.    
  46.   (start_dialog)  ;start dialog
  47.   (unload_dialog Dcl_Id%) ;unload
  48.        
  49.   ;check O.K. was selected then display the selected length.
  50.   (if userclick (alert (strcat "You Selected: " Amount)))
  51.                        
  52.  (princ)
  53. );defun
  54.  
  55.   ;define function
  56.   ;---------------
  57.   (defun slider_action (val why)
  58.     (if (or (= why 2) (= why 1)) (set_tile "eb1" val)) ;check values then update edit box
  59.   )  
  60.   (defun ebox_action (val why)
  61.     (if (or (= why 2) (= why 1)) (set_tile "myslider" val)) ;check values then update slider
  62.   )
  63.  
  64.  
  65.  
  66.  
  67.  
A must-read book: Amazing story how Bill + Paul started Microsoft and history of computer revolution.
https://www.amazon.com/Hard-Drive-Making-Microsoft-Empire/dp/0887306292

Brief history of Microsoft
https://www.youtube.com/watch?v=BLaMbaVT22E

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: can Min and Max value in Slider dialog box, assigned as variable ?
« Reply #1 on: November 03, 2021, 09:04:56 PM »
Yes is the answer, you make the slider a seperate little lisp that uses (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) this writes temporary files in this case your slider dcl.

so  max_value = 1000;   Becomes (write-line (strcat  max_value = " (rtos maxv 2 0) ";" ) fo)

So you need to write-line all the dcl. After using dont forget (vl-file-delete fname)

(if (not slider-dcl)(load "slider dcl"))
(slider-dcl 1000 100 50)

I have Mutil getvals, Multi radio buttons and Multi toggles.lsp they are all user definable writing a dcl to suit.

You can make very complicated dcl also by writing to file.


   
A man who never made a mistake never made anything

CatDance

  • Newt
  • Posts: 57
Re: can Min and Max value in Slider dialog box, assigned as variable ?
« Reply #2 on: November 04, 2021, 07:03:34 AM »
Yes is the answer, you make the slider a seperate little lisp that uses (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) this writes temporary files in this case your slider dcl.

so  max_value = 1000;   Becomes (write-line (strcat  max_value = " (rtos maxv 2 0) ";" ) fo)

So you need to write-line all the dcl. After using dont forget (vl-file-delete fname)

(if (not slider-dcl)(load "slider dcl"))
(slider-dcl 1000 100 50)

I have Mutil getvals, Multi radio buttons and Multi toggles.lsp they are all user definable writing a dcl to suit.

You can make very complicated dcl also by writing to file.


   

Writing to file is another way.
Thanks, I didn't thought of that.

A must-read book: Amazing story how Bill + Paul started Microsoft and history of computer revolution.
https://www.amazon.com/Hard-Drive-Making-Microsoft-Empire/dp/0887306292

Brief history of Microsoft
https://www.youtube.com/watch?v=BLaMbaVT22E

CatDance

  • Newt
  • Posts: 57
Re: can Min and Max value in Slider dialog box, assigned as variable ?
« Reply #3 on: November 23, 2021, 01:41:40 AM »
Yes is the answer, you make the slider a seperate little lisp that uses (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) this writes temporary files in this case your slider dcl.

so  max_value = 1000;   Becomes (write-line (strcat  max_value = " (rtos maxv 2 0) ";" ) fo)

So you need to write-line all the dcl. After using dont forget (vl-file-delete fname)

(if (not slider-dcl)(load "slider dcl"))
(slider-dcl 1000 100 50)

I have Mutil getvals, Multi radio buttons and Multi toggles.lsp they are all user definable writing a dcl to suit.

You can make very complicated dcl also by writing to file.


   

thanks Bigal. I got it done using your method.
A must-read book: Amazing story how Bill + Paul started Microsoft and history of computer revolution.
https://www.amazon.com/Hard-Drive-Making-Microsoft-Empire/dp/0887306292

Brief history of Microsoft
https://www.youtube.com/watch?v=BLaMbaVT22E

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: can Min and Max value in Slider dialog box, assigned as variable ?
« Reply #4 on: November 23, 2021, 10:52:20 PM »
Glad to here perhaps post code and a image someone else may want it.

This is 3 sliders it is hard coded but if I redo now would be like my other multi get lisps.


A man who never made a mistake never made anything