Write Method

AFP collects all data to be sent back to the browser in a buffer. This buffer is limited to the maximum length of a character string in Visual FoxPro – at the time of this writing just under 16 MB.  Response.Write() lets you attach data to this buffer

Syntax

Response.Write( uValue )

Parameter

uValue

Data of any kind, converted to character strings and attached to the output buffer. The following code is used to output an HTML page with the content Hello World:

<%

   Response.Write( "<html><body>Hello World</body></html>" )

%>

Whenever data is transmitted that has not previously been transmitted as character string, the conversion format is determined by different settings in Visual FoxPro, including SET FIXED, SET DECIMAL, SET POINT among others. If for the output a previously set format is required, you may want to employ TRANSFORM(), specify a formatting template or use other Visual FoxPro functions that convert data to character strings.

If you use AFP3.7.EXE, you will have to precede your memo field output with an empty string, as otherwise only the first 254 characters are returned. This is a bug of the Visual FoxPro 7.0 runtime library that has been rectified in Visual FoxPro 8.0:

? "" + Table.Memo

Note

If you run procedures in .code files the only way you can send data to the browser will be through Response.Write() or Response.BinaryWrite(). Inside the .afp document you can also use the following variants. While their results are identical to those of Response.Write(), they execute a bit quicker.

<%

   ? "Hello World"

   ?? "Hello World"

   = "Hello World"

%>

Under normal circumstances all three variants give the same results. You can, however, use the file .afpa to specify different formatting functions for each of these commands. This feature is taken advantage of in C24_Fox.afpa among others, to call a function for the ?? command that will effect a translation of the output value.

You should not rely on the code generated by these three alternatives as this may change in future versions due to optimizations. Currently, the response buffer is collected in the variable ___AFPContent. Output is realized by attaching the output to this character string.

From a technical aspect there is currently no difference between Response.Write() and Response.BinaryWrite(). It may be that in later versions Response.Write() will convert data automatically for different purposes like supporting different code pages or Unicode. To facilitate the adaptation of this, all data to be sent to the browser unaltered should even now be sent through Response.BinaryWrite().

See also

Response.Clear() | Response.Reset() | Server.HtmlEncode()