Error: This procedure has no return value


#1

Why is it giving me this error:“This procedure has no return value”. I want to store the name of the curve that is created from this proc in a variable. How is that possible?

global proc drawCurve(){
select -hi;
string $sel[] = ls -sl -fl;
int $noOfJnts = size($sel);
string $startJnt = $sel[0];
string $endJnt = $sel[$noOfJnts-1];
string $command = “curve”;
for($each in $sel){
vector $pos = xform -q -t -ws $each;
$command = $command+ "-p " + $pos + “”;
}
eval($command);
string $curve = ls -sl;
return $curve;
}
Thanks.


#2

you need to add the return type in the procedure definition

global proc string drawCurve(){

}


#3

to elaborate on what rgkovach123 said:

if you return a string you have to define string in your global proc definition

global proc string drawCurve(){
//code//
return $curve;
}

if its a string array, or a float, etc. you define it as such:

global proc string[] drawCurve(){
//code//
return $curve;
}

global proc float drawCurve(){
//code//
return $curve;
}

Here is the info direct from ACCAD’s site:

Procedures that return a value (the MSMA book calls this a function):

Put a data type for the returned value after the “proc” keyword.
You must then include the “return” command somewhere in the procedure.

 proc float myProc( float $input ) {
      float $squared = $input * $input;
      return $squared;
 }

If you call this procedure, you can get back the result:

float $squaredResult = myProc( 6 );