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

- old
+ new

@@ -1,43 +1,58 @@ - def rungutenbergwindow +# method to open new gutenberg window + def rungutenbergwindow rwdgutenbergwindowtwo end $tempnumber = 0 - + # display text and advance text def rwdgutenbergwindowtwo tempdoc = "" @gutendisplayvariable = "" - tempcount = 0 - if ! @a_viewgutenberg.to_s.empty? 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 + + rescue + + $stderr.print "error: #{$!}" + end + $gutenbergcommand == "continue" + end - tmpfileName = @a_viewgutenberg + ".gut" - fileName = File.join($rwdgutenberg_directory,tmpfileName) - fd = File.open(fileName,"r") - booktitle = fd.readline.chomp - - - $bookfile=File.new(booktitle,"r") #opens the file thats in fileName as read only - $gutenbergcommand = "continue" - end - while tempcount < $booklocation + $booksteps - $bookfile.gets - if tempcount > $booklocation -1 - tempdoc += $bookfile.gets #reads the file into the doc string - end + + if $gutenbergcommand == "continue" + - tempcount += 1 - end - - $booklocation = $booklocation + $booksteps - if $gutenbergcommand == "closebook" - $bookfile.close - end - @gutendisplayvariable = tempdoc + 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 end -end