I can't figure this out :
Program :
Reads in an .html file one line at time into OneLine$ .
Appends OneLine$ at a time into OutputString$ .
Reads OutputString$ and Inserts a Chr(13) after each ">" .
Writes each Line into EditorArea .
Then writes each line into "HtmlLinesSplitAtGT.html" .
The problem is that is doesn't write out the last 3 lines ,
<div id="bg_popup-container"></div>
</body>
</html>
Thanks for your help .
Here is the input file :
Code: Select all
<!DOCTYPE html>
<html><head><meta content="text/html; ">
<!-- http://w3schools.invisionzone.com/forum/6-css/ -->
<title>Jesus'sWordsOnly-3-Rows-RO.html</title>
<style>
body {
background-color: rgb(113, 30 , 19);
}
table {
border-style: none;
}
tr {
border-style: none;
}
.trBetween {
}
.td1 {
color: rgb(0, 0, 0);
vertical-align: top;
width: 50%;
font-size: 17px;
border-style:none;
//border-color: white white rgb(246, 244, 242) white;
//border-width: 2px;
background-color: rgb(232, 230 , 228);
}
.td2 {
color: rgb(0, 0, 0);
vertical-align: top;
width: 50%;
font-size: 18px;
border-style:none;
//border-color: white white rgb(246, 244, 242) white;
//border-width: 2px;
background-color: rgb(246, 244, 242); }
</style>
</head>
<body>
<h6 style="text-align: center; color: rgb(246, 244, 242);">Jesus's-Words-Only.html</h6>
<table style="text-align: left; width: 100%;">
<tbody>
<tr>
<td class="td1" contenteditable="false" style="text-align: center;">
Hover over Bible references in this column
<br>to see the GNT version .
</td>
<td class="td2" contenteditable="false" style="text-align: center;">
Jesus's words in ESV in this column .
</td>
</tr>
<tr class="trBetween"> </tr>
<tr>
<td class="td1" contenteditable="false" style="vertical-align: top;">
The Young Jesus at the Temple (Luke 2:41-52) To His parents looking for Him, Jesus said.
</td>
<td class="td2" contenteditable="false" style="vertical-align: top; background-color: rgb(246, 244, 242); ">
Why were you looking for me? Did you not know that I must be in my Father's house?
</td>
</tr>
<tr class="trBetween"> </tr>
<tr>
<td class="td1" contenteditable="false" style="vertical-align: top;">
John Baptizes Jesus (Matthew 3:13-17, Mark 1:9-11, Luke 3:21-3, John 1:33-4) John protests.
</td>
<td class="td2" contenteditable="false" style="vertical-align: top; background-color: rgb(246, 244, 242); ">
Let it be so now, for thus it is fitting for us to fulfill all righteousness.
</td>
</tr>
</tbody>
</table>
<!--StartMessageHere-->
<script src="https://www.biblegateway.com/public/link-to-us/tooltips/bglinks.js" type="text/javascript">
</script>
<script type="text/javascript">
BGLinks.version = "GNT";
BGLinks.linkVerses();
</script>
<div id="bg_popup-container"></div>
</body>
</html>
Code: Select all
; ReadAll-CollectAsOneString-Missing(body)(html).pb
; https://www.purebasic.fr/english/viewforum.php?f=13
Global OneLine$ , OutputString$ , HtmlLineIn$
Global StartingHtmlElement$ = "<td" , EndingHtmlElement$ = "</td>"
Global LEN_StartingHtmlElement = Len(StartingHtmlElement$) , LEN_EndingHtmlElement = Len(EndingHtmlElement$)
Global Starting_HitsCount , Ending_HitsCount , OutputLines$
Global OpenWindow_0 , EditorArea , EditorAreaItemsCOUNT , StartTagStr , EndTagStr , CollectBtn ,
SaveAsHtmlBtn , CollectWithinBtn , ExitBtn , HelpBtn , OpenInputBtn ,
OpenThisFilename$ , EndOfProgram$ = "no" , InputFileIsOpen = 0 ,Result = 0 ,
OutputFileName$ , OutputFileIsOpen = 0 , CurrentDIR$ = GetCurrentDirectory() ,
HtmlHeader$ = "<!DOCTYPE html>" + Chr(10) + "<html>" + Chr(10) + "<head>" + Chr(10) +
"<meta charset=" + Chr(34) + "UTF-8" + Chr(34) + ">" + Chr(10) +
"<meta name=" + Chr(34) + "viewport" + Chr(34) + "content=" + Chr(34) + "width=device-width, initial-scale=1.0" + Chr(34) + ">" + Chr(10) + Chr(13) +
"<title></title>" + Chr(10) + "</head>" + Chr(10) +
"<body>" ,
HtmlTrailer$ = "</body></html>" , LengthOutputString = 0 , GtPosition = 0 , MidStringResult$ ,
CollectWithinElement$ = "NO"
;
Declare OpenInputFile()
Declare SaveFileAs()
Declare SplitOutputStringAT()
Declare WriteEditorAreaToFile()
;
Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 575)
Window_0 = OpenWindow(#PB_Any, x, y, 600, 575, "Collect Html by Element", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget| #PB_Window_TitleBar | #PB_Window_SizeGadget | #PB_Window_ScreenCentered )
FirstContainer = ContainerGadget(#PB_Any, 10, 6, 580, 64, #PB_Container_Single )
StartTagStr = StringGadget(#PB_Any, 16, 6, 60, 25, "<td")
GadgetToolTip(StartTagStr, "Enter START TAG <p gets better results than <p>")
SetGadgetColor(StartTagStr, #PB_Gadget_FrontColor,RGB(64,0,64))
EndTagStr = StringGadget(#PB_Any, 89, 6, 60, 25, "</td>")
GadgetToolTip(EndTagStr, "Enter Full End Tag , like this </p> .")
SetGadgetColor(EndTagStr, #PB_Gadget_FrontColor,RGB(0,0,0))
SetGadgetColor(EndTagStr, #PB_Gadget_BackColor,RGB(255,255,255))
CollectBtn = ButtonGadget(#PB_Any, 180, 6, 120, 25, "Collect Elements")
GadgetToolTip(CollectBtn, "Collect Elements , show in EditArea Below .")
CollectWithinBtn = ButtonGadget(#PB_Any, 180, 34, 150, 25, "Collect Within Elements")
GadgetToolTip(CollectWithinBtn, "Collect Stuff WITHIN the Element Tag , show in EditArea Below .")
SaveAsHtmlBtn = ButtonGadget(#PB_Any, 320, 6, 86, 25, "Save As Html")
GadgetToolTip(SaveAsHtmlBtn, "Looking Good , Save It NOW !")
ExitBtn = ButtonGadget(#PB_Any, 436, 6, 80, 25, "Exit")
GadgetToolTip(ExitBtn, "Exit This Program , Bye , Bye ! :) .")
HelpBtn = ButtonGadget(#PB_Any, 526, 6, 40, 25, "?")
GadgetToolTip(HelpBtn, "Show Program HELP File In Browsr.")
CloseGadgetList()
EditorArea = EditorGadget(#PB_Any, 10, 80, 580, 475, #ES_MULTILINE|#ES_AUTOVSCROLL|#WS_VSCROLL|#WS_HSCROLL )
GadgetToolTip(EditorArea, "This Is Where We Build The Html Page")
EndProcedure ; OpenWindow_0
;
Procedure OpenInputFile() ; |All files (*.*)|*.*
MessageRequester(" " , " OpenInputFile() " )
; MessageRequester("" , "CurrentDIR$ = " + CurrentDIR$ )
ClearGadgetItems(EditArea)
OpenThisFilename$ = "Jesus'sWordsOnly-3-Rows-RO.html"
Goto SkipOpenFileRequester
InputFileIsOpen = InputFileIsOpen + 1
If InputFileIsOpen > 1 : CloseFile(2) : InputFileIsOpen = 0
EndIf
StandardFile$ = GetCurrentDirectory() ; set initial file+path to display
Pattern$ = "Html (*.html)|*.html;*.html|Text (*.txt)|*.txt"
Pattern = 0 ; use the first of the three possible patterns as standard
OpenThisFilename$ = OpenFileRequester("Please choose file to load", StandardFile$, Pattern$, Pattern)
If OpenThisFilename$
MessageRequester("Information", "You have selected following file:" + Chr(10) + OpenThisFilename$, 0)
Else
MessageRequester("Information", "The requester was canceled.", 0)
EndIf
SkipOpenFileRequester:
ReadFile(2, OpenThisFilename$)
Repeat
OneLine$ = ReadString(2 ) ;=====================================================================
If OneLine$ = "<!--StartMessageHere-->" : ShowMessageRequester$ = "yes" : EndIf
If ShowMessageRequester$ = "yes"
MessageRequester(" OneLine$ " , " OneLine$ " + OneLine$ )
EndIf
OutputString$ = OutputString$ + OneLine$
Until Eof(2)
CloseFile(2)
;
EndProcedure ; OpenInputFile()
;
Procedure SplitOutputStringAT() ; OutputString$
LengthOutputString = Len(OutputString$)
GtPosition = 1
LastGtPosition = 1
Repeat
GtPosition = FindString(OutputString$, ">" , GtPosition )
GtPosition = GtPosition + 1
MidStringResult$ = Mid(OutputString$, LastGtPosition , GtPosition - LastGtPosition )
LastGtPosition = GtPosition + 1
AddGadgetItem(EditorArea ,-1 , MidStringResult$)
OutputString$ = InsertString(OutputString$ , Chr(13) , GtPosition)
Until GtPosition + 2 > LengthOutputString
; NO File to Close
EndProcedure ; SplitOutputStringAT()
;
Procedure WriteEditorAreaToFile()
EditorAreaItemsCOUNT = CountGadgetItems(EditorArea)
If CreateFile(1, "HtmlLinesSplitAtGT.html") ; If file can be created...
For k = 0 To EditorAreaItemsCOUNT - 1
WriteStringN(1, GetGadgetItemText(EditorArea, k ) )
Next
; WriteStringN(1, HtmlTrailer$ )
CloseFile(1)
Else
MessageRequester("OpenFile(1, ", "Can't Open File = " + OutputFileName$ )
EndIf
EXITWriteEditorAreaToFile:
EndProcedure ; WriteEditorAreaToFile()
;
ClearGadgetItems(EditorArea)
OpenWindow_0()
OpenInputFile()
SplitOutputStringAT()
WriteEditorAreaToFile()
;
;
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Case #PB_Event_CloseWindow : End
EndSelect
Until event = #PB_Event_CloseWindow