(02-08-2013, 08:22 PM)oort Wrote: Texname is the variable that gets assigned a name (w_default_Bronze_1 or w_default_Bronze_2). I need to check to see if I am working with w_default_Bronze_1 or if I am working with w_default_Bronze_2. I need to know this because they have to be handled differently when exporting them for YafaRay.Probably someone could put a different code - it always possible use different ways - I'll left two that works.
This one will check for fail (but, I don't think you need to check if is number, since you have formated the string before):
Code:
Tokens=string:tokens(Texname,"_"),
Num=lists:last(Tokens),
case string:to_integer(Num) of
{error, _} -> io:format("Conversion error\n",[]);
{1, _} -> io:format("Item 1 selected\n",[]);
{2, _} -> io:format("Item 2 selected\n",[])
end,
This can crash Wings if you can get an invalid number to Num:
Code:
Tokens=string:tokens(Texname,"_"),
Num=lists:last(Tokens),
case list_to_integer(Num) of
1 -> io:format("Item 1 selected\n",[]);
2 -> io:format("Item 2 selected\n",[]);
N -> io:format("Item ~p selected\n",[N])
end,