woodman78 Posted July 13, 2009 Share Posted July 13, 2009 Hi, I,ve been on before about this. When i run this I get a "bad function" error fot TB1,TB2,TB3,TB4. Has anybody any ideas?? I am new to this so in the plainest language possible?? Thanks. (defun C:samp4 (/ hole) ;define function (vl-load-com) (setq dcl_id (load_dialog "samp3.dcl")) ;load dialog ;not sure what you want from this, but i belive its not needed, but i do not know your varibles (if (not (new_dialog "samp3" dcl_id) ;test for dialog );not (progn (alert "Can not find your dcl file") (exit) ;exit if no dialog ) );if (action_tile "T1" "(setq hole \"TB1\")") ;*store hole type (action_tile "T2" "(setq hole \"TB2\")") ;*store hole type (action_tile "T3" "(setq hole \"TB3\")") ;*store hole type (action_tile "T4" "(setq hole \"TB4\")") ;*store hole type (action_tile "cancel" ;if cancel button pressed "(done_dialog) (setq userclick nil)" ;close dialog, set flag );action_tile (action_tile "accept" ;if O.K. pressed "(done_dialog)(setq userclick T))" ;??? Is this standard code. );action tile (start_dialog) ;start dialog (unload_dialog dcl_id) ;unload (if userclick (cond (=(hole ("TB1")) (C:ESS1500)) (=(hole ("TB2")) (C:ESS1350)) (=(hole ("TB3")) (C:ESS1200)) (=(hole ("TB4")) (C:ESS1050)) ;(t (princ "\nNothing changed.")) ;_ end of optional else condition ) ) (princ) ) (princ "\nThis loaded fine") (princ) ;;;;;;;;;;Existing Storm_Sewer 1500mm;;;;;;;;;; Start (defun c:ESS1500() (setq a "CCC_DR_1500") (if (= (tblsearch "ltype" a) nil) (command "-linetype" "l" a "acadiso.lin" "") (princ)) (graphscr) (command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "L" "CCC_DR_1500" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "" ) (command "pline" pause "width" "0.0" "0.0" pause "width" "0.0" "0.0") (setvar "cmdecho" 1) (princ) ) ;;;;;;;;;;Existing Storm_Sewer 1500mm;;;;;;;;;; End ;;;;;;;;;;Existing Storm_Sewer 1350mm;;;;;;;;;; Start (defun c:ESS1350() (setq a "CCC_DR_1350") (if (= (tblsearch "ltype" a) nil) (command "-linetype" "l" a "acadiso.lin" "") (princ)) (graphscr) (command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "L" "CCC_DR_1350" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "" ) (command "pline" pause "width" "0.0" "0.0" pause "width" "0.0" "0.0") (setvar "cmdecho" 1) (princ) ) ;;;;;;;;;;Existing Storm_Sewer 1350mm;;;;;;;;;; End ;;;;;;;;;;Existing Storm_Sewer 1200mm;;;;;;;;;; Start (defun c:ESS1200() (setq a "CCC_DR_1200") (if (= (tblsearch "ltype" a) nil) (command "-linetype" "l" a "acadiso.lin" "") (princ)) (graphscr) (command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "L" "CCC_DR_1200" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "" ) (command "pline" pause "width" "0.0" "0.0") (setvar "cmdecho" 1) (princ) ) ;;;;;;;;;;Existing Storm_Sewer 1200mm;;;;;;;;;; End ;;;;;;;;;;Existing Storm_Sewer 1050mm;;;;;;;;;; Start (defun c:ESS1050() (setq a "CCC_DR_1050") (if (= (tblsearch "ltype" a) nil) (command "-linetype" "l" a "acadiso.lin" "") (princ)) (graphscr) (command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "L" "CCC_DR_1050" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "" ) (command "pline" pause "width" "0.0" "0.0") (setvar "cmdecho" 1) (princ) ) ;;;;;;;;;;Existing Storm_Sewer 1050mm;;;;;;;;;; End samp3 : dialog { //dialog name label = "Existing Storm Sewers" ; //give it a label :boxed_radio_column { //*define radio column label = "Choose a Type" ; //*give it a label :toggle { //*define toggle key = "T1"; //*give it a name label = "Type 1"; //*give it a label } //*end toggle :toggle { //*define toggle key = "T2"; //*give it a name label = "Type 2"; //*give it a label } //*end toggle :toggle { //*define toggle key = "T3"; //*give it a name label = "Type 3"; //*give it a label } //*end toggle :toggle { //*define toggle key = "T4"; //*give it a name label = "Type 4"; //*give it a label } //*end toggle } //*end radio column ok_cancel ; //predifined OK/Cancel : row { //define row : paragraph { //define paragraph : text_part { //define text label = "Designed by BD"; //give it some text } //end text : text_part { //define more text label = "for CCC NNRDO"; //some more text } //end text } //end paragraph } //end row } //end dialog Quote Link to comment Share on other sites More sharing options...
Rob-GB Posted July 13, 2009 Share Posted July 13, 2009 Should TB1, TB2 etc be declared next to 'hole' (defun C:samp4 (/ hole TB1 TB2 TB3 [and so on]) ;define function (vl-load-com) Just a guess as am new to this too! If not am sure one of the helpful guru's will spot it. Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 13, 2009 Author Share Posted July 13, 2009 Thanks for help Rob but no joy!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 13, 2009 Share Posted July 13, 2009 The problem is here: (=(hole [b][color=Red]("TB1")[/color][/b]) (C:ESS1500)) (=(hole ("TB2")) (C:ESS1350)) (=(hole ("TB3")) (C:ESS1200)) (=(hole ("TB4")) (C:ESS1050)) "TB1" is being evaluated as a function in itself. Should be: ((= hole "TB1") Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 13, 2009 Author Share Posted July 13, 2009 Lee, no joy with that. Could you have a look again and see is there anything else please? I need to get this one up and going so i can move on with others then. Thanks. Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 13, 2009 Author Share Posted July 13, 2009 actually, i had missed one of the changes and it does now. Thanks great thanks. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted July 13, 2009 Share Posted July 13, 2009 Lee,no joy with that. Could you have a look again and see is there anything else please? I need to get this one up and going so i can move on with others then. Thanks. For one thing you are using toggle buttons for a conditional when you should be using radio_buttons. Also you have no default setting. And finally you are using two different names of the files ex:samp3.dcl & samp4.lsp. Also fix the conditional as Lee pointed out. Good Luck, The Buzzard Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted July 13, 2009 Share Posted July 13, 2009 Just to point out Toggles work independent of each other where as Radio Buttons you can only have one choice such as the conditional. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted July 13, 2009 Share Posted July 13, 2009 actually, i had missed one of the changes and it does now. Thanks great thanks. Try this: I renamed the dcl to samp4.dcl, modified the conditional, Added defaults, Added radio buttons in place of toggles. The program now selects the correct function but now is looking for a linetype which I do not have. Please try it on your system and let me know what gives. If you have the linetypes being called in this program, It should work without a problem. samp4.dcl samp4 : dialog { //*dialog name label = "Existing Storm Sewers" ; //*give it a label : boxed_radio_column { //*define radio column label = "Choose a Type" ; //*give it a label : radio_button { //*define radio_button key = "T1"; //*give it a name label = "Type 1"; //*give it a label } //*end radio_button : radio_button { //*define radio_button key = "T2"; //*give it a name label = "Type 2"; //*give it a label } //*end radio_button : radio_button { //*define radio_button key = "T3"; //*give it a name label = "Type 3"; //*give it a label } //*end radio_button : radio_button { //*define radio_button key = "T4"; //*give it a name label = "Type 4"; //*give it a label } //*end radio_button } //*end radio column ok_cancel ; //*predifined OK/Cancel : row { //*define row : paragraph { //*define paragraph : text_part { //*define text label = "Designed by BD"; //*give it some text } //*end text : text_part { //*define more text label = "for CCC NNRDO"; //*some more text } //*end text } //*end paragraph } //*end row } //*end dialog samp4.lsp (defun C:samp4 (/ hole) ;define function (setq dcl_id (load_dialog "samp4.dcl")) ;load dialog (if (not (new_dialog "samp4" dcl_id) ;test for dialog );not (progn (alert "Can not find your dcl file") (exit) ;exit if no dialog ) );if (set_tile "T1" "1") ;Set radio_button T1 as default (setq hole "TB1") ;Set variable hole to TB1 as default (action_tile "T1" "(setq hole \"TB1\")") ;*store hole type (action_tile "T2" "(setq hole \"TB2\")") ;*store hole type (action_tile "T3" "(setq hole \"TB3\")") ;*store hole type (action_tile "T4" "(setq hole \"TB4\")") ;*store hole type (action_tile "cancel" ;if cancel button pressed "(done_dialog)(setq userclick nil)" ;close dialog, set flag );action_tile (action_tile "accept" ;if O.K. pressed "(done_dialog)(setq userclick T))" ;??? Is this standard code. );action tile (start_dialog) ;start dialog (unload_dialog dcl_id) ;unload (if userclick ;When OK button is selected (cond ;And one of the following conditions apply ((= hole "TB1")(C:ESS1500)) ;If TB1 selected, Go to C:ESS1500 ((= hole "TB2")(C:ESS1350)) ;If TB2 selected, Go to C:ESS1350 ((= hole "TB3")(C:ESS1200)) ;If TB3 selected, Go to C:ESS1200 ((= hole "TB4")(C:ESS1050)) ;If TB4 selected, Go to C:ESS1050 ;(t (princ "\nNothing changed.")) ;_ end of optional else condition ) ;End cond ) ;End if (princ) ;Exit quietly ) ;End defun (princ "\nThis loaded fine") (princ) ;;;;;;;;;;Existing Storm_Sewer 1500mm;;;;;;;;;; Start (defun C:ESS1500() (setq a "CCC_DR_1500") (if (= (tblsearch "ltype" a) nil) (command "-linetype" "l" a "acadiso.lin" "") (princ)) (graphscr) (command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "L" "CCC_DR_1500" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "" ) (command "pline" pause "width" "0.0" "0.0" pause "width" "0.0" "0.0") (princ) ) ;;;;;;;;;;Existing Storm_Sewer 1500mm;;;;;;;;;; End ;;;;;;;;;;Existing Storm_Sewer 1350mm;;;;;;;;;; Start (defun C:ESS1350() (setq a "CCC_DR_1350") (if (= (tblsearch "ltype" a) nil) (command "-linetype" "l" a "acadiso.lin" "") (princ)) (graphscr) (command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "L" "CCC_DR_1350" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "" ) (command "pline" pause "width" "0.0" "0.0" pause "width" "0.0" "0.0") (princ) ) ;;;;;;;;;;Existing Storm_Sewer 1350mm;;;;;;;;;; End ;;;;;;;;;;Existing Storm_Sewer 1200mm;;;;;;;;;; Start (defun c:ESS1200() (setq a "CCC_DR_1200") (if (= (tblsearch "ltype" a) nil) (command "-linetype" "l" a "acadiso.lin" "") (princ)) (graphscr) (command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "L" "CCC_DR_1200" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "" ) (command "pline" pause "width" "0.0" "0.0") (princ) ) ;;;;;;;;;;Existing Storm_Sewer 1200mm;;;;;;;;;; End ;;;;;;;;;;Existing Storm_Sewer 1050mm;;;;;;;;;; Start (defun c:ESS1050() (setq a "CCC_DR_1050") (if (= (tblsearch "ltype" a) nil) (command "-linetype" "l" a "acadiso.lin" "") (princ)) (graphscr) (command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "L" "CCC_DR_1050" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "C" "84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "" ) (command "pline" pause "width" "0.0" "0.0") (princ) ) ;;;;;;;;;;Existing Storm_Sewer 1050mm;;;;;;;;;; End Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted July 13, 2009 Share Posted July 13, 2009 I just noticed the (vl-load-com) and it is not needed since you are not using any Visual Lisp functions. I have removed it from the above posted code. I also removed (setvar "cmdecho" "1") from each function. Why do you want to turn on command echo at this point. You are not saving any system variables to start with, So why start setting enviorment variables at the end of your code? Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 14, 2009 Author Share Posted July 14, 2009 Thanks for your help Lee Mac and Buzzard. A great help indeed. I hope to be able to move it on from here myself. Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted July 14, 2009 Share Posted July 14, 2009 Just to point out Toggles work independent of each other where as Radio Buttons you can only have one choice such as the conditional. Big man that would be my fault, I changed it from radio buttons in the other thread,because he wanted a nil value aswell, so i put in a toggle, so they no value could be selected. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted July 14, 2009 Share Posted July 14, 2009 Big man that would be my fault, I changed it from radio buttons in the other thread,because he wanted a nil value aswell, so i put in a toggle, so they no value could be selected. No problem flowerrobot, Since it came down to making choices the radio button was the way to go. The program also had no defaults. The main problem was the way his conditional was written. It all worked out. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted July 14, 2009 Share Posted July 14, 2009 Thanks for your help Lee Mac and Buzzard. A great help indeed. I hope to be able to move it on from here myself. Glad it worked out. I could not test it further since I did not have the linetypes the program was calling for. After reviewing the operation at that point it seemed that if they were present on my system, I saw no reason as to why the program would 'nt complete. Your main problem was the conditional. You still would of had problems after that anyway since you did not supply the default values. Refer to my comments in the program for this. Anyway Good Luck, Any further help just ask. The Buzzard Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted July 15, 2009 Share Posted July 15, 2009 No problem flowerrobot, Since it came down to making choices the radio button was the way to go. The program also had no defaults. The main problem was the way his conditional was written. It all worked out. Yer mate just wanted to place where blame is due, Yer thats why i went with the toggles, so that no defult was set, hence no choice was needed, which is what i thought was ment to be an option. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted July 15, 2009 Share Posted July 15, 2009 Yer mate just wanted to place where blame is due, Yer thats why i went with the toggles, so that no defult was set, hence no choice was needed, which is what i thought was ment to be an option. flowerrobot, Placing blame is not called for. We all take our best shot at it. Regardless of what action tile is used, You still need a default value set. If the user were to start the program and not choose anything, A default value is still required so the program does not crash upon clicking enter. The program in question had four functions and only one was to be chosen. Toggles are an On/Off or Off/On call depending on how their respected defaults are set and all four toggles could have been chosen at the same time. Toggles are good for optional choices. In this case a function needed to be called if the user selected it or not. All action tiles need default settings just the same. Please do not worry over this one. The Buzzard Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted July 15, 2009 Share Posted July 15, 2009 flowerrobot, Placing blame is not called for. We all take our best shot at it. Ahh but if we do not blame our selfs, some one eles is , What you say is correct, the defult was nil, which was supported in my code however, aswell mine only allowed one toggle @ one time, which ment it worked the same as radio, but with the added function of nil. flowerrobot,Please do not worry over this one. Mate neva!, looking at stuff here is a great break from my project, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.