QUOTE(andylt1 @ 01/02/08, 05:58 PM) [snapback]279016[/snapback]
can any one explain why this is? why will maya only read this if it is a string?
Because it needs to know where it starts and ends. Its a syntax error otherwise the parser cant know if your code should be parsed down to the existing line of code or not.
for example print ls -sl
is valid code but print "ls -sl
" is totaly different piece of meaning. See nothing says the input cant come form a piece of code. Likewise print foobar; is valid but print foobar bar; isnt, because parser sees it as 3 words and expects only 2 again print "foobar bar"; works right because whats in "" is seen as one parse word.
Also your proc is a bit off proc alt_createFaceAttribute (string $passedText), wont work on long run. Define it global.
Sure it works NOW but thats just because your running it in the script editor wich by design is GLOBAL but wen you encapsulate this script into a file itn olonger works. Why, simply because the procedure has time to vanish form the memory by the time the main code finishes. because local procedures wanish with the code.
code is code it don't linger about just because it builds gui, it just builds it and goes away.
PS: dont rely on lines like this
CODE
textField uiTextField;
button -l "create atribute" -c "alt_createFaceAttribute (textField -q -text uiTextField
)";
do:
CODE
$inputText = textField uiTextField
;
button -l "create atribute" -c ("alt_createFaceAttribute (textField -q -text "+ $inputText+"
)")
;
because textField uiTextField isn't always named uiTextField because maya never overwrites names so it might come back as uiTextField2. And the thing is you can never know what somebody else does to your code on the fly.
PPS: a code parser is juts like a train it goes ahead and splits things with certain rules and does not THINK anything space just happens to be one word divisor and
return grouping () grouping {} scope/block grouping name() proc grouping ; line grouing separator. If it happens to fit the splitting rules, its okay for the next phase thet tries to make some sense of it all. Henace the print foobar works but print foobar bar dont, because the first passes to the sensmekaing part wich sees something that isnt anything else so it must be a string.