Weird formatting problem

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2013   #1
Weird formatting problem

global proc memoryAdd(string $field)
{
	string $evalString = eval("float $temp = " + `optionVar -q memOptVar`);
	optionVar -stringValue "memOptVar" $evalString;
}

global proc memorySub(string $field)
{
	string $evalString = eval("float $temp = " - `optionVar -q memOptVar`);
	optionVar -stringValue "memOptVar" $evalString;
}
// Error: Line 9.71: Cannot mix string and numeric data types in arithmetic expressions.

...which is funny because these procedures are identical. The only difference is the plus and minus signs in the eval -statement
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 07 July 2013   #2
I think its because eval is expecting a string argument. In strings + is the concatenation operator. In a string context, - means nothing, so your 2nd proc fails.

Try:
global proc memorySub(string $field)
  {
  	string $evalString = eval("float $temp = -" + `optionVar -q memOptVar`);
  	optionVar -stringValue "memOptVar" $evalString;
  }

Except:
I have a feeling that will fail if the optionVar returns a negative number. Maybe you have to do:
global proc memorySub(string $field)
 {
 	string $evalString = eval("float $temp = -1*" + `optionVar -q memOptVar`);
 	optionVar -stringValue "memOptVar" $evalString;
 }


Better still, just use a float optionVar
optionVar -fv  "memOptVar" (-1*`optionVar -q memOptVar`);

David
__________________
http://www.djx.com.au

Last edited by djx : 07 July 2013 at 12:24 PM. Reason: an after thought
 
Old 07 July 2013   #3
Thanks a bunch - got it working!
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 07 July 2013   #4
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 11:48 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.