Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Display Array Image Cache Question  (Read 14282 times)
Gary C.
Posts: 109


« on: May 21, 2015, 11:08:05 pm »

Hi

I have a display array with some text fields along with an image field. This is used to display a variable number of images relating to a product.

Here is the code that loads the local array:

Code:
function b13_loadimages()

    declare b13C cursor for
        select * from tctstih
            where s_stam = stam.s_stam
            or s_stam = refstam.s_stam
            order by imagetype

    call tabimgA.clear()
    foreach b13C into stih.*   
        let tabimgA[tabimgA.getLength() + 1].tabimgtext = stih.imagetext
        locate tabimgA[tabimgA.getLength()].tabimgimage in file
        select tctstid.image into tabimgA[tabimgA.getLength()].tabimgimage from tctstid
            where s_stih = stih.s_stih
    end foreach

end function

The array is displayed as part of an unbuffered dialog. You can see an example in the attached screen shot.

I seem to be having a problem with the images caching if one views one product after the next. The text element of the array is always correct but the image displayed seems to be a cached version of the first product viewed.

I've read through the manual but cannot see anything relating to this.

So, do images cache somehow? If so, how do I override this behavior?

Thanks

Gary


* screen02.png (112.23 KB, 1078x807 - viewed 2005 times.)
Reuben B.
Four Js
Posts: 1113


« Reply #1 on: May 22, 2015, 12:09:09 am »

Image cache was introduced with GDC 2.20, see here https://4js.com/online_documentation/fjs-gdc-manual-html/index.html#c_gdc_NewFeatures220_image_cache.html

I suspect it isn't the cause of your issue (as formfield IMAGE aren't cached by default), but you can try disabling the cache in the GDC console and/or via a presentation style first.

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Sebastien F.
Four Js
Posts: 545


« Reply #2 on: May 22, 2015, 09:13:00 am »

Your code looks ok... what FGL / GDC version are you using? Platform?
Can you provide a little and complete sample (with form file) to the support so we can try to reproduce here?
Seb
Gary C.
Posts: 109


« Reply #3 on: June 04, 2015, 03:08:55 pm »

Hello
Apologies for the delay. I have been away for the past week or so.

I have put together a sample which demonstrates the problem - albeit the images are loaded from files as opposed from the database.

Gary


* image1.jpg (3.45 KB, 120x120 - viewed 1234 times.)

* image2.jpg (5.51 KB, 120x120 - viewed 1257 times.)
* cache.4gl (1.72 KB - downloaded 997 times.)
* form1.per (1.55 KB - downloaded 980 times.)
Gary C.
Posts: 109


« Reply #4 on: June 04, 2015, 09:12:52 pm »

Hi

I have discovered that specifically "freeing" the image prior to clearing and reloading the array resolves the problem.

So, in the example I added:

Code:
    for idx = 1 to tabimgA.getLength()
        free tabimgA[idx].tabimgimage
    end for
   
    call tabimgA.clear()

Gary
Rene S.
Four Js
Posts: 112


« Reply #5 on: June 09, 2015, 12:03:05 pm »

Hello,
I was curious why your workaround (freeing each image before clearing the array) is working.
You're using LOCATE IN FILE. Each LOCATE IN FILE creates a temp file.

Prior to version 2.51.02: temp file names will be reused. This has the side effect  that a LOCATE IN FILE of a BYTE or TEXT variable already being located will get exactly the same name. This causes the cache problems: the file name does not change, GDC does not reload the image.

Since version 2.51.02: temp file names will not be reused. Your example code works as expected, no workaround required.

Bad news:
BTW: your workaround fails, if only 1 image is in the list!

Rene
Gary C.
Posts: 109


« Reply #6 on: June 10, 2015, 09:19:09 am »

Hi
Thanks for the explanation which makes perfect sense.

Can you explain why the workaround fails? I've looked and tested but it seems to work irrespective of the array length. Perhaps I am missing something obvious?

Gary
Rene S.
Four Js
Posts: 112


« Reply #7 on: June 10, 2015, 02:41:01 pm »

It's not working with 1 image because the name of the temp file does not change.
Edit your example, fill the array with just 1 record, the image "image1.jpg" in the 1st case, the image "image2.jpg" in the 2nd case (yes, this is no more "sort ascending" and "sort descending", it's "show image1" and "show image2".
Rene

Code
  1.    if sSeq = "A" then
  2.        let tabimgA[1].tabimgtype = "1"
  3.        let tabimgA[1].tabimgtext = "This is image number one."
  4.        locate tabimgA[1].tabimgimage in file
  5.        call tabimgA[1].tabimgimage.readFile("image1.jpg")
  6.  
  7.        {
  8.         let tabimgA[2].tabimgtype = "2"
  9.         let tabimgA[2].tabimgtext = "This is image number two."    
  10.         locate tabimgA[2].tabimgimage in file
  11.         call tabimgA[2].tabimgimage.readFile("image2.jpg")
  12.         }
  13.    else
  14.        let tabimgA[1].tabimgtype = "2"
  15.        let tabimgA[1].tabimgtext = "This is image number two."
  16.        locate tabimgA[1].tabimgimage in file
  17.        call tabimgA[1].tabimgimage.readFile("image2.jpg")
  18.  
  19.        {
  20.         let tabimgA[2].tabimgtype = "1"
  21.         let tabimgA[2].tabimgtext = "This is image number one."    
  22.         locate tabimgA[2].tabimgimage in file
  23.         call tabimgA[2].tabimgimage.readFile("image1.jpg")
  24.         }
  25.    end if
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines