sadhu Posted March 8, 2010 Share Posted March 8, 2010 In the code below I have this IF like so (if (= Edit1 "") (progn (Alert "The field is empty") ([color=Red]exit[/color]))) I want to replace "exit" with something that goes back to the Edit1 box (if it is empty) for complilation and get focus there. Edit1 is in a DCL dialog. Maybe something to restart the dialog. ;-------------start dialog------------ (setq dcl_id (load_dialog "hello_sp.dcl")) ; Load the DCL file. (if (not (new_dialog "hello_sp" dcl_id)) ; Initialize the dialog. (exit) ; Exit if this doesn't ; work. ) ;------------ set values in dialog box---- (set_tile "discesa" (rtos a1 2 2)) (set_tile "masetto1" (rtos a2 2 2)) (set_tile "salita" (rtos miodist 2 2)) (set_tile "tolleranza" (rtos tolleranza 2 2)) (set_tile "orriz" (rtos d1 2 2)) (set_tile "note_" "Ricordati bracci per il Q.E. e dorsali") (set_tile "grand_dist" (rtos tot2 2 2)) (set_tile "grand_dist_" "GRAND TOTAL (SQ)") (set_tile "Text1" "Numero Braccio") (set_tile "Edit1" "") (set_tile "Text2" "Diametro Tubo [*=25]") (set_tile "Edit2" "") (set_tile "Text3" "Tipo Linea") (set_tile "Edit3" "") ; Dialog Actions (action_tile "Edit1" "(setq Edit1 $value)") (action_tile "Edit2" "(setq Edit2 $value)") (action_tile "Edit3" "(setq Edit3 $value)") ;------------ end - set values in dialog box---- (start_dialog) ; Display the dialog ; box. (if (= Edit1 "") (progn (Alert "Campo No. braccio non puo essere vuoto") (exit))) (unload_dialog dcl_id) ; Unload the DCL file. (princ) Quote Link to comment Share on other sites More sharing options...
BearDyugin Posted March 8, 2010 Share Posted March 8, 2010 (action_tile "Edit1" "(if (= (setq Edit1 $value) \"\") (progn (Alert \"The field is empty\") (mode_tile \"Edit1\" 2) ) )" ) Quote Link to comment Share on other sites More sharing options...
sadhu Posted March 8, 2010 Author Share Posted March 8, 2010 I copied your code (action_tile "Edit1" "(if (= (setq Edit1 $value) \"\") (progn (Alert \"The field is empty\") (mode_tile \"Edit1\" 2) ) )" ) and replaced (action_tile "Edit1" "(setq Edit1 $value)") I get this error in the build output. [CHECKING TEXT sq - D_30_MAS_30_TOL_20 text.lsp loading...]. ; warning: too many arguments: (ACTION_TILE "Edit1" "(if (= (setq Edit1 $value) \"\")\n (progn\n (Alert " THE ... ) .. ; Check done. Quote Link to comment Share on other sites More sharing options...
BearDyugin Posted March 9, 2010 Share Posted March 9, 2010 of course, because You have passed a slash \ which is necessary for that inverted commas " were perceived as inverted commas in a string, a part of a stringe, instead of its end [CHECKING TEXT sq - D_30_MAS_30_TOL_20 text.lsp loading...]. ; warning: too many arguments: (ACTION_TILE "Edit1" "(if (= (setq Edit1 $value) \"\")\n(progn\n (Alert \" THE ... ) .. ; Check done. Not to suffer with slashes and inverted commas and as that habitual formatting that is written in action_tile, it is possible to write down so (action_tile "Edit1" (vl-prin1-to-string (quote (if (= (setq Edit1 $value) "") (progn (Alert "The field is empty") (mode_tile "Edit1" 2) ) ) ) ) ) And for good, it is necessary on Ok to write so (action_tile "accept" (vl-prin1-to-string (quote (if Edit1 (done_dialog) (progn (Alert "The field of Edit1 is empty") (mode_tile "Edit1" 2) ) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
sadhu Posted March 9, 2010 Author Share Posted March 9, 2010 I can't get it to work. The "if" command does not notice that the edit1 is empty and the program proceeds normal. I copied this code : (action_tile "Edit1" (vl-prin1-to-string (quote (if (= (setq Edit1 $value) "") (progn (Alert "The field is empty") (mode_tile "Edit1" 2) ) ) ) ) ) and inserted it like this : ;-------------start dialog------------ (setq dcl_id (load_dialog "hello_sp.dcl")) ; Load the DCL file. (if (not (new_dialog "hello_sp" dcl_id)) ; Initialize the dialog. (exit) ; Exit if this doesn't ; work. ) ;------------ set values in dialog box---- (set_tile "discesa" (rtos a1 2 2)) (set_tile "masetto1" (rtos a2 2 2)) (set_tile "salita" (rtos miodist 2 2)) (set_tile "tolleranza" (rtos tolleranza 2 2)) (set_tile "orriz" (rtos d1 2 2)) (set_tile "note_" "Ricordati bracci per il Q.E. e dorsali") (set_tile "grand_dist" (rtos tot2 2 2)) (set_tile "grand_dist_" "GRAND TOTAL (SQ)") (set_tile "Text1" "Numero Braccio") (set_tile "Edit1" "") (set_tile "Text2" "Diametro Tubo [*=25]") (set_tile "Edit2" "") (set_tile "Text3" "Tipo Linea") (set_tile "Edit3" "") ; Dialog Actions (action_tile "Edit1" "(setq Edit1 $value)") (action_tile "Edit2" "(setq Edit2 $value)") (action_tile "Edit3" "(setq Edit3 $value)") ;------------ end - set values in dialog box---- (start_dialog) ; Display the dialog ; box. [color=Red](action_tile "Edit1" (vl-prin1-to-string (quote (if (= (setq Edit1 $value) "") (progn (Alert "The field is empty") (mode_tile "Edit1" 2) ) ) ) )[/color] [color=Red]) [/color] ;(if (= Edit1 "") ; (progn ; (Alert "Campo No. braccio non puo essere vuoto") ;(exit))) (unload_dialog dcl_id) ; Unload the DCL file. (princ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 9, 2010 Share Posted March 9, 2010 I think: (action_tile "Edit1" (vl-prin1-to-string (quote (progn (if (= (setq Edit1 $value) "") (progn (Alert "The field is empty") (mode_tile "Edit1" 2))))))) Quote Link to comment Share on other sites More sharing options...
sadhu Posted March 9, 2010 Author Share Posted March 9, 2010 Lee, I placed your code as below but "if" does not "notice" that Edit1 box is empty. Just to let you know - your code is inserted between the start dialog and unload dialog commands. (I tried it inserted before the start dialog too) like this : (setq dcl_id (load_dialog "hello_sp.dcl")) ; Load the DCL file. (if (not (new_dialog "hello_sp" dcl_id)) ; Initialize the dialog. (exit) ; Exit if this doesn't ; work. ) ;------------ set values in dialog box---- (set_tile "discesa" (rtos a1 2 2)) (set_tile "masetto1" (rtos a2 2 2)) (set_tile "salita" (rtos miodist 2 2)) (set_tile "tolleranza" (rtos tolleranza 2 2)) (set_tile "orriz" (rtos d1 2 2)) (set_tile "note_" "Ricordati bracci per il Q.E. e dorsali") (set_tile "grand_dist" (rtos tot2 2 2)) (set_tile "grand_dist_" "GRAND TOTAL (SQ)") (set_tile "Text1" "Numero Braccio") (set_tile "Edit1" "") (set_tile "Text2" "Diametro Tubo [*=25]") (set_tile "Edit2" "") (set_tile "Text3" "Tipo Linea") (set_tile "Edit3" "") ; Dialog Actions (action_tile "Edit1" "(setq Edit1 $value)") (action_tile "Edit2" "(setq Edit2 $value)") (action_tile "Edit3" "(setq Edit3 $value)") ;------------ end - set values in dialog box---- (start_dialog) ; Display the dialog box. [color=Red](action_tile "Edit1" (vl-prin1-to-string (quote (progn (if (= (setq Edit1 $value) "") (progn (Alert "The field is empty") (mode_tile "Edit1" 2)))))))[/color] ;(if (= Edit1 "") ;(progn ;(Alert "Campo No. braccio non puo essere vuoto") ;(exit))) (unload_dialog dcl_id) ; Unload the DCL file. (princ) ;(setq lay "RH MEASURE Layer" );- writes total value to drawing Layer ;(alert "Inserisci NUMERO BRACCIO / [*] DIA.TUBO 25 - TIPO LINEA ") ;(setq braccio (getstring "\nInserisci NUMERO BRACCIO / [*] DIA.TUBO 25 - TIPO LINEA :")) (and (setq pnt (getpoint "\nPunto di inserimento misura / Specify Text placement point: ")) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") ;(cons 8 lay) (cons 1 (strcat "(" Edit1 Edit2 ")" (rtos tot2 2 2) Edit3)) (cons 7 (getvar 'textstyle)) (cons 10 pnt) (cons 40 0.08) ) ;_ list ) ;_ entmakex ) ;_ and ;------------------------ ) (princ "\nType sq to run Grand Distance(sq)") (princ) Quote Link to comment Share on other sites More sharing options...
sadhu Posted March 9, 2010 Author Share Posted March 9, 2010 When I use this - it exists. (if (= Edit1 "") (progn (Alert "Campo R non puo essere vuoto") (exit) )) Quote Link to comment Share on other sites More sharing options...
BearDyugin Posted March 9, 2010 Share Posted March 9, 2010 sadhu, show DCL and LISP entirely Quote Link to comment Share on other sites More sharing options...
sadhu Posted March 9, 2010 Author Share Posted March 9, 2010 (edited) sadhu, show DCL and LISP entirely dcl : hello_sp : dialog { label = "Sadhu says"; //first box - ** srl : boxed_column { label = "** srl"; //second box - Dati di base //start line 1 : boxed_column { label = "Dati di base"; : row { : column { width = 10; fixed_width = true; : text { key = "discesa_"; label = "Discesa ";// } } : text { key = "discesa"; label = "Sanjay";//Prompt from lsp file width = 18; fixed_width_font = true; } } //spacer; //end line 1 //start line 1 bis : row { : column { width = 10; fixed_width = true; : text { key = "tolleranza_"; label = "Tolleranza ";// } } : text { key = "tolleranza"; label = "San";//Prompt from lsp file width = 18; fixed_width_font = true; } } //spacer; //end line 1 bis //start line 2 : row { : column { width = 10; fixed_width = true; : text { key = "masetto1_"; label = "Masetto_1 ";//Prompt from lsp file } } : text { key = "masetto1"; label = "jay";//Prompt from lsp file width = 18; fixed_width_font = true; } }//end line 2 } //second box - Dati di base //spacer; //third box - dati inseriti : boxed_column { label = "Dati inseriti"; //start salita inserita : row { : column { width = 10; fixed_width = true; : text { key = "Salita_"; label = "Salit�* Inserita";//Prompt from lsp file } } : text { key = "salita"; label = "";//Prompt from lsp file width = 18; fixed_width_font = true; } } //end salita inserita //start distanza orrizontale : row { : column { width = 10; fixed_width = true; : text { key = "orriz_"; label = "Dist Orrizon. ";//Prompt from lsp file } } : text { key = "orriz"; label = "";//Prompt from lsp file width = 18; fixed_width_font = true; } } //end distanza orrizontale } // end third box - dati inseriti //spacer; spacer; spacer; spacer; //start fourth box Grand : boxed_column { //start last line Grand : row { : column { width = 10; fixed_width = true; : text { key = "grand_dist_"; label = "GRAND TOTAL ";//Prompt from lsp file } } : text { key = "grand_dist"; label = "Sanjay";//Prompt from lsp file width = 18; fixed_width_font = true; } } //end last line Grand } //endt fourth box Grand //start insert numero braccio / tubo / linee : row {//< fixed_width = true; : column { width = 35; fixed_width = true; spacer; : text { key = "Text1"; label = "";//Text1$ from lsp file } } : edit_box { key = "Edit1";//Edit1$ from lsp file edit_width = 9.42; fixed_width = true; allow_accept = true; initial_focus = true; } }//> : row {//< fixed_width = true; : column { width = 35; fixed_width = true; spacer; : text { key = "Text2"; label = "";//Text2$ from lsp file } } : edit_box { key = "Edit2";//Edit2$ from lsp file edit_width = 9.42; fixed_width = true; } }//> : row {//< fixed_width = true; : column { width = 35; fixed_width = true; spacer; : text { key = "Text3"; label = "";//Text3$ from lsp file } } : edit_box { key = "Edit3";//Edit3$ from lsp file edit_width = 9.42; fixed_width = true; } }//> //end insert numero braccio / tubo / linee } //end last line Grand spacer; spacer; spacer; spacer; spacer; spacer; : button { key = "accept"; label = "OK"; is_default = true; width = 18; fixed_width = true; alignment = centered; } //end button //start note : row { : column { width = 10; fixed_width = true; : text { key = "note_"; label = "Note: ";//Prompt from lsp file width = 40; fixed_width_font = true; } } //end note spacer; spacer; spacer; spacer; } //end fourth box Grand } //end first box - rh srl lisp : in red is what I want to replace (exit) ;rev 300.1.2prad ;cumulative distance ;this routine is just like the Autocad Distance command with the ;exception that it allows you to pick more than 2 consecutive points. ;the routine will display the cumulative distance and the distance ;between the last two points picked on the command line. ; allows constants and keyboard input (defun c:sq () ;(/ Edit1 Edit2 Edit3) (setvar "cmdecho" 0) (graphscr) (setq a1 0.23 ; discesa da PT a2 0.15 ; massetto 1 a3 0.15 ; massetto 2 tolleranza 0.201 ; valore aggiunto alla misura totale Edit1 "" Edit2 "" Edit3 "") ;-------------------- (setq p1 (getpoint "\nPick start point (SQ)") p2 (getpoint p1 "\nPick next point (SQ)") d1 (distance p1 p2) prdist (strcat "\nDistance: " (rtos d1)) ) (princ prdist) (setq p3 (getpoint p2 "\nPick next point (SQ) or RETURN if done ")) (while p3 (setq d0 (distance p2 p3) d1 (+ (distance p2 p3) d1) p2 p3 prdist (strcat "\nDistance: " (rtos d0) ", Cumulative distance: " (rtos d1)) ) (princ prdist) (setq p3 (getpoint p2 "\nPick Next Point (SQ)")) ) (setq cumd (strcat "Distanza orrizontale --> " (rtos d1 2 2))) (prompt cumd) (princ) (setq miodist (getdist "\n Insert Height ")) (princ "\n The height is ") (princ (rtos miodist 2 2)) (princ) (setq tot2 (+ a1 a2 a3 tolleranza miodist d1)) (setq pcumd (strcat "Grand distance(SQ) --> " (rtos tot2 2 2))) (princ "\n --> ") (prompt pcumd) (princ) ;-------------start dialog------------ (setq dcl_id (load_dialog "hello_sp.dcl")) ; Load the DCL file. (if (not (new_dialog "hello_sp" dcl_id)) ; Initialize the dialog. (exit) ; Exit if this doesn't ; work. ) ;------------ set values in dialog box---- (set_tile "discesa" (rtos a1 2 2)) (set_tile "masetto1" (rtos a2 2 2)) (set_tile "salita" (rtos miodist 2 2)) (set_tile "tolleranza" (rtos tolleranza 2 2)) (set_tile "orriz" (rtos d1 2 2)) (set_tile "note_" "Ricordati bracci per il Q.E. e dorsali") (set_tile "grand_dist" (rtos tot2 2 2)) (set_tile "grand_dist_" "GRAND TOTAL (SQ)") (set_tile "Text1" "Numero Braccio") (set_tile "Edit1" "") (set_tile "Text2" "Diametro Tubo [*=25]") (set_tile "Edit2" "") (set_tile "Text3" "Tipo Linea") (set_tile "Edit3" "") ; Dialog Actions (action_tile "Edit1" "(setq Edit1 $value)") (action_tile "Edit2" "(setq Edit2 $value)") (action_tile "Edit3" "(setq Edit3 $value)") ;------------ end - set values in dialog box---- (start_dialog) ; Display the dialog box. [color=Red](if (= Edit1 "");(progn (Alert "Campo No. braccio non puo essere vuoto") ;(exit)))[/color] (unload_dialog dcl_id) ; Unload the DCL file. (princ) ;(setq lay "RH MEASURE Layer" );- writes total value to drawing Layer ;(alert "Inserisci NUMERO BRACCIO / [*] DIA.TUBO 25 - TIPO LINEA ") ;(setq braccio (getstring "\nInserisci NUMERO BRACCIO / [*] DIA.TUBO 25 - TIPO LINEA :")) (and (setq pnt (getpoint "\nPunto di inserimento misura / Specify Text placement point: ")) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") ;(cons 8 lay) (cons 1 (strcat "(" Edit1 Edit2 ")" (rtos tot2 2 2) Edit3)) (cons 7 (getvar 'textstyle)) (cons 10 pnt) (cons 40 0.08) ) ;_ list ) ;_ entmakex ) ;_ and ;------------------------ ) (princ "\nType sq to run Grand Distance(sq)") (princ) Edited October 10, 2012 by sadhu Quote Link to comment Share on other sites More sharing options...
BearDyugin Posted March 9, 2010 Share Posted March 9, 2010 ;rev 300.1.2prad ;cumulative distance ;this routine is just like the Autocad Distance command with the ;exception that it allows you to pick more than 2 consecutive points. ;the routine will display the cumulative distance and the distance ;between the last two points picked on the command line. ; allows constants and keyboard input (defun c:sq () ;(/ Edit1 Edit2 Edit3) (setvar "cmdecho" 0) (graphscr) (setq a1 0.23 ; discesa da PT a2 0.15 ; massetto 1 a3 0.15 ; massetto 2 tolleranza 0.201 ; valore aggiunto alla misura totale Edit1 "" Edit2 "" Edit3 "" ) ;-------------------- (setq p1 (getpoint "\nPick start point (SQ)") p2 (getpoint p1 "\nPick next point (SQ)") d1 (distance p1 p2) prdist (strcat "\nDistance: " (rtos d1)) ) (princ prdist) (setq p3 (getpoint p2 "\nPick next point (SQ) or RETURN if done ")) (while p3 (setq d0 (distance p2 p3) d1 (+ (distance p2 p3) d1) p2 p3 prdist (strcat "\nDistance: " (rtos d0) ", Cumulative distance: " (rtos d1) ) ) (princ prdist) (setq p3 (getpoint p2 "\nPick Next Point (SQ)")) ) (setq cumd (strcat "Distanza orrizontale --> " (rtos d1 2 2))) (prompt cumd) (princ) (setq miodist (getdist "\n Insert Height ")) (princ "\n The height is ") (princ (rtos miodist 2 2)) (princ) (setq tot2 (+ a1 a2 a3 tolleranza miodist d1)) (setq pcumd (strcat "Grand distance(SQ) --> " (rtos tot2 2 2))) (princ "\n --> ") (prompt pcumd) (princ) ;-------------start dialog------------ (setq dcl_id (load_dialog "hello_sp.dcl" ) ) ; Load the DCL file. (if (not (new_dialog "hello_sp" dcl_id)) ; Initialize the dialog. (exit) ; Exit if this doesn't ; work. ) ;------------ set values in dialog box---- (set_tile "discesa" (rtos a1 2 2)) (set_tile "masetto1" (rtos a2 2 2)) (set_tile "salita" (rtos miodist 2 2)) (set_tile "tolleranza" (rtos tolleranza 2 2)) (set_tile "orriz" (rtos d1 2 2)) (set_tile "note_" "Ricordati bracci per il Q.E. e dorsali") (set_tile "grand_dist" (rtos tot2 2 2)) (set_tile "grand_dist_" "GRAND TOTAL (SQ)") (set_tile "Text1" "Numero Braccio") (set_tile "Edit1" "") (set_tile "Text2" "Diametro Tubo [*=25]") (set_tile "Edit2" "") (set_tile "Text3" "Tipo Linea") (set_tile "Edit3" "") ; Dialog Actions [color="Red"](action_tile "Edit1" (vl-prin1-to-string (quote (if (= (setq Edit1 $value) "") (progn (Alert "The field is empty") (mode_tile "Edit1" 2) ) ) ) ) ) (action_tile "accept" (vl-prin1-to-string (quote (if (/= Edit1 "") (done_dialog) (progn (Alert "The field of Edit1 is empty") (mode_tile "Edit1" 2) ) ) ) ) )[/color] (action_tile "Edit2" "(setq Edit2 $value)") (action_tile "Edit3" "(setq Edit3 $value)") ;------------ end - set values in dialog box---- (start_dialog) ; Display the dialog box. (if (= Edit1 "") ;(progn (Alert "Campo No. braccio non puo essere vuoto") ) ;(exit))) (unload_dialog dcl_id) ; Unload the DCL file. (princ) ;(setq lay "RH MEASURE Layer" );- writes total value to drawing Layer ;(alert "Inserisci NUMERO BRACCIO / [*] DIA.TUBO 25 - TIPO LINEA ") ;(setq braccio (getstring "\nInserisci NUMERO BRACCIO / [*] DIA.TUBO 25 - TIPO LINEA :")) (and (setq pnt (getpoint "\nPunto di inserimento misura / Specify Text placement point: " ) ) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") ;(cons 8 lay) (cons 1 (strcat "(" Edit1 Edit2 ")" (rtos tot2 2 2) Edit3)) (cons 7 (getvar 'textstyle)) (cons 10 pnt) (cons 40 0.08) ) ;_ list ) ;_ entmakex ) ;_ and ;------------------------ ) (princ "\nType sq to run Grand Distance(sq)") (princ) Quote Link to comment Share on other sites More sharing options...
BearDyugin Posted March 9, 2010 Share Posted March 9, 2010 Quote Link to comment Share on other sites More sharing options...
sadhu Posted March 9, 2010 Author Share Posted March 9, 2010 Thanks Geo. That's exactly how I wanted it work. Evidently I did not use both the code blocks that you had uploaded. Quote Link to comment Share on other sites More sharing options...
sadhu Posted March 9, 2010 Author Share Posted March 9, 2010 How can I set focus to edit1 box when the dialog box opens for input? Quote Link to comment Share on other sites More sharing options...
BearDyugin Posted March 9, 2010 Share Posted March 9, 2010 How can I set focus to edit1 box when the dialog box opens for input? [quote name=help ]mode_tile Sets the mode of a dialog box tile (mode_tile key mode) Arguments key A string that specifies the tile. The key argument is case-sensitive. mode An integer that can be one of the following: 0 Enable tile 1 Disable tile 2 Set focus to tile 3 Select edit box contents 4 Flip image highlighting on or off Return Values nil ... (set_tile "Edit3" "") [b][color="Red"](mode_tile "Edit1" 2)[/color][/b] ; Dialog Actions ... Quote Link to comment Share on other sites More sharing options...
sadhu Posted March 9, 2010 Author Share Posted March 9, 2010 Thanks again Geo .It works. This may sound dumb but actually I did read help and tried to work it out -- inserting mode_tile inside action_tile etc. etc. #@#@ and couldn't find a way out and got "LOST" (how I wish I was on that island ...). Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 9, 2010 Share Posted March 9, 2010 Glad you got it sorted in the end Sadhu - I didn't have to time today to help further - nice one Geo 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.