Whereas the PB government clearly states there are no plans to add an OOP-flavour to the language, it's possible to use an object-based syntax for coding.
It can be easily implemented using macros. Obviously, this complicates debugging, but nevertheless.
What do you think about writing this:
Code: Select all
_(window, w0, open(20,20,50,50,"My First Win"))
with w0
\size(300,200) :\color(RGB(255,230,230)) __
_(window, w1)
with w1
\open(400,10,400,100,"w1") :\color( w0\color()+100 ) :\timer(0,50) :\title("My Second Win")
s$= "!!!" :\title( s$ ) __
_(menu, m)
with m
\make(w0)
\title("Fruits") :\item(0,"Apples") :\bar() :\item(1,"Bananas") __
with m
\title("Props")
\sub("&Colors") :\item(10,"Red") :\item(11,"Green") :\item(12,"Blue") :\sub_()
\bar() :\item(13,"&More...") __
repeat
e = w1\waitEv()
If e=#PB_Event_Timer: w1\x( w1\x_()+1 ): w0\y( w0\y_()+1 ): EndIf
until e = cEv(CloseWindow)
end
Code: Select all
w0 = OpenWindow(#PB_Any, 20, 20, 50, 50, "My First Win", 0)
ResizeWindow(w0, #PB_Ignore, #PB_Ignore, 300, 200)
SetWindowColor(w0, RGB(255, 230, 230))
w1 = OpenWindow(#PB_Any, 400, 10, 400, 100, "w1", 0)
SetWindowColor(w1, GetWindowColor(w0)+100 )
AddWindowTimer(w1, 0, 50)
SetWindowTitle(w1, "MySecond Win")
s$="!!!"
SetWindowTitle(w1, GetWindowTitle(w1)+s$)
m = CreateMenu(#PB_Any, WindowID(w0))
MenuTitle("Fruits")
MenuItem(0, "Apples")
MenuBar()
MenuItem(1, "Bananas")
MenuTitle("Properties")
OpenSubMenu("&Colors")
MenuItem(10, "Red")
MenuItem(11, "Green")
MenuItem(12, "Blue")
CloseSubMenu()
MenuBar()
MenuItem(13, "&More...")
Repeat
e = WaitWindowEvent()
If e=#PB_Event_Timer
ResizeWindow(w1, WindowX(w1)+1, #PB_Ignore, #PB_Ignore,#PB_Ignore)
ResizeWindow(w0, #PB_Ignore, WindowY(w0)+1, #PB_Ignore,#PB_Ignore)
EndIf
Until e = #PB_Event_CloseWindow
End