Jump to content

wcmatch by file extension


jnky

Recommended Posts

Hi all,

Im trying to create a variable when an existing variable has a certain file extension associated with it.

 

This is the code

 

(if (wcmatch (strcase plotstyle) "*.stb")
(setq stbctb "White_200")
)

 

I have been successful with the following code but ultimately I need the above to work.

 

(if (wcmatch (strcase plotstyle) "MR*")
(setq stbctb "White_200")
)

 

Thanks in advance

Link to comment
Share on other sites

It seems to load but stbctb = nil when using the extension, If I use mr* stbctb = White_200....

The file associated with 'plotstyle' is "MR_filename.stb" the MR is common but if users create another plotstyle prefixed with MR then it will fail.

Link to comment
Share on other sites

What BIGAL pointed is that you should pay attention to STRCASE function's behavior; using it without the second argument set to T, it will return the string as uppercase, not lower case as expected by your comparison.

(wcmatch (strcase "test.stb")     "*.stb")   ;nil
(wcmatch (strcase "test.stb")     "*.STB")   ;T

(wcmatch (strcase "test.stb" nil) "*.stb")   ;nil
(wcmatch (strcase "test.stb" nil) "*.STB")   ;T

(wcmatch (strcase "test.stb" T)   "*.stb")   ;T
(wcmatch (strcase "test.stb" T)   "*.STB")   ;nil

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