code/superant.com.gutenberg/rungutenbergwindow.rb in rwdgutenberg-0.09 vs code/superant.com.gutenberg/rungutenbergwindow.rb in rwdgutenberg-0.12

- old
+ new

@@ -1,71 +1,89 @@ -# 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 - - - if $gutenbergcommand == "openbook" - - fileName = $rwdgutenberg_directory + "/" + @a_viewgutenberg + ".gut" - 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 - - 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 +# 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 + +def loadoptionsgutenberg + + gutenbergarray = [5,10,20,50,100,500] + @gutenbergspeedoptions = gutenbergarray.rwd_options + +end + + # start book from beginning + def rungutenbergreset + $booklocation = 0 + $gutenbergcommand = "openbook" + + rwdgutenbergwindowtwo + end + + # display text and advance text + def rwdgutenbergwindowtwo + if @a_gutenbergspeedinput == nil + $rwdtinkerlog.debug "rwdgutenbergwindowtwo: steps = nil" + else + $booksteps = @a_gutenbergspeedinput.to_i + end + + begin + tempdoc = "" + @gutendisplayvariable = "" + tempcount = 0 + + + if $gutenbergcommand == "openbook" + + if File.extname(@a_viewgutenberg) == ".lnk" + fileName = @a_viewgutenberg.strip + + fd = File.open(fileName,"r") + booktitle = fd.readline.chomp + else + booktitle = @a_viewgutenberg.strip + end + if File.file?(booktitle) + $bookfile=File.new(booktitle,"r") #opens the file thats in fileName as read only + $gutenbergcommand == "continue" + end + 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