11 Replies Latest reply on Feb 3, 2011 8:13 AM by raybaudi

    Live current time update on a form

    fluffyone

      Title

      Live current time update on a form

      Post

        Hey group

      If I have a field on a form that needs the current time kept up to date (ideally so the seconds are counting live) I can set up a script and have it refresh on keystroke, mouse click or most likely a loop to refresh often etc.. but I am worried this will tie up computer resources or delay database functions for other users. is this the best way to show the current live time always updated?

      regards Fluffy

        • 1. Re: Live current time update on a form
          raybaudi

          No.

          You'll have to use a web viewer.

          • 2. Re: Live current time update on a form
            Sorbsbuster

            I can't see any big problem with a time-resetting script triggered by common occurances such as a mouse-click, but as the triggering events aren't regular I think it might be a bit confusing for the users to see the time jump around.  I do see a problem with a looping script.  From memory, I believe that if FM is running a script it locks up everything until it is completed (and you can't even send it to the background to get on with something else).  You could check that with a script that runs for 30 seconds, say.  Sorry, I have no constructive suggestions from within FM, only exterior solutions like desktop widgets.  If we knew more about your application maybe there are ways around the requirement?

            • 3. Re: Live current time update on a form
              fluffyone

              Hi Thanks for your answers, raybaudi please confirm how a web browser can be used? are you saying that I should have the time displayed from the internet?

              regards Fluffy

              • 4. Re: Live current time update on a form
                raybaudi

                No, the time will be dispayed from your system and there will be no need of an internet connection.

                Put this code into the web viewer window:

                "data:text/html,
                <html>
                <head>
                <script type='text/javascript'>
                function startTime()
                {
                var today=new Date();
                var h=today.getHours();
                var m=today.getMinutes();
                var s=today.getSeconds();
                m=checkTime(m);
                s=checkTime(s);
                document.getElementById('time').innerHTML=h+':'+m+':'+s;
                t=setTimeout('startTime()',500)
                }
                function checkTime(i)
                { if ( i < 10 ) { i = '0' + i } return i }
                </script>
                <style type='text/css'>
                <!--body { background-color:rgb(204,204,255);margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;} -->
                </style>
                </head>
                <font size='4' face='Arial'>
                <body style='text-align:center; border:0; margin:0; padding:0; scrolling:auto'onload='startTime()'>
                <div id='time'></div>
                </font>
                </body>
                </html>"

                • 5. Re: Live current time update on a form
                  fluffyone

                  Hi Raybaudi

                  Brilliant! that is perfect can the date be added as well?

                  Thankyou 
                  Regards Fluffy

                   

                  • 6. Re: Live current time update on a form
                    raybaudi

                    I would prefer to use the date symbol ( // ) placed on the layout or an unstored calculation with Get( CurrentDate ).

                    • 7. Re: Live current time update on a form
                      Sorbsbuster

                      That's brilliant.  Any more tricks like that, that the web-viewer can be used for?

                      • 8. Re: Live current time update on a form
                        fluffyone

                        Hi Raybaudi

                        True this would be the best way to go. Just out of interest I have always thought of webbrowsers as a portal to a website, will they run any html code?

                        Thank you very much for your help on the time solution.

                        Regards Fluffy

                        • 9. Re: Live current time update on a form
                          raybaudi

                          The web viewer is a great tool.

                          You can insert any html code and any data, even a base64 picture.

                          • 10. Re: Live current time update on a form
                            fluffyone

                            Hi Raybaudi

                            Do I need to add anything else with the html code, as I had a little play messing about with some scrolling text and it wopuldn't work an error message came up saying there was some stuff missing like " or ) etc..

                            the code I tried to use (just for fun)

                            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                            <html lang="en">
                            <head>
                            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                            <meta name="Generator" content="Serif WebPlus X4 (12.0.3.029)">
                            <title>Home</title>
                            <style type="text/css">
                            <!--
                            body {margin: 0px; padding: 0px;}
                            a:link {color: #2c3651;}
                            a:visited {color: #1f5b8b;}
                            a:hover {color: #2c3651;}
                            a:active {color: #2c3651;}
                            -->
                            </style>
                            </head>
                             
                            <body text="#000000" style="background-color:#ffffff; text-align:center; height:90px;">
                            <div style="background-color:transparent;text-align:left;margin-left:auto;margin-right:auto;position:relative;width:275px;height:90px;">
                            <div style="position:absolute; left:0px; top:0px; width:275px; height:89px;">
                                <applet codebase="wpscripts" archive="SerifMarquee.jar" code="SerifMarquee.class" width="275" height="89" id="marq_1" name="marq_1">
                                    <param name="Global" value="FPS:60;BACKGROUND:0,0,0;">
                                    <param name="Event1" value="TYPE:TEXT;SPEED:4;TEXT:I like this very much;FONT:Arial;SIZE:25;STYLE:;COLOUR:255,255,255;POSITION:TOP;DIRECTION:LEFTWARDS;">
                                    <param name="Event2" value="TYPE:TEXT;SPEED:4;TEXT:and so do i ;FONT:Arial;SIZE:25;STYLE:;COLOUR:255,255,255;POSITION:MIDDLE;DIRECTION:RIGHTWARDS;">
                                </applet>
                            </div>
                            </div>
                            </body>
                            </html> 

                            • 11. Re: Live current time update on a form
                              raybaudi

                              Check that code, it must have something wrong.

                              BTW: to try a code in a simpler way, create a text field ( Html ) and place there that code. The web vievew calculation will have simply:

                              "data:text/html," & YourTable::Html