Jump to content

Recommended Posts

Posted

Hi!

 

I have a lisp to write mtext but before its executed the user can choose from a different scales with a popupmenu which pops up.

The user can also choose another which can be a number maybe like 123348 etc ... etc ..

 

What I miss there, I cannot exactly do it is to get into this popup menu a text "Cancel" and if the user choose it, it cancels the command before proceeding making an mtext.

 

here is the source of mine popup.lsp I do not have the "CANCEL" in it .. I just wrote it to have it in this example.

You need DOSlib

 

OR WHen hit ESC it dissepears ... I cant do it now. I have to choose the scale

 

(Defun PopupScale ()
 (setq x (list "Choose scale:"       ""  "1:1"     "1:2"
 "1:5"    "1:10"     "1:20"  "1:50"     "1:100"
 "1:200"    "1:500"    ""  "Another..."  [color=red][b]"Cancel"[/b][/color]
       )
ChoosedScale nil
scale nil
controlscale
 nil
 )
 (while (or (not ChoosedScale) (= ChoosedScale 0))
   (setq ChoosedScale (dos_popupmenu x))
 )
 (IF (= ChoosedScale (- (length x) 3)) 
   (while (not scale)
     (setq scale (dos_getstring "Choose another:" "Write a custom scale:"))
     (IF (wcmatch scale "*=*,*:*")
(setq scale (substr scale 3))
     )
     (setq controlscale (wcmatch scale "*@*"))

     (IF controlscale
(Alert "You have typed a wrong number. \nCould be a letter"
)
     ) 
   )
   (IF (not (= ChoosedScale (- (length x) 4))) ; last scale
     (setq scale (substr (nth (1+ ChoosedScale) x) 3))
     (setq scale (substr (nth (- (length x) 3) x)
    3
   )
     )
   )
 )
)

Posted

Its dos_popupmenu ...

 

Hmm .. its maybe impossible .... couldnt find anything in DOSLib help.

Posted
Its dos_popupmenu ...

 

Hmm .. its maybe impossible .... couldnt find anything in DOSLib help.

 

nothing is impossible. it's nothing with the doslib functions, you just have to stop the program from proceeding if all required variables have not been filled.

 

you should also use cond in lieu of several if statements. here's a modified version of what you had, i put the skeleton together, just add the meat & potatoes. oh, and instead of starting a routine by nilling out the variables, just localize them to begin with....

(defun PopupMenu (/ scalelist ChosenScale scale)
 (setq scalelist (list "Choose scale:"         ""          "1:1"
                       "1:2"       "1:5"       "1:10"      "1:20"
                       "1:50"      "1:100"     "1:200"     "1:500"
                       ""          "Another..."            "Cancel"
                      ) ;_ list
 ) ;_ setq
 (while
   (or (not ChosenScale)
       (= 0 ChosenScale)
   ) ;_ or
    (setq ChosenScale (dos_popupmenu scalelist))
 ) ;_ while
 (cond
   ((>= 9 ChosenScale)
    ;; a scale from list chosen
    (princ (strcat "\nYou chose: " (rtos ChosenScale)))
    ;; Do stuff here
   )
   ;; "Another..." chosen
   ((= 10 ChosenScale)
    ;; Do stuff here
    (princ (strcat "\nYou chose: " (rtos ChosenScale)))
   )
 ) ;_ cond
 (if scale
   ;; Proceed with routine
   (princ "\nLet us do more!")
   (princ "\nUser Quit")
 ) ;_ if
 (princ)
) ;_ defun

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...