“Null” method

“Null” method

I want to be able to start a section of code if nothing is happening in an application. This type of ‘null’ method is useful for default tasks. How can I do this?

What is the sound of one hand clapping?

Part of this question is addressed fairly easily, and part of the question is a slippery slope. To implement a null method, you need to be able to find a way to account for time in your application, since you will want to determine how long to wait for something to happen, as well as a definition of what “nothing happening” means.

The first part of the question can be handled by using the TestCommand() method. The TestCommand() method is called many times a second (I think it’s around 12 times a second) to test the status of menu items and push buttons in the tool bar. You can use this automatic function to implement an internal clock.

If you wanted to perform a particular action after the TestCommand() method had been executed 50 times, you would use code for the method that read like this:

STATIC nCount AS IntegernCount = nCount + 1IF nCount = 50 THEN        desired_actions         nCount = 0END IF

If you only wanted this code to execute if a certain condition were true, you could add a user-defined property, like udpTime, to the container which had TestCommand() method and modify the code to look like this:

udpTime = udpTime + 1IF updTime = 50 THEN        desired_actions         udpTime = 0END IF

By setting a user defined property instead of an internal variable, you let other methods access the value, so that when something happened, the action could change the value of the udpTime property to 0.

The problem now becomes philosophical. The basic premise behind client/server applications is that the application reacts to a user's actions. All applications spend a lot of time waiting for something to happen, and how you can translate that into some type of discrete action or method. If, for instance, you define 'nothing happening' as no movement through a recordset, you could reset the udpTime property whenever you changed the row in the recordset. But if you want to define all keystrokes or mouse movements as something happening, you would have to add code to a number of methods to reset the property.

In a client/server application, the concept of 'nothing happening' is always subject to change since a user can make something happen at any time, so the idea of waiting until you have an empty space may be difficult to implement. But if you were to use the same techniques for a more discrete action, such as rolling back a transaction if it had not been committed in a certain time frame, you would have a much better chance of realizing a good result.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes