Kbase P125964: Cannot call functions in library from output-headers
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  9/20/2007 |
|
Status: Unverified
FACT(s) (Environment):
All Supported Operating Systems
WebSpeed Versions
SYMPTOM(s):
Could not evaluate the expression describing the context of external function '<function>'. (2767)
Calling function defined externally from output-headers
Embedded SpeedScript
Using 4gl procedure as function library
CAUSE:
The problem occurs when instantiating a persistent procedure, saving off its handle and declaring functions within it then calling them from the output-headers procedure in Webspeed.
When you write code as such it appears that the code which runs the function library is before the code which calls output-headers, but in the code that webspeed generates the call to output-headers is actually done prior to any code written in the embedded speedscript file.
Take the following code snippet as an example:DEFINE VARIABLE hProc AS HANDLE NO-UNDO.
FUNCTION blah RETURNS CHARACTER ( INPUT pcChar AS CHARACTER ) IN hProc.
RUN p1.p PERSISTENT SET hProc.
PROCEDURE output-headers:
blah("shkjdf").
output-content-type("text/html").
END PROCEDURE.
When compiling the file using WebSpeed workshop, if you save the temporary file it generates, it looks like the following. Note that e4gl.i is included prior to the application code. This is where the line of code which runs output-headers resides:/*E4GL-W*/ {src/web/method/e4gl.i} /*Tag=<?WS>*/
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.FUNCTION blah RETURNS CHARACTER ( INPUT pcChar AS CHARACTER ) IN hProc. RUN p1.p PERSISTENT SET hProc. PROCEDURE output-headers: blah("shkjdf").
output-content-type("text/html").
END PROCEDURE.
/*Tag=</?WS>*/
{&OUT} '<HTML>~n'.
{&OUT} '</HTML>~n'.
/************************* END OF HTML *************************/
/*
** File: C:\Work101B\blah.w
** Generated on: 2007-09-20 09:54:32
** By: WebSpeed Embedded SpeedScript Preprocessor
** Version: 2
** Source file: C:\Work101B\blah.html
** Options: web-object
**
** WARNING: DO NOT EDIT THIS FILE. Make changes to the original
** HTML file and regenerate this file from it.
**
*/
/********************* Internal Definitions ********************/
/* This procedure returns the generation options at runtime.
It is invoked by src/web/method/e4gl.i included at the start
of this file. */PROCEDURE local-e4gl-options: DEFINE OUTPUT PARAMETER p_version AS DECIMAL NO-UNDO
INITIAL 2.0.
DEFINE OUTPUT PARAMETER p_options AS CHARACTER NO-UNDO
INITIAL "web-object":U.
DEFINE OUTPUT PARAMETER p_content-type AS CHARACTER NO-UNDO
INITIAL "text/html":U.
END PROCEDURE.
/* end */
FIX:
- If the function library will be used by all programs in your WebSpeed application you can define a NEW GLOBAL SHARED variable to store the handle, start it in one of the server startup procedures and simply define the handle variable as such in all procedures which use it. With this method be very careful of potential transaction leaks in the function library code as this could cause other problems in your application.
- Start the function library when needed. i.e. Move your code outside output-headers or move the code which instantiates the procedure into output-headers.