WinTask Fundamentals: Data Types and Conditionals

Introduction

Welcome to this tutorial on using loops in WinTask. In this session, we will demonstrate how to use While/Wend and Repeat/Until loops for automating repetitive tasks.

While/Wend Loop

The While/Wend loop is ideal for repeating actions while a condition is true. This loop checks the condition before executing the code inside it. For example, to count from 1 to 3 and display each number:


a = 0
While a < 5
 beep (100)
 a = a + 1
Wend

In this example, a is set to 0. While a is less than 5, it beeps and increments a by 1. The loop stops when a reaches 5.

Repeat/Until Loop

The Repeat/Until loop ensures the action occurs at least once before checking the condition. This loop is useful when you need to perform an action and then decide whether to continue. For instance, flipping a coin until it lands on heads:


repeat
 coin = Random(1)
 beep (100)
until coin = 1

This script flips a coin and beeps until it lands on heads, demonstrating the Repeat/Until loop's capability to handle uncertain outcomes.

Data Types

WinTask supports four main data types:

  1. Integers: 32-bit numbers. Example:
    
        a = 12
        qwerty = 3567
        
  2. Strings: Variable names ending with $. Example:
    
        a$ = "Hello"
        Name$ = "Here is a string variable name"
        
  3. Arrays: Unidimensional arrays of integers or strings. Example:
    
        Dim Tab(10)  ' Array with 11 integers (0 to 10)
        Dim Tab$(20) ' Array with 21 strings (0 to 20)
        Tab(1) = 3
        Tab$(2) = "Hello"
        
  4. Unsigned: Used for 32-bit memory addresses. Example:
    
        Dim Addr as Unsigned
        

If...Then...Else...EndIf

This structure allows conditional execution of code blocks. Example:


If a = 1 Then
 beep(100)
Else
 beep(200)
EndIf

Conclusion

Thank you for following this tutorial on using loops in WinTask. For more examples and help, check WinTask's help section. Also, see our Excel to Web automation video for practical applications of these loops.

For more tutorials, please like and subscribe to our channel. Have a great day!