'///////////////////////////////////////////////////////////////////////////// 
'// This program adds an Index node to the converted Commodore autodocs,    // 
'// enabling return to the main Lib_Index file in a single step via the     //     
'// Index button on the hypertext viewer program.                           // 
'// This covversion will be done from and to the Ram Disk:, ie this         //   
'// program will overwrite the ram: files so there won't be two sets of     // 
'// files after this conversion.                                            // 
'// You should create a temporary drawer on the Ram Disk: and place as many // 
'// of the converted Commodore Autodoc files in this drawer as you feel     // 
'// comfortable with. ie dont bring your memory right down to zero, I need  // 
'// some memory to work with too!                                           //   
'// The file selector that comes up at the beginning is really a Dir        // 
'// selector but you must pass any filename from this drawer otherwise I    //           
'// will get an empty string for the path which is no good, especially since// 
'// there is no error hanling in this program. So be warned, get it right,  // 
'// give me a full path to any file in the Ram: drawer that you've put the  // 
'// docs into.  After conversion this drawer will contain the converted     //   
'// docs with the Index node inserted into them.                            // 
'// If you don't have enough ram then you can do it from floppy disk just   // 
'// by changing lines 24 and 25 below to your chosen path                   // 
'///////////////////////////////////////////////////////////////////////////// 
'
Global PATH2$
Dir$="Ram Disk:"
PATH$=Fsel$("Ram Disk:",""," Choose any file from ","the correct DRAWER!!")
CHAR=Instr(PATH$,"/",1)
PATH2$=Left$(PATH$,CHAR-1)
FILE$=Dir First$(PATH2$)
CHAR=Instr(FILE$," ",2)
FILE$=Mid$(FILE$,2,CHAR-2)
Proc CONVERT[FILE$]
For I=1 To 50
   FILE$=Dir Next$
   Exit If FILE$=""
   CHAR=Instr(FILE$," ",2)
   FILE$=Mid$(FILE$,2,CHAR-2)
   Proc CONVERT[FILE$]
Next I
Print "All Done"
End 
'
'
Procedure CONVERT[FILE$]
   Set Input 10,-1
   INDEX$="@Index "+Chr$(34)+"Lib_Index/Main"+Chr$(34)+Chr$(10)
   FOOTER$="@endnode Main"+Chr$(10)
   Open In 1,PATH2$+"/"+FILE$
   L=Lof(1)
   Line Input #1,LINE$
   Close 1
   LINE$=LINE$+Chr$(10)
   Reserve As Work 7,L+100
   Reserve As Work 8,L
   Copy Varptr(LINE$),Varptr(LINE$)+Len(LINE$) To Start(7)
   Copy Varptr(INDEX$),Varptr(INDEX$)+Len(INDEX$) To Start(7)+Len(LINE$)
   Bload PATH2$+"/"+FILE$,Start(8)
   Copy Start(8)+Len(LINE$),Start(8)+L To Start(7)+Len(LINE$)+Len(INDEX$)
   Bsave PATH2$+"/"+FILE$,Start(7) To Start(7)+Len(INDEX$)+L
   Erase 7 : Erase 8
End Proc
