# what should be simple formula

## Recommended Posts

I need all of these to be true before it continues, or else it fails and does not continue. What am I doing wrong?

```;Should be working
If 2 > 1 Then
If 2 < 3 Then
If 4 > 3 Then
If 4 < 5 Then
MsgBox(0, "1", "Working")
EndIf
EndIf
EndIf
Else
MsgBox(0, "1", "NotWorking")
EndIf
;Should be notworking
If 2 > 1 Then
If 4 < 3 Then
If 4 > 3 Then
If 4 < 5 Then
MsgBox(0, "2", "NotWorking")
EndIf
EndIf
EndIf
Else
MsgBox(0, "2", "Working")
EndIf
;Should be notworking
If 1 > 2 Then
If 2 < 3 Then
If 2 > 3 Then
If 4 < 5 Then
MsgBox(0, "3", "NotWorking")
EndIf
EndIf
EndIf
Else
MsgBox(0, "3", "Working")
EndIf```
Edited by Hatcheda

##### Share on other sites

I need all of these to be true before it continues, or else it fails and does not continue. What am I doing wrong?

```;Should be working
If 2 > 1 Then
If 2 < 3 Then
If 4 > 3 Then
If 4 < 5 Then
MsgBox(0, "1", "Working")
EndIf
EndIf
EndIf
Else
MsgBox(0, "1", "NotWorking")
EndIf
;Should be notworking
If 2 > 1 Then
If 4 < 3 Then
If 4 > 3 Then
If 4 < 5 Then
MsgBox(0, "2", "NotWorking")
EndIf
EndIf
EndIf
Else
MsgBox(0, "2", "Working")
EndIf
;Should be notworking
If 1 > 2 Then
If 2 < 3 Then
If 2 > 3 Then
If 4 < 5 Then
MsgBox(0, "3", "NotWorking")
EndIf
EndIf
EndIf
Else
MsgBox(0, "3", "Working")
EndIf```
Obviously you can tell that 5 is greater than 4 and 2 is greater than 3 and 1 is lesser than 2. What are you trying to do.

##### Share on other sites

fixed

```;Should be working
If 2 > 1 Then
If 2 < 3 Then
If 4 > 3 Then
If 4 < 5 Then
MsgBox(0, "complete", "Working")
Else
MsgBox(0, "if 4", "NotWorking")
EndIf
Else
MsgBox(0, "if 3", "NotWorking")
EndIf
Else
MsgBox(0, "if 2", "NotWorking")
EndIf
Else
MsgBox(0, "if 1", "NotWorking")
EndIf```

*Edit* I will post the real thing in a few after I finish updating it.

Edited by Hatcheda

##### Share on other sites

here is what I was working on -if you move off the gui it gets smaller- if you move back to where it was it gets bigger

```Global \$ParentWin_Width = 450
Global \$ParentWin_Height = 700
Global \$ParentWin_Left = ((@DesktopWidth - \$ParentWin_Width) / 2)
Global \$Top = 25
Global \$ParentWin = GUICreate("Example", 450, \$ParentWin_Height, \$ParentWin_Left, \$Top)
Opt("GUIOnEventMode", 1)
HotKeySet("{ESC}", "_Custom_Exit")
GUISetState(@SW_SHOW, \$ParentWin)

While 1
Sleep(1000)
Global \$size = WinGetPos(\$ParentWin)
Global \$pos = MouseGetPos()

;MouseLeft < GuiLeft
If \$pos[0] > \$size[0] Then
;MouseRight > GuiRight
If \$pos[0] < (\$size[0] + \$size[2]) Then
;MouseTop < GuiTop
If \$pos[1] > \$size[1] Then
;MouseBottom > GuiBottom
If \$pos[1] < (\$size[1] + 500) Then
_Expand()
Else
;MsgBox(0, "if 4", "NotWorking")
_Colapse()
EndIf
Else
;MsgBox(0, "if 3", "NotWorking")
_Colapse()
EndIf
Else
;MsgBox(0, "if 2", "NotWorking")
_Colapse()
EndIf
Else
;MsgBox(0, "if 1", "NotWorking")
_Colapse()
EndIf
WEnd

Func _Colapse()
;WinMove ( "title", "text", x, y [, width [, height[, speed]]] )
If \$size[3] > 40 Then
For \$i = \$ParentWin_Height To 40 Step - 5
WinMove(\$ParentWin, "", \$size[0], \$size[1], \$size[2], \$i)
Next
EndIF
EndFunc   ;==>_Colapse
Func _Expand()
;MsgBox(0, "if 5", "working")
If \$size[3] = 40 Then
For \$i = 40 To \$ParentWin_Height Step 5
WinMove(\$ParentWin, "", \$size[0], \$size[1], \$size[2], \$i)
Next
EndIf
EndFunc   ;==>_Expand

Func _Custom_Exit()
Exit
EndFunc ;==> _exit()```

##### Share on other sites

Thats a really neat script, but a little slow.

##### Share on other sites

Just change the step to bump it up -I wanted it slower for appearance

##### Share on other sites

Why do I keep seeing people do this?

`\$ParentWin_Left = ((@DesktopWidth - \$ParentWin_Width) / 2)`

Did you know if you use Default for the X parameter it will be centered?

Also, you can use AND in your if statements. That will really cleanup your code here.

For example, try this for your While loop.

```While 1
Sleep(1000)
Global \$size = WinGetPos(\$ParentWin)
Global \$pos = MouseGetPos()

If \$pos[0] > \$size[0] And \$pos[0] < (\$size[0] + \$size[2]) And \$pos[1] > \$size[1] And \$pos[1] < (\$size[1] + 500) Then
_Expand()
Else
_Colapse()
EndIf
WEnd```

And your results confuse me a bit. The window expands when the mouse is in just about any area below it, was that intentional?

Otherwise neat idea.

Here's something I did a while ago that is similar in idea, but quite different in execution. This won't replicate your behaviour though, it's just similar.

```Global \$GUI_EVENT_CLOSE = -3
Global \$GUI_DOCKBORDERS = 102

Global \$iHeightExpand = 500, \$iHeightCollapse = 200
Global \$bCollapsed = True

\$hGui = GUICreate('Hover and expand', 200, 200, Default, 50)
GUICtrlCreateLabel('', 0, 0, 200, 200)
GUICtrlSetResizing(-1, \$GUI_DOCKBORDERS)
GUISetState()

Do
\$gc = GUIGetCursorInfo(\$hGui)
If Not @error Then
If \$gc[4] And \$bCollapsed Then
WinMove(\$hGui, '', Default, Default, Default, \$iHeightExpand)
\$bCollapsed = False
ElseIf Not \$gc[4] And Not \$bCollapsed Then
WinMove(\$hGui, '', Default, Default, Default, \$iHeightCollapse)
\$bCollapsed = True
EndIf
EndIf
\$gm = GUIGetMsg()
Until \$gm = \$GUI_EVENT_CLOSE```

##### Share on other sites

Hey, I have to run but I will test yours out later. -mine was just a first draft. I am thinking that I will duplicate the code for expansion if over a smaller area of the gui. (and area that will say 'Expand' but stay expanded if over anywhere. -Thanks for the info. I tried and but was getting errors so I needed to error proff it. -thats why the error stuff is there

I will update and edit this later!

Edited by Hatcheda

## Create an account

Register a new account