Needed to re-read the help

Just starting out? Need help? Post your questions and find answers here.
User avatar
kpeters58
Enthusiast
Enthusiast
Posts: 341
Joined: Tue Nov 22, 2011 5:11 pm
Location: Kelowna, BC, Canada

Needed to re-read the help

Post 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?
Last edited by kpeters58 on Wed Dec 30, 2020 6:36 am, edited 1 time in total.
PB 5.73 on Windows 10 & OS X High Sierra
User avatar
skywalk
Addict
Addict
Posts: 4221
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

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

Post by skywalk »

Okay?... :evil:
[ ] Descriptive Title?
[ ] Working code?
[ ] Use EnableExplicit?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
STARGÅTE
Addict
Addict
Posts: 2235
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

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

Post 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)
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

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

Post 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)
User avatar
kpeters58
Enthusiast
Enthusiast
Posts: 341
Joined: Tue Nov 22, 2011 5:11 pm
Location: Kelowna, BC, Canada

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

Post by kpeters58 »

Thanks Demivec -

should have read the help more thoroughly - thought it needed an existing image passed in :(
PB 5.73 on Windows 10 & OS X High Sierra
Post Reply