Page 1 of 1

Needed to re-read the help

Posted: Mon Dec 28, 2020 12:15 am
by kpeters58

Code: Select all

  If DatabaseQuery(DatabaseHandle, SQLExpr)
    If NextDatabaseRow(DatabaseHandle)
      bytecount = DatabaseColumnSize(DatabaseHandle, ColIndex) 
      If bytecount > 0
        *membuffer = AllocateMemory(bytecount)
        If *membuffer
          tmpimage = CreateImage(#PB_Any, 10, 10)
          Debug tmpimage ; = 36950176
          GetDatabaseBlob(DatabaseHandle, ColIndex, *membuffer, bytecount)
          CatchImage(tmpimage, *membuffer, bytecount)
          SetGadgetState(ImageGadget, ImageID(tmpimage))
          FreeMemory(*membuffer)
        Else ; allocation error
          FinishDatabaseQuery(DatabaseHandle)
          ProcedureReturn #False
        EndIf  
      Else ; no data in column
        FinishDatabaseQuery(DatabaseHandle)
        ProcedureReturn #False
      EndIf  
    Else ; no record found
      FinishDatabaseQuery(DatabaseHandle)
      ProcedureReturn #False
    EndIf  
    FinishDatabaseQuery(DatabaseHandle)
    ProcedureReturn #True
  Else ; query failed
    ProcedureReturn #False
  EndIf
PB returns 36,950,176 as gadget number (all other gadgets in code not shown for this program are in that 30,000,000 range as well), yet
CatchImage() fails with '[ERROR] #Image object number is very high (over 100000), are You sure of that ?'

If I hard-code tmpImage to a value < 100,000, everything works just fine.

Looks like an error trap that should be no longer active? Did Fred bump up the number range for gadgets? Or am i missing something?

Re: Looks like a bug to me... Can you confirm?

Posted: Mon Dec 28, 2020 12:35 am
by skywalk
Okay?... :evil:
[ ] Descriptive Title?
[ ] Working code?
[ ] Use EnableExplicit?

Re: Looks like a bug to me... Can you confirm?

Posted: Mon Dec 28, 2020 12:39 am
by STARGĂ…TE

Code: Select all

          ; tmpimage = CreateImage(#PB_Any, 10, 10)
          ; Debug tmpimage ; = 36950176
          GetDatabaseBlob(DatabaseHandle, ColIndex, *membuffer, bytecount)
          tmpimage = CatchImage(#PB_Any, *membuffer, bytecount)

Re: Looks like a bug to me... Can you confirm?

Posted: Mon Dec 28, 2020 2:18 am
by Demivec
kpeters58 wrote:PB returns 36,950,176 as gadget number (all other gadgets in code not shown for this program are in that 30,000,000 range as well), yet
CatchImage() fails with '[ERROR] #Image object number is very high (over 100000), are You sure of that ?'

If I hard-code tmpImage to a value < 100,000, everything works just fine.

Looks like an error trap that should be no longer active? Did Fred bump up the number range for gadgets? Or am i missing something?
The error trap is to alert you that numbers generated by #PB_Any can't be used in place of the image# required by CatchImage(). You need to use either an image# or #PB_Any, not the number generated by a former use of #PB_Any.
If you use an image# with CatchImage() and there is already an image that exists with that image# it will be freed before a new image is assigned to that image#. If you want to do something similar with #PB_Any and have an image with a number (i.e. tmpimage) that was generated by using #PB_Any you have to use FreeImage(tmpimage) and then generate a new image# with #PB_Any and CatchImage().

Change this to

Code: Select all

tmpimage = CreateImage(#PB_Any, 10, 10)
Debug tmpimage ; = 36950176
GetDatabaseBlob(DatabaseHandle, ColIndex, *membuffer, bytecount)
CatchImage(tmpimage, *membuffer, bytecount)
To this:

Code: Select all

tmpimage = CreateImage(#PB_Any, 10, 10)
Debug tmpimage ; = 36950176
FreeImage(tmpimage)
GetDatabaseBlob(DatabaseHandle, ColIndex, *membuffer, bytecount)
tmpimage = CatchImage(#PB_Any, *membuffer, bytecount)

Re: Looks like a bug to me... Can you confirm?

Posted: Mon Dec 28, 2020 3:17 am
by kpeters58
Thanks Demivec -

should have read the help more thoroughly - thought it needed an existing image passed in :(