(self, args)
return newline
PRINT USING clause: Write expressions to console or file using a formatting string.
PRINT USING clause: Write expressions to console or file using a formatting string.
PRINT USING clause : Write expressions to console or file using a formatting string .
def _print_using(self, args):
        """PRINT USING clause: Write expressions to console or file using a formatting string."""
        format_expr = values.next_string(args)
        if format_expr == b'':
            raise error.BASICError(error.IFC)
        fors = codestream.CodeStream(format_expr)
        newline, format_chars = True, False
        start_cycle = True
        initial_literal = b''
        try:
            while True:
                c = fors.peek()
                if c == b'':
                    if not format_chars:
                        # avoid infinite loop
                        break
                    # loop the format string if more variables to come
                    start_cycle = True
                    initial_literal = b''
                    fors.seek(0)
                elif c == b'_':
                    # escape char; write next char in fors or _ if this is the last char
                    if start_cycle:
                        initial_literal += fors.read(2)[-1:]
                    else:
                        self._output.write(fors.read(2)[-1:])
                else:
                    try:
                        format_field = StringField(fors)
                    except ValueError:
                        try:
                            format_field = NumberField(fors)
                        except ValueError:
                            if start_cycle:
                                initial_literal += fors.read(1)
                            else:
                                self._output.write(fors.read(1))
                            continue
                    format_chars = True
                    value = next(args)
                    if value is None:
                        newline = False
                        break
                    if start_cycle:
                        self._output.write(initial_literal)
                        start_cycle = False
                    self._output.write(format_field.format(value))
            # consume any remaining arguments / finish parser
            list(args)
        except StopIteration:
            pass
        if not format_chars:
            self._output.write(initial_literal)
            # there were no format chars in the string, illegal fn call
            raise error.BASICError(error.IFC)
        return newline
def _print_using ( self , args ) : format_expr = values . next_string ( args ) if format_expr == b'' : raise error . BASICError ( error . IFC ) fors = codestream . CodeStream ( format_expr ) newline , format_chars = True , False start_cycle = True initial_literal = b'' try : while True : c = fors . peek ( ) if c == b'' : if not format_chars : # avoid infinite loop break # loop the format string if more variables to come start_cycle = True initial_literal = b'' fors . seek ( 0 ) elif c == b'_' : # escape char; write next char in fors or _ if this is the last char if start_cycle : initial_literal += fors . read ( 2 ) [ - 1 : ] else : self . _output . write ( fors . read ( 2 ) [ - 1 : ] ) else : try : format_field = StringField ( fors ) except ValueError : try : format_field = NumberField ( fors ) except ValueError : if start_cycle : initial_literal += fors . read ( 1 ) else : self . _output . write ( fors . read ( 1 ) ) continue format_chars = True value = next ( args ) if value is None : newline = False break if start_cycle : self . _output . write ( initial_literal ) start_cycle = False self . _output . write ( format_field . format ( value ) ) # consume any remaining arguments / finish parser list ( args ) except StopIteration : pass if not format_chars : self . _output . write ( initial_literal ) # there were no format chars in the string, illegal fn call raise error . BASICError ( error . IFC ) return newline