6.23.10.2.4. Include file/source

The include file command is a subroutine call. It pushes a new input frame associated with the file, causing input to be read from the file. The new input frame has a copy of the user dictionary from the calling frame. When the file ends, the frame is popped which destroys the dictionary; all newly created symbols are lost.

The new input frame does not inherit the parent frames lexicology. In particular, the warning character is restablished as @. This command reasserts document mode, both in the included file and the current one.

The command include_source is a generalisation of include_file which takes any source driver as the input.

Comienzo python section to interscript/frames/inputf.py[9 /41 ] Siguiente Previo Primero Ăšltimo
   327: #line 452 "input_frame.ipk"
   328:   def include_file(self,name,encoding=None):
   329:     if 'input' in self.process.trace:
   330:       print 'input from',name
   331:     file_signature = (self.depth+1,'interscript',name)
   332:     if file_signature in self.pass_frame.skiplist:
   333:       print 'SKIPPING INCLUDE FILE',file_signature
   334:       i = 0
   335:       t = self.master.src_tree
   336:       n = len(t)
   337:       while i<n:
   338:         if file_signature == tuple(t[i][0:3]): break
   339:         i = i + 1
   340:       if i == n:
   341:         print 'COULD NOT FIND SKIP FILE',file_signature,'in',t
   342:       else:
   343:         self.pass_frame.include_files.append(file_signature)
   344:         i = i + 1
   345:         lev = file_signature[0]
   346:         while i<n:
   347:           if t[i][0] >= lev: break
   348:           print 'INSERTING',t[i][2],'into include file list (cheating)'
   349:           self.pass_frame.include_files.append(tuple(t[i][0:3]))
   350:           i = i + 1
   351:     else:
   352:       self.pass_frame.include_files.append(file_signature)
   353:       if encoding is None:
   354:         encoding = self.source.encoding_name
   355:       self.include_source(named_file_source(
   356:         self.pass_frame,name, self.source.directory, encoding=encoding))
   357: 
   358:   def include_source(self,source):
   359:     self.select(None)
   360:     ho = self.head_offset
   361:     inpt = input_frame(
   362:       self.pass_frame,
   363:       source,
   364:       [],
   365:       self.current_weaver,
   366:       self.userdict.copy(),
   367:       self.depth+1)
   368:     inpt.head_offset = ho
   369:     inpt.set_warning_character(python='@')
   370:     inpt.file_pass()
   371:     self.current_weaver.set_original_filename (self.original_filename)
End python section to interscript/frames/inputf.py[9]