Jump to content

Request a variable and set a new variable with If function


Manuel_Kunde

Recommended Posts

Hi, I'm trying to query the variable "Weight" and if it has the content "50" I want to define a new variable: "Stamp" with the content "internal".

Is WCMATCH the right command for this?

 

(if (= wcmatch Weight "50") (progn (setq stamp "intern")))
  
  (princ)

 

Edited by Manuel_Kunde
Link to comment
Share on other sites

Put a * either side of the 50 (for a wildcard search) and take out the = and it should work I think

 

(if (wcmatch Weight "*50*")
  (progn (setq stamp "intern"))
)

 

Link to comment
Share on other sites

20 minutes ago, Steven P said:

Put a * either side of the 50 (for a wildcard search) and take out the = and it should work I think

 


(if (wcmatch Weight "*50*")
  (progn (setq stamp "intern"))
)

 

 

This works, thanks. 

  • Like 1
Link to comment
Share on other sites

For an exact match, you can use:

 

(if (= weight "50") (setq stamp "intern"))

 

Note that the progn expression is not required as you are only supplying a single expression as the 'then' argument for the if statement.

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