1. Berka Frenfert
  2. PowerBuilder
  3. Wednesday, 31 July 2019 07:07 AM UTC

The interval is not fixed to 1 second and it may be different at different times during the life time of an instance of the timing user object.

How do i increment an instance variable that hold maximum number of seconds since instance of the timing user object was created?

 

Accepted Answer
Berka Frenfert Accepted Answer Pending Moderation
  1. Tuesday, 6 August 2019 05:50 AM UTC
  2. PowerBuilder
  3. # Permalink

I think every idea completes on pretty much same trick "Make a hole in the bottom"

The missing part in timing object was "Every Second Counts". 

A child timing object inside parent timing object solves the date change issue. 

I have two timing objects:

1- uo_timing (The parent one that will be used everywhere for any time interval)

2- uo_everySecond (The child only for 1 second interval created inside parent uo_timing object )

The only itching part left behind is that the parent timing object (no matter what) IS NOT GOING TO  CREATE ITSELF. otherwise there was no need of uo_everySecond.

for example: everySecond = CREATE uo_timing will crash PowerBuilder in classic way if used in parent.

But good thing is, parent will kill its child before parent is dead. And that does not bother me because only parent will be created everywhere and not the child.

And the cream is the instance variable Counter in uo_everySecond

Double lifeSpan
lifeSpan = TAME.EverySecond.Counter

It will be the actual life span of a timing object in seconds regardless of how many times Start() or Stop() were called.

And seconds will be converted to anything minutes, days, weeks etc.

 

Thank you for letting me attach pbl

Attachments (1)
Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 31 July 2019 10:23 AM UTC
  2. PowerBuilder
  3. # 1

Why not save the start time in an instance variable. Then you can use the SecondsAfter function passing the instance variable and Now() to get the number of elapsed seconds.

Comment
  1. David Peace (Powersoft)
  2. Wednesday, 31 July 2019 15:56 PM UTC
we have PB services that run 24/7 using this datetime concepts, calculate the next action time and then wait till that point in date time arrives.
  1. Helpful
  1. Berka Frenfert
  2. Thursday, 1 August 2019 05:19 AM UTC
Does PB Service means restful or is it local service?
  1. Helpful
  1. Berka Frenfert
  2. Thursday, 1 August 2019 05:26 AM UTC
If i use Ronald's idea then i will have to do calculation when date changes. Wondering why SecondsAfter could not take a DateTime parameter. If someone have already written a function that takes DateTime parameter then please share the code.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.