>Robert posted: > Widget of the Day >><snip> >Hi Robert, >A couple of comments re Max Hackenstein. > >1. If the file being split doesn't contain "MAIN", it doesn't work. >2. When "CLEAR LOCAL FN xxxx", the split file is named "AL FN xxxx" Bernie, this fixes item 1... I just passed the found value to FN LineWhack. Robert Covington '------FB 3 Program------ // File Splitter v1.1 // Sifts One Long File using 2 passes. // Creates Globals and Main files // Creates One Big Pile Of Files // v1.1 Fixes Clear Local FN item // Robert Covington <artlythere@...> Output File "Max Hackenstein" def open "TEXTFB^e" DIM gMain DIM gGlbl DIM hold$$ : hold$$ = "" DIM c$$ : c$$ = "" end globals '~'8 // "You No Like-a de Includa, You Comment Out de Includa." // Like so, Si? // + ".incl" Local FN LineWhack$(tmp$,x) DIM st$,st1 Long if LEN(tmp$) st1 = instr( 9,tmp$, "(" ) x = x + 9 Long if st st$ = mid$(tmp$,x,st1 - 10 ) + ".incl" Xelse st$ = mid$(tmp$,x,len(tmp$) - 8 ) + ".incl" End If Xelse st$ = "" End IF End FN = st$ '~'8 Local FN GetEmGlobals(WDRef%,FileName$) DIM tmp$,OutName$ DIM foundGlbl,cnt,i,foundMain,foundAtom cnt = 0 foundMain = 0 foundGlbl = 0 gGlbl = 0 gMain = 0 // Note: This FN Will Blow a Parse of this File by this File! OPEN "I", #1, FileName$,,WDRef% Do LINE INPUT #1, tmp$ inc(cnt) foundGlbl = instr( 1, ucase$(tmp$), "END GLOBALS" ) if foundGlbl then gGlbl = cnt foundMain = instr(1,ucase$(tmp$),CHR$(34)+"MAIN"+CHR$(34)) if foundMain then gMain = cnt until Eof(1) Close #1 cnt = 0 // flag Long if gGlbl or gMain OPEN "I", #1, FileName$,,WDRef% Long if gGlbl // get some globals foundGlbl = gGlbl OutName$ = FileName$ + ".glbl" open "O", #2, OutName$,, WDRef% DO LINE INPUT #1, tmp$ inc(cnt) Print #2,tmp$ until cnt = foundGlbl Close #2 End if Long if gMain OutName$ = FileName$ + ".main" While cnt <> gMain-1 inc(cnt) : line input #1,tmp$ wend open "O", #2, OutName$,, WDRef% DO LINE INPUT #1, tmp$ : Print #2,tmp$ until Eof(1) Close #2 End If Close #1 End if end FN '~'8 CLEAR LOCAL LOCAL FN AtomizeFile(WDRef%,FileName$) DIM tmp$,outFile$ DIM fileOpen DIM i,cnt,clgth DIm px,py,pz LONG IF WDRef% <> 0 OPEN "I", #1, FileName$,,WDRef% // Skip Past Any Globals Long if gGlbl for i = 0 to gGlbl LINE INPUT #1, tmp$ next i end if // Init file counter cnt = 0 OutFile$ = "" // Container parse convention via Michael Kluskens // Truncate via RC ... Keeps The Spaces Out. // pz via RC, handles "//" Comment type. // NOTE: Block Remarked FNs via /*-*/ aren't handled // quite properly. They get a file, but the ending "*/" // is sent to the next file. Do inc(cnt) line input #1, tmp$ px = instr( 1, ucase$(tmp$), "LOCAL FN" ) py = instr( 1, tmp$, "'" ) pz = instr( 1, tmp$, "//" ) if ( py > 0 and py < px ) or ( pz > 0 and pz < px ) then px = 0 long if ( px > 0 ) if ( FileOpen == 1 ) then close #2 OutFile$ = FN LineWhack$(tmp$,px) open "O",#2,OutFile$,,WDRef% FileOpen = 1 Long if ( len(hold$$) > 0 ) clgth = LEN(hold$$)-1 c$$ += LEFT$$(hold$$,clgth) print #2, c$$ c$$ = "" End If end if long if ( FileOpen == 1 ) print #2, tmp$ xelse hold$$ += tmp$ hold$$ += chr$(13) end if px = instr( 1, ucase$(tmp$), "END FN" ) py = instr( 1, tmp$, "'" ) pz = instr( 1, tmp$, "//" ) if ( py > 0 and py < px ) or ( pz > 0 and pz < px ) then px = 0 long if ( px > 0 ) close #2 FileOpen = 0 hold$$ = "" end if Until Cnt > gMain or EOF(1) Long if ( len(hold$$) > 0 ) and FileOpen = 1 print #2, hold$$ Close #2 End if CLOSE #1 END IF END FN '~'8 '~'8 "Main" DIM @WDRef% DIM ChosenFile$ ChosenFile$ = files$(_fOpen,"TEXT",,WDRef%) Long if ChosenFile$ <> "" FN GetEmGlobals(WDRef%,ChosenFile$) FN AtomizeFile(WDRef%,ChosenFile$) End If End '------ END FB 3 Program ------