PDA

View Full Version : Cannot convert data of type string[] to type string...


playmesumch00ns
03-19-2003, 04:42 PM
I've got this error loads of times on other things but never been able to work it out, now it's just getting to be a pain in the arse. The procedure looks like this:


global proc nprAddLayer()
{
$sel = `ls -sl`;

for ($s in $sel)
{
string $nt = `nodeType $s`;

switch ($nt)
{
case "mesh":
nprAddLayerToObject($s);
break;

case "transform":
select $s;
pickWalk -d down;
$ns = `ls -sl`;
string $nst = `nodeType $ns[0]`;
if ($nst == "mesh")
{
nprAddLayerToObject($ns);
break;
}
else
{
error("Please select either a mesh or its tranform");
break;
}

default:
error("Please select either a mesh or its tranform");
break;

}
}
}


now I get the "Error: Cannot convert data of type string[] to type string" alternately when I run the proc, i.e first time it doesn't work, so try again straight away and it works. Try again straight away and it doesn't etc etc.

Can someone please tell me what's going on here? Thanks:thumbsup:

X-Tender
03-19-2003, 05:00 PM
try this .. change

string $nt = `nodeType $s`;
to
string []$nt = `nodeType $s`;

and

$ns = `ls -sl`;

to

$ns[] = `ls -sl`;

playmesumch00ns
03-19-2003, 05:04 PM
Thanks X-Tender! Sure enough it was the `ls -sl` ones. Nice one!:beer:

CGTalk Moderation
01-14-2006, 04:00 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.