Jump to content

Problems with func()


bogQ
 Share

Recommended Posts

im on v3.2.12.1

HotKeySet("{1}", "k1")
Global $key1 = "s"
While 1
    key()
WEnd
Func key()
    If $key1 <> "s" Then
        $key1 += 1
    EndIf
    ToolTip($key1&"  ")
EndFunc

Func k1()
$key1 = -1
EndFunc

on tooltip i get 0 all the time :/

can someone comfirm this? or m i dooing something wrong?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

change {1} to 1

tryed that i still get 0 on tooltip

its like he only one time try "if" event

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

sry 4 duble post

when i done

Func k1()
$key1 = ""
EndFunc

its working, but not with

$key1 = -1

dont get it, can someone explaind diffrance?

and now this isnt working

HotKeySet("1", "k1")
Dim $key1 = "s"
While 1
    key()
WEnd
Func key()
    If Not $key1 = "s" Then
        $key1 += 1
    EndIf
    ToolTip($key1&"  ")
EndFunc

Func k1()
$key1 = ""
EndFunc

what m i dooing wrong

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

sry 4 duble post

when i done

Func k1()
$key1 = ""
EndFunc

its working, but not with

$key1 = -1

dont get it, can someone explaind diffrance?

and now this isnt working

HotKeySet("1", "k1")
Dim $key1 = "s"
While 1
    key()
WEnd
Func key()
    If Not $key1 = "s" Then
        $key1 += 1
    EndIf
    ToolTip($key1&"  ")
EndFunc

Func k1()
$key1 = ""
EndFunc

what m i dooing wrong

You are mixing strings and numbers, making loop too tight, changing more than one parameter at once...

Your first post code works just fine when do what LarryDalooza said.

- if you put $key1 = -1, all works well but you don't see tooltip with "-1" because it's changed to "0" before you can register it

- If Not $key1 = "s" Then - that's not right

Try this:

HotKeySet("1", "k1")
Dim $key1 = "s"
While 1
    Sleep(10)
    key()
WEnd
Func key()
    If Not ($key1 = "s") Then; If $key1 <> "s" Then
        $key1 += 1
    EndIf
    ToolTip($key1&"  ")
EndFunc

Func k1()
$key1 = -77
EndFunc

Do you know why does it stop on "0"?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Do you know why does it stop on "0"?

i dont know its 0 all the time only working when the data on var on func is more than 0 or ""

Func k1()

$key1 = 1

EndFunc

Func k1()

$key1 =""

EndFunc

my goal is that $key1 need to count from -10000 to +10000 (or maby lower and hier) so i cat set Global $key1 = "NUMBER" it ned to b a letter

and i still dono why its stoping at 0 maby it can b solved if i write if = 0 then var = var +1 but still i dono is this some kinde of bug or its mented to b like that?

sry 4 edit my kboard is kinda crazzy

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

i dont know its 0 all the time only working when the data on var on func is more than 0 or ""

Func k1()

$key1 = 1

EndFunc

Func k1()

$key1 =""

EndFunc

my goal is that $key1 need to count from -10000 to +10000 (or maby lower and hier) so i cat set Global $key1 = "NUMBER" it ned to b a letter

and i still dono why its stoping at 0 maby it can b solved if i write if = 0 then var = var +1 but still i dono is this some kinde of bug or its mented to b like that?

sry 4 edit my kboard is kinda crazzy

What bug? No bug.

HotKeySet("1", "k1")
Dim $key1 = "s"
While 1
    Sleep(10)
    key()
WEnd
Func key()
    If IsNumber($key1) Then
        $key1 += 1
    EndIf
    ToolTip($key1 & "  ")
EndFunc

Func k1()
$key1 = -1000
EndFunc

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

r you telling me that "s" is = 0?

:/

- numbers and + <> "s" but the 0 = "s"

is kinda crazzy when you look that "" <> "s"

im confused heare

(im not telling that you didnt help with your sugestions and that it isnt working, but i still dont understand why s = 0 but not = -1 or = 1 why i get this only on 0 but not on other numbers )

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

r you telling me that "s" is = 0?

:/

