PDA

View Full Version : Scripting Q>> Wildcard not working .....


solagratia77
02-17-2007, 09:29 AM
Here I am with another Scripting question.

SYMPTOM>>
The following script works OK
if I don't use any wildcard.
But when I use * (on the 4th line)
it just ignores it.

BRIEF>>
I have a lens shader named 'Lens_Effects1'
on a Camera on Viewport-B
And I would like to delete it using
Lens_Effects*
(I just put temp logmessage for now)


set oCam = GetViewCamera(1)

set oKam = oCam.Shaders

for each oFound in oKam

If oFound.name = "Lens_Effects*" then

logmessage "Wildcard working"

else

logmessage "Try again"

end if

next

Please tell me what I am doing wrong
I would very much appreciate any help on this.

Thank you in advance !!

-J

Rens
02-18-2007, 11:22 PM
Try this instead:


set oCam = GetViewCamera(1)
set oKam = oCam.Shaders

for each oFound in oKam

If ( StringSearch (oFound.name, "Lens_Effects") ) = 0 then

logmessage "StringSearch working"

else

logmessage "Try again"

end if

next

This has the same effect as "Lens_Effects*" would have. If you would like something like "*Lens_Effects*" instead then replace with the line below. (StringSearch returns the position in the target string, -1 means nothing was found.)



If ( StringSearch (oFound.name, "Lens_Effects") ) > -1 then

solagratia77
02-19-2007, 05:58 AM
Thank you so much... Rens!
It is really great to learn Basics like this.

Well like I have mentioned many times,
my programming skill is no more than
copy-paste-edit.

So my understanding of very basic things
like this is very minimal.

Please recommend me a book, or preferably
a website where I can get these basics.

And thanks again for the code.

Thank you

-J
SolaGratia

Rens
02-19-2007, 12:04 PM
You're welcome. I'm no scripting expert myself but whenever I need to know something I look in the SDK guides (under Help) or Google it. You can find alot of stuff about the basics of VBScript on the web, shouldn't be too hard to find.
There are tons of example scripts to be found in the SDK guide as well.

Good luck!

solagratia77
02-19-2007, 05:54 PM
.....tons of example scripts to be found in the SDK guide as well.

Yes, that's where I start my scripting from.
Thanks Rens!

CGTalk Moderation
02-19-2007, 05:54 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.