Save 'Surf' Data Arrays into a text file

up

'Save Array' uses the 'Java Application' bmp_to_txt to save the array data the user has selected in the Surf 'Java Applet' into a  .txt  file.   Files ending in .txt  can be opened using Microsoft Notepad and may other programs including most word processors and most programming development environments.

The save process has two steps.  First the user must capture the screen using a screen capture program such as PrintKey.  In order for the save to work the screen must be captured into the  .bmp  graphic format.  Next the user activates the txt_to_bmp Java Application to convert data that is encoded in the  .bmp  graphic into a text file.

For important security reasons 'Java Applets' operating in the internet environment in your 'Internet Explorer' are not allowed access to your hard disk.  If it were possible for a web page to access your hard drive then any web page to which you might browse could take over your computer.   Thus to save the data calculated in the Surf Applet it is necessary to use an application on the users computer to save the data from the 'Display Array' screen capture.

Summary of the actions taken by bmp_to_txt  Application

If a file named bmp_to_txt__file_to_open.txt  exists open that file and read the name of the  .bmp  file that bmp_to_txt  is to read and parse.   If the word STOP is present and it is not preceded by  //  then when bmp_to_txt is finished the application is not to exit until the  Enter  key is pressed.  STOP is provided so if  bmp_to_txt  is not working as expected the user can read the messages to the user produced by bmp_to_txt before the application terminates.

Attempt to open the file Picture0001.bmp (in this case).
If Picture0001.bmp is opened successfully then store its contents in memory and close the Picture0001.bmp file.
There are only four colors in the Picture0001.bmp data that are of interest to bmp_to_txt.  Pixels with color one tell bmp_to_txt to begin reading data.  Color two represents logical zero, color three represents logical one and color four tells bmp_to_txt to stop reading data.

Data is read from left to right starting with the bottom line of data and proceeding to the top line of data.  Data is encoded in 8 bit bytes.  For an interpretation of 8 bit bytes (as used in DOS) see char_256__picture.gif.  The value of the first data pixel ( bit ) is 128 followed by 64, 32, 16, 8, 4, 2, 1.   Bit values are summed to produce the byte value.

If bmp_to_txt is able to interpret valid data in the Picture0001.bmp buffer then bmp_to_txt saves that data in memory.
bmp_to_txt tries to prepare a name for the  .txt  file that it is to write using the data interpreted from the Picture0001.bmp file.

bmp_to_txt checks to see if there is already a file by that name and if there is asks the user if it is OK to overwrite the existing file.

bmp_to_txt writes the output  .txt  file.

bmp_to_txt writes a status and error report to 'standard out' (if needed).

bmp_to_txt either exits immediately or asks the user to press the  Enter key.

For further details of the operation of bmp_to_txt  use Notepad to open bmp_to_txt.java
or you can open bmp_to_txt_dot_java.txt to see the Java source code.
 

Return to plot_board.htm