I am working on my first application in maxscript. I hope you dont mind I will use this thread to ask little (probably stupid) questions.
First one :
For some reason he is only outputting “Diffuse Updated” while he also has to print the other also. But the ignores the other folowing if statements. I guess its a stupid mistake but I can’t find it.
if (matchPattern imgFileName_Part3 pattern:"1*" ) then
(
if( matchPattern imgFileName_Part2 pattern:"D1*") then
(
print "Diffuse Updated"------------------------------------------
)
if( matchPattern imgFileName_Part2 pattern:"N1*") then
(
print "Normal Updated"------------------------------------------
)
if( matchPattern imgFileName_Part2 pattern:"S1*") then
(
print "Specular Updated"------------------------------------------
)
if( matchPattern imgFileName_Part2 pattern:"O1*") then
(
print "Opacity Updated"------------------------------------------
)
print "blabla"
)
else
(
btn_File.text = "Wrong File"
)
)
It would helpful to know some test values you are using for imgFilename_Part2. In the script snippet you’ve posted, the matchPattern can only be true for one of the if-statements. It sounds as if you may be expecting some other result, but I can’t be certain.
We’ll there you go. For example, matchPattern imgFileName_Part2 “N1*” will only match the string if it begins with N1. matchPattern imgFileName_Part2 “N1”
matchPattern imgFileName_Part2 pattern:"??N1*" would also work.
The * wildcard stands in for any number of characters in part of a string. The ? wildcard stands in for a single character in a string.
it sounds like you may want to use findstring instead of matchpattern.
ie: if ((findstring filename “d1”) != undefined) then
reads as “if the variable filename contains the substring “d1” then…”
findString returns either the index of the search string within the string, or undefined if it cannot find the search string. IIRC matchpattern is faster, but it doesn’t sound like that’s a big concern… findstring was just always easier for me to grok.