NetTalk Central

Author Topic: A Form with a Timer and an Image  (Read 3051 times)

MyBrainIsFull

  • Full Member
  • ***
  • Posts: 134
    • View Profile
A Form with a Timer and an Image
« on: March 29, 2015, 01:30:51 AM »
NT8 41
C10

2 problems

The Design
Show a button - when someone presses it the server returns a generated image, say web\Blah001.Png
there is a one second timer, for five seconds the server will send an updated image, say web\Blah002.Png,   web\Blah003.Png etc which each new image replaces the previous

I made a NetSource proc that has a one second timer on it called  "TimerCode"  (as per timer example web46)
I made a form that has a button, a display string and an image, then I added the procedure "TimerCode" onto the form.

Problem 1 - no image
When the button is hit, it calls server side code
- reads the fast clock in win event  and puts the time into a time field in my event table   eve:CpuTime
- assisgns an image's filename to  a field in the record   eve:Filename
- generates a png in the web folder

On the form, under the "Client-Side" tab there is a section to Reset items on the form
- I have selected the display of the time
- the image filename as a string
- the image itself

I see the time, and the filename as a string, but I never see the image (png)
If I look in the web folder, its there OK

So I put another button on the form, when you hit it, it does a refresh on the image. But still no image appears. I hit the save button and then reread the record, there is the image OK.

Observation
It appears that if the form does not have an image on it initially, you cant update it to show one

Problem 2 - image does not update
This form now has a timer procedure that triggers every second, In the timer I update the session variable p_web.ssv('CpuTime', loc:cpuTime) and assign the image to some other image
As before I set the 'Client-Side'  reset  to refresh the values
And to help things along, I set an initial image on the form, so there is something to update.

When the timer hits, the time updates, the flename changes and the image goes to a blank

Any ideas anyone ?
Kevin

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: A Form with a Timer and an Image
« Reply #1 on: March 30, 2015, 01:53:26 AM »
Hi Kevin,

bear in mind that images are "sent" to the browser as <img> tags, not as the actual PNG or whatever file. The browser then sees the <img> tag, and makes a separate request to fetch the image.

I'm not sure what actual problem you are solving here, but I might be tempted to send all 5 images to the browser in the first place, and use JavaScript to just oscillate between them. Or even use the Carousel (with appropriate settings) to do all the timing and switching for you.

However if you want to persist with this approach (and there are a few cases where I think you would) then please make a small example and post it so I can take a look. I imagine the setup would need to be fairly precise.

cheers
Bruce