Author Topic: starting function by radio button equal 1  (Read 4278 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: starting function by radio button equal 1
« Reply #15 on: November 30, 2015, 02:52:12 PM »
When the (abc) or (def) functions are called they have not yet been defined.
Try 'unnesting' these functions, or make sure they are defined at the start of the main function and not at the end.

In general: unlocalized nested functions don't make a lot of sense.
Note that not a single variable is localized. This is not good practice. :police:

Denzuki

  • Guest
Re: starting function by radio button equal 1
« Reply #16 on: November 30, 2015, 04:03:35 PM »
Ok, my variables have been localized and my abc and efg functions were placed before the oldsnap definition. I verified my parenthesis and now I get
; error: too few arguments

I should mention that this tool will be specific to model space.

ymg

  • Guest
Re: starting function by radio button equal 1
« Reply #17 on: November 30, 2015, 07:28:45 PM »
Roy,

I agree with your comments about localizing variables and/or subroutine, however we were still at the proof of concept stage.

ymg

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: starting function by radio button equal 1
« Reply #18 on: December 01, 2015, 03:04:41 AM »
@ Denzuki: You should post your revised code.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: starting function by radio button equal 1
« Reply #19 on: December 01, 2015, 03:09:27 AM »
@ Denzuki: You should post your revised code.

why ? isn't it more fun to guess ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Denzuki

  • Guest
Re: starting function by radio button equal 1
« Reply #20 on: December 01, 2015, 10:57:00 AM »
I like this group, especially the wise-achers!

So , I ran some more tests and changed a few things here and there to get it to work. This morning I saved my drawing to my local drive along with my LSP and DCL files and ran them. Finally it works. Now my question becomes, how do I make this work in an enterprise type setting? Previously, I had my DWG, LSP and DCL in a network folder and it would not work. Could be security related maybe?

And before you ask, yes my path had been mapped previously. :-)
Code: [Select]
;;;LSP code starts here

