Jump to content

Calculating on the fly ?


Recommended Posts

This seems logical to me but not Autoit.

Calculating command on the fly ?

Example:

$Label1= GuiCtrlCreateLabel("Test1", 5, 30, 100, 15)

$Label2= GuiCtrlCreateLabel("Test2", 5, 45, 100, 15)

$Label3= GuiCtrlCreateLabel("Test3", 5, 60, 100, 15)

For $i = 1 to 3

GuiCtrlSetData ("$Label"&$i, "Result " & $i)

Next

My goal was to Set the data in the three labels. Autoit returned no error message and no results.

Any suggestions ?

Thank You in advance.

Bluhair

Link to comment
Share on other sites

Yet another way for your consideration.

#include <GUIConstantsEx.au3>

local  $width=500,$height=300,$Label1,$Label2,$Label3,$num=0

$hGui = GUICreate("GUI", $width, $height, -1, -1)
GUISetState()
$Label1= GuiCtrlCreateLabel("Test1", 5, 30, 100, 15)
$Label2= GuiCtrlCreateLabel("Test2", 5, 45, 100, 15)
$Label3= GuiCtrlCreateLabel("Test3", 5, 60, 100, 15)

; Because the labels were created sequencially, the labels' 
; identifiers (controlID) are numbered sequencially.
For $i = $Label1 to $Label3
    $num +=1
    GuiCtrlSetData ($i, "Result " & $num) ;$i being the controlID when label created.
Next

do
    sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...