Storing Images in Linear Hash Tables (Functions/Subroutines/Programs)

Linear Hash can only store images in a record if a conversion is done to the image.  The image would be in Binary characters and may contain characters that are also what LH use s as delimiters.  Therefore problems well most likely occur.

 

            A way of getting around this conversion would be to store the path to the image instead of storing the image itself.  With a few lines of code the user will assume the image is actually bound to the record.  (Which it really is, with a twist)

 

Walk through example:

 

1)            Create an LH table with (2) two fields.  One called  NAME  and the other called  PICTURE .

 

kb0092_1.jpg

 

2)            Create a new form based on this table.  When the form comes up resize the form to make it longer and

      place a Bitmap control on the form.

           

                

               

3)            In the CHANGED event of the PICTURE field type in this script:

 

***********************************************************************

* pathToBitmap = Get_Property(@WINDOW : ".PICTURE" , "TEXT")

*

* path = Set_Property(@WINDOW : ".BITMAP_1" , "BITMAP", pathToBitmap)

                ***********************************************************************

 

**This will change the Bitmap image whenever the PICTURE field changes.  If the field is looking for an invalid Bitmap that does not exist or an invalid path is entered, the Bitmap will go to the OpenInsight default image.  In other words it is a good idea to ensure the path is valid.   4)  The next thing to do is to run the form and add a couple of records.  After a few have been added, browse through them to see the records changes along with the picture.  This way the user assumes the picture is associated with the record when in fact it s only the path and filename.   5) Sometimes people don t want to type in the path with the fear of typing in the wrong path or filename.  So what we can do in the example is call the Open Dialog box from Windows and click on the file you want. The path and the filename will be returned and automatically put in the picture field that holds the path and filename information.  This way will ensure no mistakes.  **Doing it this way will also give us the option to make the field invisible, because the path doesn t matter to us, only the picture.**   6) Steps for calling the Open Dialog box:                                                 **************************************************************** * Declare Function Utility                                                                                                      *                                                                                                                          * CFOpt = ""                                                                                                  * CFOpt<1> = 0                       ;* Open Mode                                                 * CFOpt<2> = "Bitmaps (*.bmp)/*.bmp/All Files (*.*)/*.*/"                                                  *                                                                                                                    * getBmpFile = Utility("CHOOSEFILE" , @WINDOW , CFOpt)               * set = Set_Property(@WINDOW : ".PICTURE" , "TEXT" , getBmpFile) ****************************************************************   **What you would want to do is to call this code when you finish typing in the NAME field.  whatever image you select will be stored in the table when you save and will show up next time the record is called.  This is done due to the code you put in the changed eventof the picture field.

  • kb/kb_articles/kb0092.txt
  • Last modified: 2024/01/30 13:36
  • by 127.0.0.1