code/superant.com.gutenberg/rungutenbergwindow.rb in rwdgutenberg-0.05 vs code/superant.com.gutenberg/rungutenbergwindow.rb in rwdgutenberg-0.06

- old
+ new

@@ -1,41 +1,56 @@ -# method to open new gutenberg window +# method to open new TEXT gutenberg window def rungutenbergwindow - - rwdgutenbergwindowtwo + @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 - tempdoc = "" - @gutendisplayvariable = "" - tempcount = 0 - if @rwd_tab== "rwdgutenberg" - @rwd_window = "gutendisplaywindowtwo" - end - - if $gutenbergcommand == "openbook" - tmpfileName = @a_viewgutenberg + ".gut" - fileName = File.join($rwdgutenberg_directory,tmpfileName) - begin - 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 + begin + tempdoc = "" + @gutendisplayvariable = "" + tempcount = 0 + $stderr.print "starting\n" + + if $gutenbergcommand == "openbook" - rescue + # 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 + - $stderr.print "error: #{$!}" - end - $gutenbergcommand == "continue" - end - - if $gutenbergcommand == "continue" - - tempcount = 0 while tempcount < $booksteps tempdoc += $bookfile.gets #reads the file into the doc string tempcount += 1 end @@ -53,6 +68,14 @@ end if $gutenbergcommand == "closebook" $bookfile.close end @gutendisplayvariable = tempdoc + + + rescue SystemCallError , StandardError, RuntimeError + $stderr.print "system call error: " + $! + "\n" + + $gutenbergcommand == "closebook" + + end end