6.19.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.

Start python section to interscript/frames/inputf.py[10 /42 ] Next Prev First Last
   370: #line 496 "input_frame.ipk"
   371:   def include_file(self,name,encoding=None):
   372:     "Include an interscruot file"
   373:     if 'input' in self.process.trace:
   374:       print 'input from',name
   375:     file_signature = (self.depth+1,'interscript',name)
   376:     if file_signature in self.pass_frame.skiplist:
   377:       print 'SKIPPING INCLUDE FILE',file_signature
   378:       i = 0
   379:       t = self.master.src_tree
   380:       n = len(t)
   381:       while i<n:
   382:         if file_signature == tuple(t[i][0:3]): break
   383:         i = i + 1
   384:       if i == n:
   385:         print 'COULD NOT FIND SKIP FILE',file_signature,'in',t
   386:       else:
   387:         self.pass_frame.include_files.append(file_signature)
   388:         i = i + 1
   389:         lev = file_signature[0]
   390:         while i<n:
   391:           if t[i][0] >= lev: break
   392:           print 'INSERTING',t[i][2],'into include file list (cheating)'
   393:           self.pass_frame.include_files.append(tuple(t[i][0:3]))
   394:           i = i + 1
   395:     else:
   396:       self.pass_frame.include_files.append(file_signature)
   397:       if encoding is None:
   398:         encoding = self.source.encoding_name
   399:       self.include_source(named_file_source(
   400:         self.pass_frame,name, self.source.directory, encoding=encoding))
   401: 
   402:   def include_source(self,source):
   403:     "Include an interscript source"
   404:     self.select(None)
   405:     ho = self.head_offset
   406:     inpt = input_frame(
   407:       self.pass_frame,
   408:       source,
   409:       [],
   410:       self.current_weaver,
   411:       self.userdict.copy(),
   412:       self.depth+1)
   413:     inpt.head_offset = ho
   414:     inpt.set_warning_character(python='@')
   415:     inpt.file_pass()
   416:     self.current_weaver.set_original_filename (self.original_filename)
   417: 
End python section to interscript/frames/inputf.py[10]