- numbers and + <> "s" but the 0 = "s"

is kinda crazzy when you look that "" <> "s"

im confused heare

(im not telling that you didnt help with your sugestions and that it isnt working, but i still dont understand why s = 0 but not = -1 or = 1 why i get this only on 0 but not on other numbers )

No, I'm telling you that 1 + "s" = 1

Here:

$a = 345
$b = "some string, even emty one"
MsgBox(0,"",$a + $B)

That is expected. It's not a bug or whatever.

Ti si bog? :P

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

No, I'm telling you that 1 + "s" = 1

Here:

$a = 345
$b = "some string, even emty one"
MsgBox(0,"",$a + $B)

That is expected. It's not a bug or whatever.

Ti si bog? :(

not working

$b = "some string, even emty one"
$a = 0

If $b <> $a Then MsgBox(0,"",$a + $b)

working

$b = "some string, even emty one"
$a = "0"
If $b <> $a Then MsgBox(0,"",$a + $b)

working

$b = "some string, even emty one"
$a = "-1"
If $b <> $a Then MsgBox(0,"",$a + $b)

working

$b = "some string, even emty one"
$a = -1
If $b <> $a Then MsgBox(0,"",$a + $b)

every time on original script i changed the "s" before compareing valyes, it seems that when i predefine $var it still holds the string mark on it or something else when its set to 0 valye :/

i maby dont like the result and i probably ned to reedit alot things now in script :/

ty 4 the support (trancexx: ovo je bre nepravilno, nemoj da zezas, ne moze i minus jedan i nula da daju razlicite rezultate na uporedjivanju ispravnosti, al aj sad nema veze, mozda sam lepo trebao da pocnem ovo cudo u ceu da radim, malo bi se vise namucio ali me nebi jedna nepravilna glupost kocila ceo dan i kostala prepravke svega, bdw ako imas nesto da dodas pisi pm :P )

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

You are really confusing yourself with difference between numbers and strings.

When AutoIt's engine meets mathematical operator then that what is left and right of it is converted to numbers and operated-on afterward.

$a = 1
$b = 2
$c = $a + $b

ConsoleWrite($c & @CRLF)

We will get 3.

Process goes something like this:

1. introducing $a

2. assigning $a with number 1

3. introducing $b

4. assigning $b with number 2

5. introducing $c

6. recognising mathematical operator +

7. converting $a to number $a = Number($a)

8. converting $b to number $b = Number($:P

9. adding two numbers

10. assigning $c with calculated number

11. etc...

Try converting some strings to numbers.

Now, for "<>". What is that?

That is comparison operator. You can use it both for strings and for numbers, but has somewhere different meaning (will explain).

Cause of this is existance of operator "==" (identical).

Examine this:

$a = 1
$b = 2
$c = $a + $b

If $c <> 5 Then ConsoleWrite($c & @CRLF)

and this:

$a = 1
$b = 2
$c = $a + $b

If Not($c = 5) Then ConsoleWrite($c & @CRLF)

That is how you see that. And that is ok, but only for numbers.

The other code should be:

$a = 1
$b = 2
$c = $a + $b

If Not($c == 5) Then ConsoleWrite($c & @CRLF)

And that is making all this mess for you. :(

<> means Not =

Thing with numbers is that equal sign (=) has the same effect as the identical sign (==).

Knowing this you can see what is the problem with this peace of code that you wrote. If there is chance that there will be strings involved in calculations then it's wrong to use "<>" creating implications.

Not this:

If $b <> $a Then MsgBox(0,"",$a + $b)

but this:

If Not ($b == $a) Then MsgBox(0,"",$a + $b)

For your case:

HotKeySet("1", "k1")
Dim $key1 = "s"
While 1
    Sleep(10)
    key()
WEnd
Func key()
    If Not ($key1 == "s") Then
        $key1 += 1
    EndIf
    ToolTip($key1 & "  ")
EndFunc

Func k1()
$key1 = -77
EndFunc

So, when I asked you "Do you know why does it stop on 0?" you should said "Yea, it's because I should be using == instead of =".

♡♡♡

.

eMyvnE

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...