/*************************************************************/ /* */ /* File: MkText.cmd */ /* Purpose: Extract text from the Messier catalog html files */ /* Author: Hartmut Frommert */ /* */ /*************************************************************/ call rxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs fs = SysFileTree('*.html','HtmlFile','O') do i=1 to HtmlFile.0 /* do i=1 to 1 */ Html = HtmlFile.i src = Stream(Html, c, 'Open Read') NotReady = 1 InText = 0 TextLines = 0 do while ((Lines(Html) = 1) & NotReady) Inl = LineIn(Html) select when Strip(Inl) = '' then InText = 1 when Strip(Inl) = '' then NotReady = 0 when Strip(Inl) = '->Type Text Description and Information HERE<-' then nop otherwise if InText then do TextLines = TextLines + 1 Line.TextLines = Inl end /* Do */ end /* select */ end /* do */ src = Stream(Html, c, 'Close') if TextLines > 0 then do TextFile = MkTextName(HtmlFile.i) src = Stream(TextFile, c, 'Open Write') do j=1 to TextLines call WriteText Line.j end /* do */ src = Stream(TextFile, c, 'Close') end /* Do */ end /* do */ exit MkTextName: procedure TextDir = '.text\' parse arg HtmlPath HtmlDir = SubStr(HtmlPath, 1, LastPos('\', HtmlPath)) HtmlFile = Substr(HtmlPath, LastPos('\', HtmlPath)+1) HtmlName = SubStr(HtmlFile, 1, LastPos('.', HtmlFile)-1) TextName = TextDir || HtmlName || 'text.htm' return TextName WriteText: procedure expose TextFile CrLf = d2c(13) || d2c(10) parse arg line line = line || CrLf fs = CharOut(TextFile,line,) return