/* * * ProLinga-Run * * Copyright (C) 2002-2009 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Run. * * ProLinga-Run is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ProLinga-Run 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ProLinga-Run. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "RunCommon.h" #include "DataRef.hpp" #include "Logic.hpp" extern ForCountStackPtr forStackPtr; /* Command : FOR */ /* Syntax : FOR counter_ref = begin_value TO end_value [ STEP increment ] */ short CmdFor(const char **argList, int argHits, bool isMainThread) { char retValue[255]; int count, step, end; /* Assign start value to counter ref */ getDataRef(argList[3], isMainThread, retValue, false); count = atoi(retValue); putDataRef(argList[1], retValue, 0, isMainThread); /* Get End Value */ getDataRef(argList[5], isMainThread, retValue, false); end = atoi(retValue); /* Check if loop has to be started at all */ if (count > end) return 1; /* Get Step Value */ if (argHits == 7) { getDataRef(argList[7], isMainThread, retValue, false); step = atoi(retValue); } else step = 1; /* Create new FOR stack entry */ forStackPtr->push(&forStackPtr, argList[1], count, end, step, NULL); /* Return */ return 0; }