# method to open new TEXT gutenberg window def rungutenbergwindow @rwd_window = "gutendisplaywindowtwo" rwdgutenbergwindowtwo end # method to open new HTML gutenberg window def rungutenbergwindowhtml @rwd_window = "gutendisplayhtmlwindowtwo" rwdgutenbergwindowtwo end $tempnumber = 0 # start book from beginning def rungutenbergreset $booklocation = 0 $gutenbergcommand = "openbook" rwdgutenbergwindowtwo end # display text and advance text def rwdgutenbergwindowtwo begin tempdoc = "" @gutendisplayvariable = "" tempcount = 0 $stderr.print "starting\n" if $gutenbergcommand == "openbook" # raise "forced error test" # raise RuntimeError $stderr.print "testing string\n" fileName = $rwdgutenberg_directory + "/" + @a_viewgutenberg + ".gut" $stderr.print "about to open file existence " $stderr.print fileName $stderr.print "\n" fd = File.open(fileName,"r") booktitle = fd.readline.chomp $stderr.print booktitle $bookfile=File.new(booktitle,"r") #opens the file thats in fileName as read only $gutenbergcommand == "continue" end if $gutenbergcommand == "continue" tempcount = 0 while tempcount < $booksteps tempdoc += $bookfile.gets #reads the file into the doc string tempcount += 1 end $booklocation = $booklocation + $booksteps end if $gutenbergcommand == "openbook" while tempcount < $booklocation + $booksteps tempdoc += $bookfile.gets #reads the file into the doc string tempcount += 1 end $booklocation = $booksteps $gutenbergcommand = "continue" end if $gutenbergcommand == "closebook" $bookfile.close end @gutendisplayvariable = tempdoc rescue SystemCallError , StandardError, RuntimeError $stderr.print "system call error: " + $! + "\n" $gutenbergcommand == "closebook" end end