Jump to content

Values needed, Enter ignore and run normally.


Tharwat

Recommended Posts

Hi,

Suppose that user pressed enter instead of giving a value. How could I let the program keep on running and return only values that are given from user.

for example:

(setq pcs1 (getdist "\nLength of First Peice: ")) ;suppose any number

(setq pcs2 (getdist "\nLength of Second Peice: ")) ;suppose

(setq pcs3 (getdist "\nLength of Third Peice: ")) ; suppose

 

How to get only the giving values and running the program normally . ..?

 

Many Thanks.

 

Tharwat

Link to comment
Share on other sites

Check the INITGET statement, will allow to constrain user answer and compare that answer with nil - this is returned when is hit instead of an input.

 

Regards,

Link to comment
Share on other sites

Thanks msasu.

All (initget) values are with not allowed as following,

Establishes limitations on the user responses allowed by the next get- function
(initget 1) null input not allowed ("null input" means 'Enter' by itself)
(initget 2) 0 input not allowed
(initget 3) null input and 0 input not allowed (3 = 1 + 2)
(initget 4) negative values not allowed
(initget 5) null input and negative values not allowed (5 = 1 + 4)
(initget 6) 0 input and negative values not allowed (6 = 2 + 4)
(initget 7) null input, 0 input, and negative values not allowed (7 = 1 + 2 + 4)
(initget  cancels limits check
(initget 16) (not used)
(initget 32) causes get- functions that include a base point to display a rubber band cursor or window that is highlighted rather than solid
(initget 64) Z coordinate not allowed in next getdist function
(initget 128) allows arbitrary input (accepts any "key word")
(initget "A B C") allows the user to enter "A" "B" "C" "a" "b" or "c" in response to the next get- function (in addition, of course, to the possibility of entering an integer if the next get- function is getint, a real if it is getreal, etc.) Subsequent programming must be set up to handle these strings.

 

I cloud not find something allowed.

 

Regards,

Tharwat

Link to comment
Share on other sites

Maybe an IF statement could be used for the test

 

There are probably a few ways of doing it. Just a sample

 

(if (setq Input (getdist "\nLength of First Peice: " ))(setq pcs1 Input))
(if (setq Input (getdist "\nLength of Second Peice: "))(setq pcs2 Input))
(if (setq Input (getdist "\nLength of Third Peice: " ))(setq pcs3 Input))

 

Or if you would like to store a default

 


(or pcs1 (setq pcs1 10.0))

(if
 (setq Input (getdist (strcat "\nLength of First Peice [" (rtos  pcs1) "] : " )))
 (setq pcs1 Input))

Link to comment
Share on other sites

Thank you sooooooo much jammie :)

 

Both of proposals were Wonderful... and in particular the second one which is saves the value.

 

Thanks again and again .

 

With all my respects

 

Tharwat

Link to comment
Share on other sites

Two more examples:

 

(setq pcs1 (cond ((getdist "\nLength of First Peice <10.0>: "))
                (10.0)
          )
)

 

(setq *pcs1* (cond ((getdist (strcat "\nLength of First Peice <"
                                    (rtos (cond (*pcs1*)
                                                ((setq *pcs1* 10.0))
                                          )
                                    )
                                    ">: "
                            )
                   )
                  )
                  (*pcs1*)
            )
)

Link to comment
Share on other sites

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...