Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- ClipX.Lib v1.2 - <b>stopwrite()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
StopWrite()
Toggles HTML write to standard-out ( on/off )
--------------------------------------------------------------------------

Syntax:

  StopWrite( [< lSetting >] )  --->  lInitialState

Arguments:

  [<lSetting>] is an optional logical value which is tested by most ClipX
  functions which generate HTML tags.

  The StopWrite default setting is FALSE.

  Returns: A logical value representing the initial state
  ( TRUE or FALSE ) of the StopWrite setting.

Description:

  Most X-Hacker.orgfunctions, which generate HTML text/tags, both return
the generated HTML code and immediately write that HTML code to
standard-out.

  StopWrite() can be used to prevent the writing of the HTML code
to standard-out.  In this case, the functions which test the StopWrite
setting, will only return the HTML string.

HtmlWrite() is not affected by this setting.

Examples:

  The following code sample is an extreme example of the use of StopWrite().
  It illustrates the effect of the StopWrite setting, and is not a
  suggested coding style.

  function Main()
    local cMyQueue := ''

    if !ClipXOpen()
      Quit
    endif
    header()     // --> Content-Type: text/html

    // Write the HTML begin and line break tags to standard-out.
    // The return value is ignored.
    Br()         // --> <BR>
    htmlBeg()    // --> <HTML>

    // Set the StopWrite setting to suspend the writing of HTML code by
    // the functions that follow, until StopWrite is reset.
    // htmlWrite() is not affected.
    StopWrite( .T. )

    // Continue to write HTML page code in various ways

    // Queues the code for later writing
    cMyQueue := headBeg() +;
                titleBeg( 'My Title' ) + titleEnd() +;
                headEnd()
    htmlWrite( cMyQueue )   // --> <HEAD><TITLE>My Title</TITLE></HEAD>

    // Write the return value yourself
    // The StopWrite setting never affects the return value of a function
    htmlWrite( bodyBeg() )   // --> <BODY>

    // Since StopWrite is TRUE, this statement will have no effect
    Big( 'Hello World' )

    // Reset the StopWrite setting
    StopWrite( .F. )

    // Since StopWrite is FALSE, this statement will write to standard-out
    // as well as return the HTML string
    cMyQueue := Big( 'Hi Universe' )   // --> <BIG>Hi Universe</BIG>
    Br()                               // --> <BR>

    // Writes  'Hi Universe, again.' to standard-out
    htmlWrite( cMyQueue + '<BIG>, again.</Big>' )
              // --> <BIG>Hi Universe</BIG><BIG>, again.</Big>
    Br()      // --> <BR>

    // Write the current value of StopWrite
    htmlWrite( 'The current setting of StopWrite() is: ' +;
               iif( StopWrite(), "TRUE", "FALSE" ) )
               // --> The current setting of StopWrite() is: FALSE

    // Write the end body and end HTML tags to standard-out
    // The return value is ignored
    htmlBodyEnd()  // --> </BODY></HTML>

    ClipXClose()

  return nil

  Browser output:

     Hi Universe
     Hi Universe, again.
     The current setting of StopWrite() is: FALSE

Files: Library is ClipX.Lib


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson