/* ********************************************************************* This source file is a part of the standard library of Scol For the latest info, see http://www.scolring.org Copyright (c) 2013 Stephane Bisaro aka Iri. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ********************************************************************* */ /* * Standard functions for miscelleanous uses * See http://redmine.scolring.org/projects/tutorials/wiki/Scol_usage * for more informations */ /*! \file misc.pkg * \author Scol team * \version 0.1 * \copyright GNU Lesser General Public License 2.0 or later * \brief Scol Standard Library - Miscelleanous API * * Required : lib/std/string.pkg * **/ /* COUNTER */ struct STD_COUNTER = [ std_countervalue : I ] mkSTD_COUNTER;; /*! \brief Start a counter * * Prototype : fun [] STD_COUNTER * * \return STD_COUNTER : a counter object **/ fun std_counterStart ()= mkSTD_COUNTER [_tickcount];; /*! \brief Stop a counter * * \ingroup std_other * Prototype : fun [STD_COUNTER] I * * \param STD_COUNTER : a counter object * * \return I : the elaspsed time from the START call, in milliseconds. * \remark the counter is not closed, this function can be called again. **/ fun std_counterStop (counter)= if counter == nil then nil else _tickcount-counter.std_countervalue;; /*! \brief Reset a counter (a re-start) * * \ingroup std_other * Prototype : fun [STD_COUNTER] STD_COUNTER * * \param STD_COUNTER : a counter object * * \return STD_COUNTER : the same object **/ fun std_counterReset (counter)= if counter == nil then nil else set counter.std_countervalue = _tickcount; counter;; /*! \brief Close a counter * * \ingroup std_other * Prototype : fun [STD_COUNTER] I * * \param STD_COUNTER : a counter object * * \return I : always 0 * \remark this counter can not be called again. **/ fun std_counterClose (counter)= set counter = nil; 0;;