1. Gene Kanten
  2. PowerBuilder
  3. Thursday, 30 May 2024 21:36 PM UTC

I'm having trouble understanding what the application object Idle function is expecting as an input parameter.

The documentation doesn't really say what the data type is and the only examples show using a literal.

Does it have to be a literal?

I want to pass a variable instead of a hard coded literal but I don't know if it's expecting an integer or a long.

I've tried both and both seem to work although not consistently.
Sometimes the first call fails but if I call it a second time it works.

I would like to use a long and cap the max time but not sure what's happening because some values fail.

It seems it might be related to the size of the actual value being used.
There also seems to be issues with integer overflow if the value exceeds what an integer can hold.

Does anyone have any insights into this function?

Using PowerBuilder 2022 Build 1892.

Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 31 May 2024 10:16 AM UTC
  2. PowerBuilder
  3. # 1

Hi.

First of all, I believe that Roland's Smith answer is accurate. The argument must be an integer. Of course, this isn't clearly documented. But the object browser shows: idle ( integer s ) retrurns integer.

Second, even if Idle(65535) returns 1 (in 2022 R3 3356 this isn't the case), what make you think that the timer of idle has been set to the value you provided? The only way to check if the value was set is to let the application trigger the event, and check when this happened.

Another point, while I used Idle in the past, I never had such a need to set it to a value > than the max value an integer can store (32767). Even 32767 = 32767/60/60=9.102 -> near 9 hours.

You can use a variable (of integer datatype). In that case the overflow can happen when assigning a value to the variable. If you use a variable, with larger capacity than integer, again an overflow will occur.

By the way, in PB 2022 R3 3356, Idle(65535) returns -1. Also:

integer li_err, li_value

li_value = 65539
messagebox("li_value", li_value) // returns 3

// I believe that idle(65539) is equal to:

idle(li_value)

// Which will set idle to 3 seconds.

Andreas.

Comment
  1. Andreas Mykonios
  2. Friday, 31 May 2024 10:56 AM UTC
From help:

* "Overflow of real, double, and decimal values causes errors at runtime."

* "Overflow of signed or unsigned integers and longs causes results to wrap. However, because integers are promoted to longs in calculations, wrapping does not occur until the result is explicitly assigned to an integer variable."

At least this is documented :-)

Andreas.
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 31 May 2024 10:59 AM UTC
Even worse, but thanks for clearing it up!

So some variables throw an exception and others don't. How typical :)
  1. Helpful
  1. Arnd Schmidt
  2. Friday, 31 May 2024 16:29 PM UTC
Hey... it's PowerBuilder! Kaboom!

No error, no warning, your responsibility.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 31 May 2024 08:07 AM UTC
  2. PowerBuilder
  3. # 2

Another example of the powerbuilder help file not being informative enough. It's a basic requirement to describe the types of arguments when documenting a function.

Comment
There are no comments made yet.
Gene Kanten Accepted Answer Pending Moderation
  1. Friday, 31 May 2024 04:42 AM UTC
  2. PowerBuilder
  3. # 3

I tried using uint but it fails with any value that exceeds 32767, which leads me to believe it's using an integer.

But if I use a literal, eg: Idle(65535) it works.

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 31 May 2024 03:03 AM UTC
  2. PowerBuilder
  3. # 4

I checked the Browser window and it says the argument to the Idle function is integer. 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 30 May 2024 21:43 PM UTC
  2. PowerBuilder
  3. # 5

I would use an UnsignedInteger (UInt) variable, since the argument value must be a whole number of seconds greater than or equal to zero. I've verified that the compiler accepts a UInt.

Comment
  1. John Fauss
  2. Thursday, 30 May 2024 21:52 PM UTC
The compiler accepts any of the integer data types as the argument value (UnsignedInteger, Integer, UnsignedLong, Long, LongLong, Longptr) to the Idle function.
  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.