Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAWK fatal error: "return outside function body"

Status
Not open for further replies.

calabrra

Technical User
Sep 16, 2003
14
US
Greetings,

I'm running the ported mawk version 1.3.3 under Win 2K Pro, and am getting the fatal error message:

"(Source) Line nnn: Return outside function body."

for all functions with a "return" statement. Strangely, I don't get any errors when interpreting the exact same code with awk95.exe and gawk.exe.

Can you determine what is wrong?

Thanks,
-Bob

Sample code:

###################################################
func qword_to_double (qword, mantissa, exponent) {
###################################################

ifunc++;

#Convert a quadruple hex word (64 bit) value to double
#precision IEEE floating point.

#First, convert to binary
qwordbin = hex2bin(qword);

#Extract sign bit
sgn = substr(dwordbin, 1, 1) == "1" ? -1 : 1;

#Extract exponent
exponent = bin2uint( substr(qwordbin, 2, 11) );

#Extract mantissa
mantissa = bin2uint( substr(qwordbin, 13, 52) ) / 2^52;

#print "Hex to Double:\t", qword "\s", qwordbin "\s", length(qwordbin) "\s", sgn "\s", expbin "\s", mantbin "\s", exponent "\s", mantissa "\n" > "DPDiag.txt";

#Put it all together and return ...
return (sgn * 2^(exponent - 1023) * (1.0 + mantissa) );

}
 
I found the solution thanks to Mike Brennan:

Change "func" to "function".

-Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top