Ooops
October 28, 2021, 16:08:39

Author Topic: Why do this code send up a Memory Access violation?  (Read 1640 times)

Offline bsisko

  • Full Member
  • ***
  • Posts: 127
Why do this code send up a Memory Access violation?
« on: February 14, 2018, 23:41:18 »
; Blitz3d  TButton object
; (C) 2018  CJW Enterprises


Main
End



; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function Main()
   Graphics 1024, 768, 32, 0
   Button1.TButton = Create.TButton("Start")
   Button1 = Show(Button1)
   While Not KeyHit(1)
      
   Wend
End Function
Type TButton
   Field Top
   Field BLeft
   Field Height
   Field Width
   Field BorderColor$
   Field FillColor$
   Field Caption$
   Field CapColor$
   Field TypeFont
   Field Button
   ;  On_Click()
   ;  Create()
   ;  Hide()
   ;  Show()
   ;  Free()   
   
End Type


Function Create.TButton(pText$, pTop = 5, pLeft = 5, pHeight = 20, pWidth = 100, pTColor$ = "000, 000, 000", pBorder$ = "255, 255, 255", pFill$ = "000, 000, 255")
   
   this.TButton = New TButton
   this\Top = pTop
   this\BLeft = pLeft
   this\Height = pTop + pHeight
   this\Width = pLeft + pWidth
   this\Caption$ = pText$
   this\CapColor$ = pTColor$
   this\BorderColor$ = pBorder$
   this\FillColor$ = pFill$
   ;  this/TypeFont   
   
   
   this\Button = CreateImage(this\Height, this\Width)
   SetBuffer ImageBuffer(Button)
   
   Red =   Int(Mid$(pFill$, 1, 3))
   Green = Int(Mid$(pFill$, 5, 3))
   Blue =  Int(Mid$(pFill$, 9, 3))
   Color Red, Green, Blue
   
   Rect (this\Top, this\BLeft, this\Width, this\Height, 1) 
   
   Red =   Int(Mid$(pFill$, 1, 3))
   Green = Int(Mid$(pFill$, 5, 3))
   Blue =  Int(Mid$(pFill$, 9, 3))
   Color Red, Green, Blue
   
   Rect (this\Top, this\BLeft, this\Width, this\Height, 0)
   
   Return this
End Function

Function Show.TButton( this.TButton )
   SetBuffer BackBuffer()
   DrawImage this\Button, 100, 100
   Flip
End Function
 :o
Prepare to be assimilated !  Resistance is futile!

https://www.youtube.com/channel/UCtF5_0dBPL5eSBerwlJCnPA

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: Why do this code send up a Memory Access violation?
« Reply #1 on: February 15, 2018, 01:51:15 »
Code: BlitzBasic
  1. SetBuffer ImageBuffer(this\Button) ;<<<<< Solved.
  2. ;SetBuffer ImageBuffer(Button) <<<< Error.
  3.  

Offline bsisko

  • Full Member
  • ***
  • Posts: 127
Re: Why do this code send up a Memory Access violation?
« Reply #2 on: February 17, 2018, 01:15:32 »
Thanks Yue.

I must have been sitting at the computer too long to miss that one!
Prepare to be assimilated !  Resistance is futile!

https://www.youtube.com/channel/UCtF5_0dBPL5eSBerwlJCnPA

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal