// IncludePath.edt
// ===============
//
// Expand Filename containing TeX Definitions:
// ===========================================
// \def\rootpath{c:\TeX\Lectures}
// \def\mypath{\rootpath/folder}
// ...
//   \include{\mypath/filename}
// =====================================================
// %?  = the last wildcard
// %!? = the whole line span containing the directive...
// =====================================================

  PushTagsandRegisters;
  LetReg(0,'%?'); // \include{\path/filename}
  FindInString("%!0","\\\(@[a-z]\)", 1,1, 1);
  IfOK('Relax;','PopTagsandRegisters;Exit;'); // contains control sequences?
  GetPreamble("\begin{document}",9); // Get Preamble in Register 9
  LetRegNum(6,0);         // counter to prevent an infinite loop

:More:: =============================================================
  LetRegNum(6,%!6+1);
  IfNum(%!6,9,'>','PopTagsandRegisters;Exit;'); // way too deep: cannot be resolved...
  GetTag(0,8); // Control Sequence
  FindInString("%!9","\\def\\%!8\{\(1*\)\}",1,1,11);
  IfOK('Relax;','PopTagsandRegisters;Exit;'); // Not Found?
  GetTag(1,7); // Control Sequence definition
  SubstituteInString("%!0","\%!8","%!7",10,0);
  FindInString("%!0","\\\(@[a-z]\)", 1,2, 1);
  IfOK('JMP("More");');

  // Prompt('%!0'); // for debugging...
  Assign("_ExTreeInput","%!0");
  PopTagsandRegisters;

End;
