Jump to content

Recommended Posts

Posted (edited)

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
Posted

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"))
)

 

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

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.

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