(self, args)
MID$: set part of a string.
MID$: set part of a string.
MID$ : set part of a string .
def mid_(self, args):
        """MID$: set part of a string."""
        name, indices = next(args)
        name = self.complete_name(name)
        if indices != []:
            # pre-dim even if this is not a legal statement!
            self.arrays.check_dim(name, indices)
        start = values.to_int(next(args))
        num = next(args)
        if num is None:
            num = 255
        else:
            num = values.to_int(num)
        s = values.pass_string(self.view_or_create_variable(name, indices)).to_str()
        error.range_check(0, 255, num)
        if num > 0:
            error.range_check(1, len(s), start)
        # we're not using a temp string here
        # as it would delete the new string generated by midset if applied to a code literal
        val = values.pass_string(next(args))
        # ensure parsing is completed
        list(args)
        # copy new value into existing buffer if possible
        basic_str = self.view_or_create_variable(name, indices)
        self.set_variable(name, indices, basic_str.midset(start, num, val))
def mid_ ( self , args ) : name , indices = next ( args ) name = self . complete_name ( name ) if indices != [ ] : # pre-dim even if this is not a legal statement! self . arrays . check_dim ( name , indices ) start = values . to_int ( next ( args ) ) num = next ( args ) if num is None : num = 255 else : num = values . to_int ( num ) s = values . pass_string ( self . view_or_create_variable ( name , indices ) ) . to_str ( ) error . range_check ( 0 , 255 , num ) if num > 0 : error . range_check ( 1 , len ( s ) , start ) # we're not using a temp string here # as it would delete the new string generated by midset if applied to a code literal val = values . pass_string ( next ( args ) ) # ensure parsing is completed list ( args ) # copy new value into existing buffer if possible basic_str = self . view_or_create_variable ( name , indices ) self . set_variable ( name , indices , basic_str . midset ( start , num , val ) )