I am at the rudimentary level in Ruby and am trying to learn Tk.
The attached program (tkalpha.rb) worked fine from the command line,
without the Tk code. All it should do is apply a mask/code to text, to
form a cryptogram, then save the cryptogram, and the code number, to a
file. Without the Tk code, each line of the resulting data file is
either a cryptogram or a code number. When I run the program with the Tk
code inserted, it adds either a blank line and a line with the code
number, but no cryptogram, or it adds the cryptogram, a blank line, the
code number, a blank line, and then a code number, which may or may not
be the same as the first code number.
I also attached the data file. After running tkalpha 12 times, it saved
the cryptogram only once, followed by a blank line, the code number, a
blank line, and then the code number. The other 11 times it saved only a
blank line and then the code number.
I tried .chomp, and .strip to eliminate blank lines, but no luck. It
seems the extra lines are introduced when the code number (fixnum) is
added to the file. I tried .to_s with .chomp and .strip to no avail.
I am using a Windows Vista platform, Ruby 2.0, and Tk 8.5.
There is no error message. I didn’t have far to go, but I am at my wit’s
end. Any insight or suggestions would be greatly appreciated.