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

about interfaces

by morosh Mon Nov 25, 2019 7:30 am

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: 49
Joined: Wed Feb 26, 2014 7:11 am

Re: about interfaces

by Danilo Mon Nov 25, 2019 2:10 pm

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

Re: about interfaces

by morosh Mon Nov 25, 2019 3:32 pm

Thanks Danilo!! I'll try that
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 3 guests