Sign in to follow this  
Followers 0
autoitxp

simple math question

11 posts in this topic

#1 ·  Posted (edited)

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 this post


Link to post
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 :P

Share this post


Link to post
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]

$add = 3

$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

$add = 1 + $add

call("_next")

Case $msg = $prv

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

_prv()

EndSelect

Wend

func _prv()

_GUICtrlStatusBarSetText($StatusBar1,$add)

EndFunc

func _next()

_GUICtrlStatusBarSetText($StatusBar1,$add)

EndFunc

Share this post


Link to post
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]

$add = 3


$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
            $add = 1 + $add
            Call("_next")
        Case $msg = $prv

            If $add > $add - 1 Then $add -= 1
            _prv()


    EndSelect


WEnd

Func _prv()
    _GUICtrlStatusBarSetText($StatusBar1, $add)
EndFunc   ;==>_prv
Func _next()
    _GUICtrlStatusBarSetText($StatusBar1, $add)
EndFunc   ;==>_next

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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 this post


Link to post
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 this post


Link to post
Share on other sites

thanks dude i will try

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hi thanks man this method works

local $add = 3
local $add1 = $add

If  $add > $add1 -1 Then  $add -= 1
Edited by autoitxp

Share this post


Link to post
Share on other sites

lol? Anyone else think this is weird?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0