about interfaces

Just starting out? Need help? Post your questions and find answers here.
morosh
Posts: 27
Joined: Mon Feb 02, 2015 7:48 pm

about interfaces

Post by morosh »

Hello:
I tried to translate an old PB example for implementing OOP, I didn't succeed, operator ? not supported, is there any other alternative for that?

thanks in advance

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Structure Rectangle2
  *vt
  x1.i
  x2.i
  y1.i
  y2.i
EndStructure

Procedure Draw_Rectangle(*this.Rectangle2)
Debug "inside draw"
EndProcedure

Procedure Delete_Rectangle(*this.Rectangle2)
Debug "inside delete"
EndProcedure

Interface Rectangle
  Draw()
  Delete()
EndInterface

Procedure New_Rect(x1.l, x2.l, y1.l, y2.l)
  *Rect.Rectangle2 = AllocateMemory(SizeOf(Rectangle2))
  If *Rect
    ;*Rect\vt = ?RectVT
    *Rect\x1 = x1
    *Rect\x2 = x2
    *Rect\y1 = y1
    *Rect\y2 = y2
  EndIf
 
ProcedureReturn *Rect
EndProcedure


OpenWindow(0, 0, 0, 900, 400, "OOP", #PB_Window_SystemMenu)

Rect.Rectangle = New_Rect(0, 10, 0, 20)

Rect\Draw()
Rect\Delete()

DataSection
  RectVT:
    Data.i @Draw_Rectangle()
    Data.i @Delete_Rectangle()
EndDataSection

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

User avatar
Danilo
Posts: 51
Joined: Wed Feb 26, 2014 7:11 am

Re: about interfaces

Post by Danilo »

cya,
...Danilo
morosh
Posts: 27
Joined: Mon Feb 02, 2015 7:48 pm

Re: about interfaces

Post by morosh »

Thanks Danilo!! I'll try that
Post Reply