# Copyright (C) 2023 Dennis J. Darland # This file is part of Dennis J Darland's Glucose Prediction Software. # It is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with it. If not, see . def add_entry_to_table if File.exists?(File.join($target,"body4.html")) then if not tran(File.join($target,"body4.html") , File.join($target,"body4.work")) then puts "error copying body4.html" exit(1) end else # Make body empty puts "create empty because doesn't exist" bodywork = File.new(File.join($target,"body4.work"),"w") bodywork.puts " " bodywork.close end if not tran2(File.join($target,"body4.work"), "summary4.txt" ,File.join($target,"body4.html")) then puts "error concatinating entry" exit(1) end if not tran3(File.join("html","head4.html") , File.join($target,"body4.html") , File.join("html","tail.html") , File.join($target,"table4.html")) then puts "error concatinating table" exit(1) end end def tran(infile,outfile) puts "tran |" + infile + "| + |" + outfile + "|" fd1 = File.new(infile,"r") fd2 = File.new(outfile,"w") puts "tran " + infile + " " + outfile while linein = fd1.gets do fd2.puts linein end fd2.flush fd1.close fd2.close return true end def tran2(infile1,infile2,outfile) fd1 = File.new(infile1,"r") fd2 = File.new(infile2,"r") fd3 = File.new(outfile,"w") puts "tran2 " + infile1 + " " + infile2 + " " + outfile while linein = fd1.gets do fd3.puts linein end while linein = fd2.gets do fd3.puts linein end fd3.flush fd1.close fd2.close fd3.close return true end def tran3(infile1,infile2,infile3,outfile) fd1 = File.new(infile1,"r") fd2 = File.new(infile2,"r") fd3 = File.new(infile3,"r") fd4 = File.new(outfile,"w") puts "tran3 " + infile1 + " " + infile2 + " " + infile3 + " " + outfile while linein = fd1.gets do fd4.puts linein end while linein = fd2.gets do fd4.puts linein end while linein = fd3.gets do fd4.puts linein end fd4.flush fd1.close fd2.close fd3.close fd4.close return true end $target = "html" add_entry_to_table