From 35ced32e331ee29fda1642616c803637952f5b22 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 30 May 2025 14:27:29 +0900 Subject: Replace TRUE/FALSE with boolean values true/false - part 1 Signed-off-by: Michele Calgaro (cherry picked from commit a7f1e6e2552d9cdbb3d76bff089db522248b9a24) --- doc/html/tutorial1-12.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'doc/html/tutorial1-12.html') diff --git a/doc/html/tutorial1-12.html b/doc/html/tutorial1-12.html index 387e594de..34a6bd07a 100644 --- a/doc/html/tutorial1-12.html +++ b/doc/html/tutorial1-12.html @@ -186,9 +186,9 @@ widget is invisible. TQt guarantees that no harm is done when calling repaint() on a hidden widget.

    void  CannonField::newTarget()
     {
-        static bool first_time = TRUE;
+        static bool first_time = true;
         if ( first_time ) {
-            first_time = FALSE;
+            first_time = false;
             TQTime midnight( 0, 0, 0 );
             srand( midnight.secsTo(TQTime::currentTime()) );
         }
@@ -210,7 +210,7 @@ passed since midnight as a pseudo-random value.
 

First we create a static bool local variable. A static variable like this one is guaranteed to keep its value between calls to the function.

The if test will succeed only the first time this function is called -because we set first_time to FALSE inside the if block. +because we set first_time to false inside the if block.

Then we create the TQTime object midnight, which represents the time 00:00:00. Next we fetch the number of seconds from midnight until now and use it as a random seed. See the documentation for TQDate, -- cgit v1.2.3