/* * * ProLinga-Run * * Copyright (C) 2002-2008 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" #include "DataCommand.hpp" extern ForCountStackPtr forStackPtr; extern DataModelPtr dmPtr; /* Command : ENDFOR */ /* Syntax : ENDFOR */ short CmdEndfor(bool isMainThread) { int retValue = 0, count, end, step; char *dataref, *dmName, int2str[100]; /* Get Loop values */ dataref = forStackPtr->getCountDataRef(forStackPtr); count = forStackPtr->getCount(forStackPtr); end = forStackPtr->getEndValue(forStackPtr); step = forStackPtr->getStep(forStackPtr); dmName = forStackPtr->getDataModel(forStackPtr); /* Check if ENDFOR for FOR or FOREACH */ if ( (dataref != NULL) || (dmName != NULL) ) { /* Check if break the loop */ count = count + step; if (count > end) { /* Remove For entry from stack */ forStackPtr->pop(&forStackPtr); retValue = 3; } else { /* Raise count and loop again */ if (dataref != NULL) { sprintf(int2str, "%d", count); putDataRef(dataref, int2str, 0, isMainThread); } if (dmName != NULL) { dmPtr->putCurrentRow(&dmPtr, dmName, count); /* Get Next row of Data Model */ dataDataModelGetRow(dmName, count); } forStackPtr->putCount(&forStackPtr, count); } } /* Return */ return retValue; }