(defun c:msam ( / *acdoc* *aclay* *acspc* oldsnap oldfile newl1 newl2 newl3 newl4 newl5 newl6 newl7 newl8
       cba_list cbalist colspc rowspc selitem0 selitem1 selitem2 selitem3 cbspc0 cbspc1 cbspc2 cbspc3
       baba babc babe babg prmtr1 prmtr2 prmtr3 prmtr4 etest1 ddiag Dbox)
       

   (vl-load-com)
 

   (or *acdoc*  (setq *acdoc*  (vla-get-ActiveDocument (vlax-get-acad-object))))

   (or *aclay*  (setq *aclay*  (vla-get-Layers *acdoc*)))

   (setq *acspc* (if (= (getvar "CVPORT") 1)
         (vla-get-PaperSpace *acdoc*)
         (vla-get-ModelSpace *acdoc*)
          )
)

;888888888888888888888888888888888888888888888888888888888888888

   (defun abc (/ catno2)

      (alert "abc running !")

      (princ (setq catno2 (strcat "CATALOG NUMBER = " selitem0 "-" selitem1 "-" selitem2 "-" selitem3 " ")))

   )

   (defun efg (/ catno3)     

     (alert "efg running")

      (princ (setq catno3 (strcat "CATALOG NUMBER = " selitem1 "-" selitem0 "-" selitem3  "-" selitem2 " ")))

   )

  ;88888888888888888888888888888888888888888888888888888888888888888888888888888
 
   (setq oldsnap (getvar "osmode"))

   (setq oldfile (getvar "filedia"))

   (setvar "osmode" 0)

   (setvar "filedia" 0)
 

   (defun dtr (x) (* pi (/ x 180.0)))
 

   (setq newl1 (vla-add *aclay* "C-test-1"))

   (vla-put-color newl1 253)

   (setq newl2 (vla-add *aclay* "C-test-2"))

   (vla-put-color newl2 6)

   (setq newl3 (vla-add *aclay* "C-test-3"))

   (vla-put-color newl3 4)

   (setq newl4 (vla-add *aclay* "Defpoints"))

   (vla-put-color newl4 7)

   (setq newl5 (vla-add *aclay* "C-test-4"))

   (vla-put-color newl5 131)

   (setq newl6 (vla-add *aclay* "C-test-5"))

   (vla-put-color newl6 5)

   (setq newl7 (vla-add *aclay* "C-test-6"))

   (vla-put-color newl7 3)

   (setq newl8 (vla-add *aclay* "C-test-7"))

   (vla-put-color newl8 150)
 

 ;*************************************************************
 

   (defun savVar ()

      (setq baba (atoi (get_tile "baba")))

      (setq babc (atoi (get_tile "babc")))

      (setq babe (atoi (get_tile "babe")))

      (setq babg (atoi (get_tile "babg")))

      (setq cbspc0 0)

      (setq cbspc1 (atoi (get_tile "cbspc1")))

      (setq cbspc2 (atoi (get_tile "cbspc2")))

 

      (setq cba_list

              (list cbspc1

                    (+ cbspc1 cbspc2)

              )

      )

 

      (setq cba_list (acet-list-remove-duplicates cba_list nil))

      (setq cbalist (list cbspc2))

      (setq cbalist (vl-remove-if '(lambda (x) (zerop x)) cbalist))

 

      (setq colspc (+ 6 (* baba babe)))

      (setq rowspc (+ 6 (* babc babg)))

 

      (setq selitem0 (nth (atoi (get_tile "popup1")) prmtr1))

      (setq selitem1 (nth (atoi (get_tile "popup2")) prmtr2))

      (setq selitem2 (nth (atoi (get_tile "popup3")) prmtr3))

      (setq selitem3 (nth (atoi (get_tile "popup4")) prmtr4))

   )



;;; lists for popup boxes

   (setq prmtr1 '("T" "F"))

   (setq prmtr2 '("1" "2" "3" "4" "5" "6" "7" "8" "9" "10"))

   (setq prmtr3 '("AB4.0" "BC1.6" "AC2.0" "AD4.0"))

   (setq prmtr4 '("0.6G" "1.0G" "1.5G" "2.0G"))

 

;;; start of Dialog box information 

   (setq dcl_id (load_dialog "msam.dcl"))

   (if (not (new_dialog "msam" dcl_id))

      (exit)

   )

 

   (start_list "popup1" 3)

   (mapcar 'add_list prmtr1)

   (end_list)

   (start_list "popup2" 3)

   (mapcar 'add_list prmtr2)

   (end_list)

   (start_list "popup3" 3)
   (mapcar 'add_list prmtr3)

   (end_list)

   (start_list "popup4" 3)

   (mapcar 'add_list prmtr4)

   (end_list)

   (setq selitem0 (car prmtr1)

         selitem1 (car prmtr2)

         selitem2 (car prmtr3)

         selitem3 (car prmtr4)
         etest1   (strcat "CATALOG NUMBER = " selitem0 "-" selitem1 "-" selitem2 "-" selitem3 " ")
   )

 

   (set_tile "rb1" "1")

   (set_tile "etest1" etest1)

 

   (action_tile "popup1" "(setq tmp selitem0)

                          (setq selitem0 (nth (atoi (get_tile \"popup1\")) prmtr1))

                          (set_tile \"etest1\" (vl-string-subst selitem0 tmp etest1 17))

                          (setq etest1 (get_tile \"etest1\"))")

 

   (action_tile "popup2" "(setq tmp selitem1)

                          (setq selitem1 (nth (atoi (get_tile \"popup2\")) prmtr2))

                          (set_tile \"etest1\" (vl-string-subst selitem1 tmp  etest1 17))

                          (setq etest1 (get_tile \"etest1\"))")

 

   (action_tile "popup3" "(setq tmp selitem2)

                          (setq selitem2 (nth (atoi (get_tile \"popup3\")) prmtr3))

                          (set_tile \"etest1\" (vl-string-subst selitem2 tmp  etest1 17))

                          (setq etest1 (get_tile \"etest1\"))")

 

   (action_tile "popup4" "(setq tmp selitem3)

                          (setq selitem3 (nth (atoi (get_tile \"popup4\")) prmtr4))

                          (set_tile \"etest1\" (vl-string-subst selitem3 tmp  etest1 17))

                          (setq etest1 (get_tile \"etest1\"))")

 

   (action_tile "debox" "(cond

                            ((= $value \"rb1\")

                                 (setq etest1 (strcat \"CATALOG NUMBER = \" selitem0 \"-\" selitem1 \"-\" selitem2 \"-\" selitem3 \" \")))

                            ((= $value \"rb2\")

                                 (setq etest1 (strcat \"CATALOG NUMBER = \" selitem1 \"-\" selitem0 \"-\" selitem3 \"-\" selitem2 \" \")))

                         )

                         (set_tile \"etest1\" etest1)")

 

   (action_tile "cancel" "(setq ddiag 1) (done_dialog)")


   (action_tile "accept" "(setq Dbox (get_tile \"debox\"))

                          (savVar)

                          (setq ddiag 2)

                         (done_dialog)"

   )

 
   (start_dialog)
   (unload_dialog dcl_id)

 



   (if (= ddiag 2)

      (cond

         ((= dbox "rb1") (abc))

         ((= dbox "rb2") (efg))
      )

   )



   (princ)

)


//DCL CODING STARTS HERE

msam : dialog {
label = "test";
: radio_row {
key = "debox";
: radio_button {
        key = "rb1" ;
        label = "abc" ;
      value = "1" ;
      }
: radio_button {
key = "rb2" ;
      label = "efg" ;
        }
       

//******************************************
//******************************************

: row {
: column {
: boxed_column {
label = "Top Test";
fixed_width = true;
alignment = centered;
: row {
: text {label = "test1";}
: edit_box {key = "cbspc1"; width = 8;
fixed_width = true; value = "0";}
//
}
: row {
: text {label = "test2";}
: edit_box {key = "cbspc2"; width = 8;
fixed_width = true; value = "0";}
//
}
}

//********************************************

: row {
: boxed_column {
label = "Second test";
fixed_width = true;
alignment = centered;
: row {
: text {label = "B test";}
: edit_box {key = "abab2"; width = 8;
fixed_width = true; value = "0.0";}
//
}
: row {
: text {label = "B test 2";}
: edit_box {key = "abac3"; width = 8;
fixed_width = true; value = "0.00";}
//
}
}
}
}

//********************************************
//********************************************

: boxed_column {
label = "C test";
fixed_width = true;
alignment = centered;
:row {
: text {label = "Ctest1";} //give it a label
        : popup_list { //define popup list
key = "popup1"; //give it a name
width = 10; //fix the width
fixed_width = true;
      value = 0;} //initial value
      }
:row {
: text {label = "Ctest2";} //give it a label
: popup_list { //define popup list
key = "popup2"; //give it a name
width = 10; //fix the width
fixed_width = true;
      value = 0;} //initial value
        } //end list
:row {
: text {label = "Ctest3";} //give it a label
: popup_list { //define popup list
key = "popup3"; //give it a name
width = 10; //fix the width
fixed_width = true;
      value = 0;} //initial value
        } //end list
        :row {
: text {label = "Ctest4";} //give it a label
: popup_list { //define popup list
key = "popup4"; //give it a name
width = 10; //fix the width
fixed_width = true;
      value = 0;} //initial value
        } //end list
        } //end boxed column

//*********************************************
//*********************************************
       
        : boxed_column {
label = "D test";
fixed_width = true; // fix the width
  alignment = centered; // align left       
: row {
: text {label = "Dtest1";}
: edit_box {key = "baba"; width = 5;
fixed_width = true; value = "4.0"; initial_focus = true;}
//
}
: row {
: text {label = "Dtest2";}
: edit_box {key = "babc"; width = 5;
fixed_width = true; value = "2.0";}
//
}
: row {
: text { label = "Dtest3";}
: edit_box {key = "babe"; width = 5;
fixed_width = true; value = "5";}
//
}
: row {
: text { label = "Dtest4";}
: edit_box {key = "babg"; width = 5;
fixed_width = true; value = "4";}
//
}
}
}

: boxed_column {
label = "Etest: ";
: text  {key = "etest1"; width = 66;
fixed_width = true; alignment = centered; value = "?";}
//
}

: row {

      ok_cancel;
        }
      }


« Last Edit: December 01, 2015, 11:00:12 AM by Denzuki »