Jump to content

Problems with COND


Andrew1979

Recommended Posts

I am having trouble with the cond function.

I am trying to get a number from a text file to evaluate. If the text file says 0, an alert will say evaluation expired. If not, the program will continue. Only problem is, the function doesn't work. Any ideas?

The problem is, the way the code currently is, the alert always displays no matter what number is in the text file.

 

 

(defun checkcount ()

(setq count (atoi Evaluation))

(cond

((= count 0)(alert "Evaluation Expired" ))

((>= count 1)

(getVariables-Elevation-WDE)

(getInput-Elevation-WDE)

(setVariables-Elevation-WDE)

(Offset-Elevation-WDE)

(layers)

(processInput-Elevation-WDE)

(DoorNumber-Elevation-WDE)

))

)

Link to comment
Share on other sites

The evaluation is correct; seems that the issue is with the value stored in Evaluation variable - should be a string ("0" or "1"):

(and (eq (type Evaluation) 'STR)
    (member Evaluation '("0" "1")))

Please edit your post and required code tags.

Link to comment
Share on other sites

I would suggest

;;at you main code
(if (and (= (type Evaluation) 'STR)
 (setq Evaluation (read Evaluation))
 (= (type Evaluation) 'INT)
   );; and
 (checkcount Evaluation)
 (prompt "\nWrong Evaluation TYPE!")
);; if

;; usage
;; (checkcount Evaluation)
;; Evaluation as an integer
(defun checkcount (count)
(cond
((= count 0) (alert "Evaluation Expired" ))
((> count 0)
(getVariables-Elevation-WDE) 
(getInput-Elevation-WDE)
(setVariables-Elevation-WDE)
(Offset-Elevation-WDE)
(layers)
(processInput-Elevation-WDE)
(DoorNumber-Elevation-WDE)
)
);; cond 
);; defun

 

HTH

Henrique

Edited by hmsilva
Link to comment
Share on other sites

Henrique, please remember that ATOI will always return an integer (even if a non-numerical string was supplied as argument), so that type validation is superfluous.

Would be better to validate for nil, case when ATOI will raise an error.

Link to comment
Share on other sites

Henrique, please remember that ATOI will always return an integer (even if a non-numerical string was supplied as argument), so that type validation is superfluous.

Would be better to validate for nil, case when ATOI will raise an error.

Mircea,

you'r correct, my bad...:oops:

I did mod my previous code to READ to test for an INT.

Thank you

 

Henrique

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