(self, args)
Initialise a FOR loop.
Initialise a FOR loop.
Initialise a FOR loop .
def for_(self, args):
        """Initialise a FOR loop."""
        # read variable
        varname = self._memory.complete_name(next(args))
        vartype = varname[-1:]
        start = values.to_type(vartype, next(args)).clone()
        # only raised after the TO has been parsed
        if vartype in (values.STR, values.DBL):
            raise error.BASICError(error.TYPE_MISMATCH)
        stop = values.to_type(vartype, next(args)).clone()
        step = next(args)
        if step is not None:
            step = values.to_type(vartype, step).clone()
        list(args)
        if step is None:
            # convert 1 to vartype
            step = self._values.from_value(1, varname[-1:])
        ins = self.get_codestream()
        # find NEXT
        forpos, nextpos = self._find_next(ins, varname)
        # initialise loop variable
        self._scalars.set(varname, start)
        # obtain a view of the loop variable
        self.for_stack.append((varname, stop, step, step.sign(), forpos, nextpos,))
        # empty loop: jump to NEXT without executing block
        if (start.gt(stop) if step.sign() >= 0 else stop.gt(start)):
            ins.seek(nextpos)
            self.iterate_loop()
def for_ ( self , args ) : # read variable varname = self . _memory . complete_name ( next ( args ) ) vartype = varname [ - 1 : ] start = values . to_type ( vartype , next ( args ) ) . clone ( ) # only raised after the TO has been parsed if vartype in ( values . STR , values . DBL ) : raise error . BASICError ( error . TYPE_MISMATCH ) stop = values . to_type ( vartype , next ( args ) ) . clone ( ) step = next ( args ) if step is not None : step = values . to_type ( vartype , step ) . clone ( ) list ( args ) if step is None : # convert 1 to vartype step = self . _values . from_value ( 1 , varname [ - 1 : ] ) ins = self . get_codestream ( ) # find NEXT forpos , nextpos = self . _find_next ( ins , varname ) # initialise loop variable self . _scalars . set ( varname , start ) # obtain a view of the loop variable self . for_stack . append ( ( varname , stop , step , step . sign ( ) , forpos , nextpos , ) ) # empty loop: jump to NEXT without executing block if ( start . gt ( stop ) if step . sign ( ) >= 0 else stop . gt ( start ) ) : ins . seek ( nextpos ) self . iterate_loop ( )