Date:  11/13/2006 04:08:35 AM Msg ID:  003210
From:  Gia Luc Thread:  003210
Subject:  Where to place FUNCTION...RETURN
If I try the following, I get a blank page (no html at all).  Foxweb does not generate an error, and everything seems to run correctly :

 <%
lcMessage = "Hello"
lcMessage = message_change(lcMessage)

FUNCTION message_change
LPARAMETERS lcString
lcString = lcString + " World"
RETURN lcString
ENDFUNC
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<%=lcMessage%>

<body bgcolor="#FFFFFF" text="#000000">

</body>
</html>

If I move the FUNCTION...ENDFUNC to the end, just after the closing body and html tags, the script runs correctly i.e. it returns "Hello World" in the browser :

 <%
lcMessage = "Hello"
lcMessage = message_change(lcMessage)
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<%=lcMessage%>

<body bgcolor="#FFFFFF" text="#000000">

</body>
<%
FUNCTION message_change
LPARAMETERS lcString
lcString = lcString + " World"
RETURN lcString
ENDFUNC
%>
</html>

I'm only guessing, but it seems that in the first example, the script stops executing completely when the RETURN statement is reached.

The second example is essentially the same code, only with the FUNCTION block being moved to the end of the page.  Yet it runs fine. 

Is this normal, is there some rule about where to place FUNCTION...RETURN ENDFUNC ?  Have I missed something in the documentation ?

Thanks for your help.

Gia