Jump to content

Real time clock calculations?


This topic is 3996 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello,

 

I've been using filemaker for quite some time and tried to use it to build a "backtimer" log for Live television applications.

 

however, after much searching, i cannot find a "real time running clock" function or plug in that allows a field to be updated with the "current time" in real time(system clock every second).

 

a script does now work for my application as i need to be able to use the database to type notes as the time calc runs in the background.

 

I have not been able to get a web viewer window to work because i still need a script to update the field every second.

 

In my search i have read several times that filemaker cannot do this.

 

I find this hard to believe.

 

Any help is much appreciated.

Thx,

Link to comment
Share on other sites

The best you can do natively in Filemaker is to calculate a time and then refresh a calculation/variable via some means of a Window Refresh or Record Commit.  I've built a system that gives local time in various time zones given a native UTC.  It doesn't need to be up to the second but it gives an accurate enough time for my needs.

Link to comment
Share on other sites

  • 1 month later...

Have you tried using the Data URL in the web viewer to create an html Countdown clock?  Then using the ObjectNameAtrributes to grab the content of the Web Viewer and parse out the time?

 

I haven't actually tried that, but in theory it seems like it might work.  I have used an online clock that updates in real time without a script trigger.

Link to comment
Share on other sites

Below is a sample code that works in the webviewer.  You can tweak it to pull the time/date from a field, or however you want to set it.

 

Name the webviewer with an Object name.  And use GetLayoutObjectAttribute ( "<ObjectName>" ; "Content" ). Replace <ObjectName> with your actual object name.  That will return the HTML that drives the visual.  You can parse out the Date/Time, and run a calculation against the current timestamp to calculate seconds and such.

"data:,
<!DOCTYPE html>
<html>
<script language="JavaScript">
TargetDate = "8/1/2013 8:00 PM";
BackColor = "black";
ForeColor = "palegreen";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "	%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.	";
FinishMessage = "It is finally here!";
</script>
<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script>
</html>"

This will give you something that looks like this:

post-90190-0-61083500-1366295882_thumb.j

 

You can tweak this to remove the border on the WebViewer, and reformat the style, and remove the unneeded time categories.

Link to comment
Share on other sites

GetLayoutObjectAttribute ( ObjectName ; Attribute )

 

ObjectName you give the Webviewer, in the Inspector.  Then you use that same name in the function.  That function will then return the full HTML.  You can parse out the target time using Middle () or something similar.  If you need help writing the calc to calculate the time, let us know and we can try to help.

Link to comment
Share on other sites

I'm almost there...

 

with GetLayoutObjectAttribute ( ObjectName ; "content" )

 

i do get the HTML from the web viewer.  however when i point the text function

at the part of the HTML where i think i should be, i just get the text of the HTML, not the resulting number.

 

i'm using this clock from Brian Dunning web page and it works perfect.

 

 

<html>

 <head>

 <title>JavaScript Clock</title>

 

 <style type="text/css">

 #clock { font-family: Arial, Helvetica, sans-serif; font-size: 0.8em; color: white; background-color: black; border: 2px solid purple; padding: 4px; }

 </style>

 

 <script type="text/javascript">

 <!--

 

 function init ( )

 {

   timeDisplay = document.createTextNode ( "" );

   document.getElementById("clock").appendChild ( timeDisplay );

 }

 

 function updateClock ( )

 {

   var currentTime = new Date ( );

 

   var currentHours = currentTime.getHours ( );

   var currentMinutes = currentTime.getMinutes ( );

   var currentSeconds = currentTime.getSeconds ( );

 

   // Pad the minutes and seconds with leading zeros, if required

   currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;

   currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

 

   // Choose either "AM" or "PM" as appropriate

   var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

 

   // Convert the hours component to 12-hour format if needed

   currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

 

   // Convert an hours component of "0" to "12"

   currentHours = ( currentHours == 0 ) ? 12 : currentHours;

 

   // Compose the string for display

   var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

 

   // Update the time display

   document.getElementById("clock").firstChild.nodeValue = currentTimeString;

 }

 

 // -->

 </script>

 

 </head>

 <body onload="updateClock(); setInterval('updateClock()', 1000 )">

 

 <div style="clear: both;"> </div>

 

 

  <div style="width: 10em; text-align: left; margin: 0px auto;">

   <span id="clock"> </span>

 </div>

 

 </body>

 </html>

 

 

Link to comment
Share on other sites

I think you may be over-thinking this.

 

You have your web viewer that displays the time for you.  That is only showing the system time on the machine you are using.  If you set a field with the time from Get ( CurrentTime ), it will populate with the same time that Web Viewer was showing when you ran the script.

 

The clock in the webviewer seems like it is just a cosmetic/visual thing for the user, correct?  What do you need to do with the time once you have it?

Link to comment
Share on other sites

I have the backtimer working with an ontimer install script.

however, with the script running at every 1 second interval, it renders the rest of the fields un-usable for data entry because the script leaves the active field to the get current time field.

thats why i'm looking for a real time function clock that calculations can be based on.

i need to use the database while the clock calculations are taking place in the background.

the web viewer concept is promising but i can't figure out how to extract the numerical values in real time.

thanks so much for your help.

 

added note: What do you need to do with the time once you have it?

 

 

the get (CurrentTime) function only grabs the time when you leave the field and return to it. or click on it.

i need to see a real time countdown clock for each record when it becomes the active record.

Link to comment
Share on other sites

What you haven't answered yet is what you are actually doing with it. You have told me what you think you need...I need to know what the purpose is.

 

Example:

"I need to see a real time countdown clock for each record when it becomes the active record"

  • My example above gave you that.  You need to tweak it to feed it the date you want, but it provides a countdown timer.
    • ​So that leads me to think you are doing something else with the timer. But I don't know what, so I can't help.

 

the get (CurrentTime) function only grabs the time when you leave the field and return to it. or click on it.

 

i need to see a real time countdown clock for each record when it becomes the active record.

 

Talk me through the process as you want it to work...like I have never see it before.  Or upload a sample file and tell me what it should be doing.  ( The key is knowing how the user is going to be using it )

Link to comment
Share on other sites

Ahhhh. what am i actually doing with it.

I am making a "Backtimer" for live television productions. it visibly does a  countdown to commercial break.

we have a specific start time and specific commercial break times that are listed on our rundown.

I import the rundown into Filemaker and get all of the segment times based on all of the item times.(simple calc's)

as we are doing the show, we could be over or under our target time for commercial break.

i need to be able to type notes and change item times in the active record while we are in the middle of that item.

this is where the script is killing me.  i cant type in the same window while the ontimer install script is running.

i can create a new window and stop the ontimer script in that window and edit every other record but the active record.  but that gets very clunky going back and forth between windows.

hit me with an email and i will email you a sample file.

 

[email protected]

 

 

Link to comment
Share on other sites

This topic is 3996 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.