Jump to content

Bit help?


Recommended Posts

Can someone post for each line that what it do? I need to learn bit.

#include <GUIConstants.au3>
#include <ButtonConstants.au3>

Opt("GUIOnEventMode", 1)

Global $SSB = StringSplit("1|2|3|4|5|6|7|8|9|-|0|+|/|*|.|C|%|=", "|"), $bX = 8, $bY = 40

$Form1 = GUICreate("Lc", 108, 233, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Form1)
GUISetBkColor(0xFFFF00)
$som = GUICtrlCreateInput("", 8, 8, 89, 21)
For $i = 1 To $SSB[0]
    GUICtrlCreateButton($SSB[$i], $bX, $bY, 27, 25, $BS_CENTER)
    GUICtrlSetOnEvent(-1, "Event")
    GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
    If Not Mod($i, 3) Then
        $bX = 8
        $bY += 32
    Else
        $bX += 32
    EndIf
Next
$SSB = 0
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch GUICtrlRead(@GUI_CtrlId)
        Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "."
            GUICtrlSetData($som,  GUICtrlRead($som) & GUICtrlRead(@GUI_CtrlId)) 
        Case "="
            If Execute(GUICtrlRead($som)) Then GUICtrlSetData($som, Execute(GUICtrlRead($som)))
        Case "C"
            GUICtrlSetData($som, "")
        Case "%"
           ;??? Percent, leave this one for you 
    EndSwitch
EndFunc

Func Close()
    Exit
EndFunc
Link to comment
Share on other sites

I read it but i still dont understand all. These r what i dont understand:

If Not Mod($i, 3) Then
        $bX = 8
        $bY += 32
    Else
        $bX += 32
    EndIf
Next
$SSB = 0
GUISetState(@SW_SHOW)

and

Switch GUICtrlRead(@GUI_CtrlId)
        Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "."
            GUICtrlSetData($som,  GUICtrlRead($som) & GUICtrlRead(@GUI_CtrlId)) 
        Case "="
            If Execute(GUICtrlRead($som)) Then GUICtrlSetData($som, Execute(GUICtrlRead($som)))
Link to comment
Share on other sites

I read it but i still dont understand all. These r what i dont understand:

If Not Mod($i, 3) Then
        $bX = 8
        $bY += 32
    Else
        $bX += 32
    EndIf
Next
$SSB = 0
GUISetState(@SW_SHOW)

Looks like that sets the variables depending on whether the iteration number is divisible by 3. It is setting up the X Y positions for the buttons. After setting up the buttons the button array is set to zero and the gui state is changed to show. This is necessary because the Help file says when initially created the state is hidden.

and

Switch GUICtrlRead(@GUI_CtrlId)
        Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "."
            GUICtrlSetData($som,  GUICtrlRead($som) & GUICtrlRead(@GUI_CtrlId)) 
        Case "="
            If Execute(GUICtrlRead($som)) Then GUICtrlSetData($som, Execute(GUICtrlRead($som)))
In the first case its appending the current choice to the end and showing it in the input block. In the second case its executing the statement in the input block and updating the input block with the result.
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...