Sicro wrote:Apparently you have misunderstood me. I have my first post provided with better example codes.
I understood you fine, which is why I said:
Julian wrote:Optional params can be awkward, specifying #PB_Ignore is clearer, for the sake of a couple of keystokes...
Sicro wrote:Julian wrote:ResizeWindow half does it:
Why "half does it"? In ResizeWindow() and ResizeGadget(), the parameters can be set identical.
I said ResizeWindow only half does it because the manual mentions
If 'x' or 'y' is set to #PB_Ignore, the current value of 'x' or 'y' won't be changed.
and
If 'Width' or 'Height' is set to #PB_Ignore, the current value of 'Width' or 'Height' won't be changed.
Which would seem is an error in the documentation.
As I said originally, Optional params can be awkward, specifying #PB_Ignore is clearer, for the sake of a couple of keystokes. They are awkward because you still need to specify a value (100 or #PB_Ignore) for the optional params before you get to the last one. Let me elaborate:
ResizeWindow(0, 100, #PB_Ignore, #PB_Ignore, #PB_Ignore) can only be reduced to ResizeWindow(0, 100) if you want to change x
ResizeWindow(0, #PB_Ignore, 100, #PB_Ignore, #PB_Ignore) can only be reduced to ResizeWindow(0, #PB_Ignore, 100) if you want to change y
ResizeWindow(0, #PB_Ignore, #PB_Ignore, 100, #PB_Ignore) can only be reduced to ResizeWindow(0, #PB_Ignore, #PB_Ignore, 100) if you want to change w
ResizeWindow(0, #PB_Ignore, #PB_Ignore, #PB_Ignore, 100) can only be reduced to ResizeWindow(0, #PB_Ignore, #PB_Ignore, #PB_Ignore, 100) if you want to change h
I assume you want this so you can just change single params on their own? If you want to change single params only their own why dont you make 4 macros?
Code: Select all
Macro ResizeWindowX(Window, X)
ResizeWindow(Window, X, #PB_Ignore, #PB_Ignore, #PB_Ignore)
EndMacro
Macro ResizeWindowY(Window, Y)
ResizeWindow(Window, #PB_Ignore, Y, #PB_Ignore, #PB_Ignore)
EndMacro
Macro ResizeWindowW(Window, W)
ResizeWindow(Window, #PB_Ignore, #PB_Ignore, W, #PB_Ignore)
EndMacro
Macro ResizeWindowH(Window, H)
ResizeWindow(Window, #PB_Ignore, #PB_Ignore, #PB_Ignore, H)
EndMacro
Now you have all the time saving of your requested optional params. In fact, its a lot simpler because you don't have to specify a load of #PB_Ignore's
Code: Select all
Macro ResizeWindowX(Window, X)
ResizeWindow(Window, X, #PB_Ignore, #PB_Ignore, #PB_Ignore)
EndMacro
Macro ResizeWindowY(Window, Y)
ResizeWindow(Window, #PB_Ignore, Y, #PB_Ignore, #PB_Ignore)
EndMacro
Macro ResizeWindowW(Window, W)
ResizeWindow(Window, #PB_Ignore, #PB_Ignore, W, #PB_Ignore)
EndMacro
Macro ResizeWindowH(Window, H)
ResizeWindow(Window, #PB_Ignore, #PB_Ignore, #PB_Ignore, H)
EndMacro
OpenWindow(0, 0, 0, 200, 200, "test", #PB_Window_SystemMenu)
AddWindowTimer(0, 0, 2000)
Define.i event, state
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Timer
Select state
Case 0
;ResizeWindow(0, 100, #PB_Ignore, #PB_Ignore, #PB_Ignore)
ResizeWindowX(0, 100)
state = 1
Case 1
;ResizeWindow(0, #PB_Ignore, 100, #PB_Ignore, #PB_Ignore)
ResizeWindowY(0, 100)
state = 2
Case 2
;ResizeWindow(0, #PB_Ignore, #PB_Ignore, 400, #PB_Ignore)
ResizeWindowW(0, 400)
state = 3
Case 3
;ResizeWindow(0, #PB_Ignore, #PB_Ignore, #PB_Ignore, 400)
ResizeWindowH(0, 400)
state = 4
Case 4
RemoveWindowTimer(0, 0)
CloseWindow(0)
Break
EndSelect
EndIf
ForEver
PS. I added case4 so you can see the last test.