/*******************************************************************************
*                                                                              *
*  File:        PlayField.js                            Revision:  1.0         *
*                                                                              *
*  Contents:    a simple environment for JavaScript experiments                *
*                                                                              *
*  Creation:    14.08.1998                     Last Modification:  24.04.2002  *
*                                                                              *
*  Platform:    IBM-compatible PC running Windows 98                           *
*                                                                              *
*  Environment: Opera 5.12                                                     *
*                                                                              *
*  Author:      Andreas Rozek           Phone:  ++49 (711) 6770682             *
*               Kirschblütenweg 15      Fax:    -                              *
*             D-70569 Stuttgart         EMail:  Andreas.Rozek@T-Online.De      *
*               Germany                                                        *
*                                                                              *
*  URL:         http://www.Andreas-Rozek.de/                                   *
*                                                                              *
*  Copyright:   this software is published under the  "GNU Lesser General Pub- *
*               lic  License"  (see  "http://www.fsf.org/copyleft/lesser.html" *
*               for additional information)                                    *
*                                                                              *
*  Comments:    (none)                                                         *
*                                                                              *
*******************************************************************************/

/*******************************************************************************
*                                                                              *
*                              internal functions                              *
*                                                                              *
*******************************************************************************/

/*******************************************************************************
*                                                                              *
* _clearOutputArea                             clears the program output field *
*                                                                              *
*******************************************************************************/

  function _clearOutputArea () {
    var actualForm = document.forms["ScriptForm"];
    actualForm.elements["OutputArea"].value="";
  };

/*******************************************************************************
*                                                                              *
* _clearSourceArea                          clears the source code input field *
*                                                                              *
*******************************************************************************/

  function _clearSourceArea () {
    var actualForm = document.forms["ScriptForm"];
    actualForm.elements["SourceArea"].value="";
  };

/*******************************************************************************
*                                                                              *
* _evalSourceArea     reads & evaluates the contents of the source input field *
*                                                                              *
*******************************************************************************/

  function _evalSourceArea () {
    var actualForm = document.forms["ScriptForm"];
    eval(actualForm.elements["SourceArea"].value);
  };

/*******************************************************************************
*                                                                              *
*                        publically available functions                        *
*                                                                              *
*******************************************************************************/

/*******************************************************************************
*                                                                              *
* cls                                                   clears the output area *
*                                                                              *
*******************************************************************************/

  function cls () {
    _clearOutputArea();
  };

/*******************************************************************************
*                                                                              *
* confirm                               allows the user to "confirm" a request *
*                                                                              *
*******************************************************************************/

//function confirm (Message) {
//  if (Message == null) {                  // also handles a "missing" argument
//    Message = "Please confirm";
//  };
//
//  return window.confirm(Message);
//};

/*******************************************************************************
*                                                                              *
* input                           retrieves the content of the data input area *
*                                                                              *
*******************************************************************************/

  function input (Message,Value) {
    if (Message == null) {                  // also handles a "missing" argument
      Message = "Please enter some input for your program:";
    };
    if (Value == null) Value = "";

    return window.prompt(Message,Value);
  };

/*******************************************************************************
*                                                                              *
* print, println                    simplifies printing into the "output area" *
*                                                                              *
*******************************************************************************/

  function print () {
    var actualForm = document.forms["ScriptForm"];
    for (var i = 0; i < arguments.length; i++) {
      actualForm.elements["OutputArea"].value += arguments[i];
    };
  };

  function println () {
    for (var i = 0; i < arguments.length; i++) {
      print(arguments[i]);
    };
    print("\n");
  };
