String to Int
Does anyone know if there is a way to convert a string to an int or a float.
Example: string $mystring = "15"; int $myint = ($mystring - 1); print $myint; Maya doesn't execute this script because $mystring doesn't really have a int value. In BASIC I think this concept would be written as: Dim mystring As string = "15" Dim myint As integer = (val(mystring) - 1) MsgBox(myint) The VAL function works in BASIC but it won't work in MEL. Of course it doesn't seem like MEL hasa VAL function but is there an alternative? |
you're talking about casting.
you can cast a string like this: string $strVal = "150000"; int $intVal = (int)$strVal; float $floatVal = (float)$strVal; and you can go the other way too: int $intVal = 1545; string $strVal = (string)$intVal; :ninja: A |
Whoa thanks a bunch. Never thought there would be a way for this. Couldn't find anything in the reference commands or anything.
:beer: You're Awsome:beer: |
no problem. Casting is common in many programming languages.
:ninja: A |
All times are GMT. The time now is 08:24 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018