Date:  11/13/2006 06:50:50 AM Msg ID:  003212
From:  FoxWeb Support Thread:  003210
Subject:  Re: Where to place FUNCTION...RETURN
FoxWeb converts fwx scripts to regular prg files.  Execution starts from the top of the file and continues until the end of the file, or until one of the following statements is encountered:  RETURN, FUNCTION, ENDFUNC, PROCEDURE, ENDPROC.  This means that all function code must be at the end of the file.
 
By the way, your code seems to be incorrect.  The <%=lcMessage%> should be part of the HTML body, so it should be between the opening and closing BODY elements.

FoxWeb Support Team
support@foxweb.com email

Sent by Gia Luc on 11/13/2006 04:08:35 AM:
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