# simple math question

## Recommended Posts

hi well i donno y im nt getting true results while using this method

If \$idrecord > \$idrecord Then \$idrecord -= 1

it works fine when use simple

If \$idrecord > 1 Then \$idrecord -= 1

i want to put somthing like this

\$idrecord = 3

\$idrecord > \$idrecord -1 then \$idrecord -= 1

but it returns not to 2

why is that help!!!!!!!!

REGARDS

sim

Edited by autoitxp

##### Share on other sites

?

What do you mean "it returns not to 2"?

`\$idrecord = 3`

So, we can replace \$idrecord with 3, right?

If 3 > 2 then 3-1

And we get 2 as a result

##### Share on other sites

yaa not to 2 and i dont want to replace \$idrecord to 3 coz \$idrecord will change time 2 time with other method

#include <GUIConstants.au3>

#Include <GuiStatusBar.au3>

Local \$gui

Local \$a_PartsText[3]

Local \$a_PartsRightEdge[3] = [200, 500, -1]

\$gui = GUICreate("Database Gui", 800,600)

\$StatusBar1 = _GUICtrlStatusBarCreate (\$gui, \$a_PartsRightEdge, \$a_PartsText)

\$next = GUICtrlCreateButton ("add", 100, 500,100)

\$prv = GUICtrlCreateButton ("subtract", 300, 500,100)

GUISetState (@SW_SHOW)

While 1

\$msg = GUIGetMsg()

Select

Case \$msg = \$GUI_EVENT_CLOSE

ExitLoop

Case \$msg = \$next

call("_next")

Case \$msg = \$prv

_prv()

EndSelect

Wend

func _prv()

EndFunc

func _next()

EndFunc

##### Share on other sites

I was just showing you an example of how your script is working.

I have no idea what you are trying to do, but this adds and substracts the number in the status bar:

```#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>
Local \$gui
Local \$a_PartsText[3]
Local \$a_PartsRightEdge[3] = [200, 500, -1]

\$gui = GUICreate("Database Gui", 800, 600)
\$StatusBar1 = _GUICtrlStatusBarCreate(\$gui, \$a_PartsRightEdge, \$a_PartsText)
\$next = GUICtrlCreateButton("add", 100, 500, 100)
\$prv = GUICtrlCreateButton("subtract", 300, 500, 100)

GUISetState(@SW_SHOW)

While 1

\$msg = GUIGetMsg()

Select
Case \$msg = \$GUI_EVENT_CLOSE
ExitLoop
Case \$msg = \$next
Call("_next")
Case \$msg = \$prv

_prv()

EndSelect

WEnd

Func _prv()
EndFunc   ;==>_prv
Func _next()
EndFunc   ;==>_next```

You'll need to speak clrearer, i can't really understand what you say.

##### Share on other sites

well this is not subtracting any thing i want to subtract 1 from current value of \$add

`If \$add > \$add Then \$add -= 1`

and this method acsseed 1 to -1 when call previous button

`If \$add > \$add -1  Then \$add -= 1`

and this works fine but its not subtracting current value of \$add

`If \$add > 1  Then \$add -= 1`

hope u got this time

Edited by autoitxp

##### Share on other sites

Hello autoitxp,

the symbol ">" is for comparing *two* values. So you will need two different variables.

`If \$add > \$add Then \$add -= 1`

Here, there is only one value, "\$add", so this can not work. The variable \$add can never be

bigger than \$add, at the same time (line of code).

`If \$add > \$add -1  Then \$add -= 1`

In this example, comparing \$add with \$add-1 is useless, as this will always be true, so you

would simply write \$add -= 1, but thats not what you want, i guess.

`If \$add > 1  Then \$add -= 1`

This will work correct, if \$add > 1.

I think you would need a second variable as a reference, to compare it to \$add.

##### Share on other sites

thanks dude i will try

##### Share on other sites

Hi thanks man this method works

```local \$add = 3

Edited by autoitxp

##### Share on other sites

lol? Anyone else think this is weird?

##### Share on other sites

I do, its making my brain hurt.. I don't understand this at all. Sorry...

##### Share on other sites

\$idrecord = 3

\$idrecord > \$idrecord -1 then \$idrecord -= 1

but it returns not to 2

why is that help!!!!!!!!

REGARDS

sim

If you put the IF in front of the second line then it works as expected, though it's pointless.

```\$idrecord = 3
If \$idrecord > \$idrecord -1 then \$idrecord -= 1
consolewrite(\$idrecord);<--shows 2```

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

## Create an account

Register a new account