Jump to content

1 To 100 Step 1


AlmarM
 Share

Recommended Posts

Why doesnt this work?

#include <GUIConstants.au3>

$GUI = GUICreate("Value Changer", 100, 100, -1, -1)
$Label = GUICtrlCreateLabel("", 10, 10, 30, 30)
$Button = GUICtrlCreateButton("Change Value", 10, 40)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Button
        For $i = 1 To 100 Step 1
            Next
        GUICtrlSetData($Label, $i)
    EndSelect
WEnd

If I press Change Value it will set the Label to: 101

Whats wrong :)

I think its just a newbie thing :P

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

  • Developers

The value of $i will be 101 when the for-next loop is ended ... so what is it you want it to do ?

by the way, please shorten your Sig some... save us all the scrolling effort... :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Done with sig

And I think I need to place ExitLoop somewhere?

EDIT:

I edited my script.

#include <GUIConstants.au3>

$GUI = GUICreate("Value Changer", 100, 100, -1, -1)
$Label = GUICtrlCreateLabel("", 10, 10, 30, 30)
$Button = GUICtrlCreateButton("Change Value", 10, 40)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Button
        For $i = 1 To 100 Step 1
        GUICtrlSetData($Label, $i)
    Next
    EndSelect
WEnd

He'll set the Value of the label to 100 from 1 realy fast...

Its like

1 50 100

Thats almost what I see :)

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

  • Developers

I have no idea what you want so cannot answer....

First define what it is you want to do when the button is pressed ..

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The Label = Empty

If u press the Button it will GUICtrlSetData the Label to 1 Then 2 Then 3 etc untill 100

So each timie u press the Button the value will be +1

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

  • Developers

ok ... add a sleep in there to give it time to repaint... something like:

For $i = 1 To 100 Step 1
                GUICtrlSetData($Label, $i)
                Sleep(50)
            Next

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

So each timie u press the Button the value will be +1

ahh change of requirements :)

No need for the loop then ...just:

GUICtrlSetData($Label, GUICtrlRead($Label) + 1)
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Ye or,

#include <GUIConstants.au3>

$GUI = GUICreate("Value Changer", 100, 100, -1, -1)
$Label = GUICtrlCreateLabel("", 10, 10, 30, 30)
$Button = GUICtrlCreateButton("Change Value", 10, 40)
GUISetState()
$i = 0
While $i < 100
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Button
        $i = $i +1
        GUICtrlSetData($Label, $I)
    EndSelect
WEnd
Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Ye or,

#include <GUIConstants.au3>

$GUI = GUICreate("Value Changer", 100, 100, -1, -1)
$Label = GUICtrlCreateLabel("", 10, 10, 30, 30)
$Button = GUICtrlCreateButton("Change Value", 10, 40)
GUISetState()
$i = 0
While $i < 100
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Button
        $i = $i +1
        GUICtrlSetData($Label, $I)
    EndSelect
WEnd
fast learner, congrats :)

I can do signature me.

Link to comment
Share on other sites

Ye or,

#include <GUIConstants.au3>

$GUI = GUICreate("Value Changer", 100, 100, -1, -1)
$Label = GUICtrlCreateLabel("", 10, 10, 30, 30)
$Button = GUICtrlCreateButton("Change Value", 10, 40)
GUISetState()
$i = 0
While $i < 100
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Button
        $i = $i +1
        GUICtrlSetData($Label, $I)
    EndSelect
WEnd
Yes this works as well but provides an unneeded variable and an extra line. Congratz on learning a little more on repetition. Don't forget to apply it to other repetitive actions as an option as well from now on and happy scripting :D.
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...