PB_Any Generates Very Large Constant

Just starting out? Need help? Post your questions and find answers here.
jpotting
User
User
Posts: 12
Joined: Sat Jun 11, 2005 10:28 pm
Location: Texas, USA

PB_Any Generates Very Large Constant

Post by jpotting »

I'm trying to dynamically generate a form from a database using #PB_Any The code seemed to run fine (the form is generated) until I started to manipulate the created gadgets. Then I got the compile error "Very large constant...". So I added a Debug, and low and behold, the constants generated were 14086180, and similiar. I'm using both static and dynamic constants, the last enumerated constant was 61. Why is PB_Any generating such a large value.

The program is pretty big....so the following code is just the code used to generate the gadgets. It also requires the database to run, but here it is. Any help would be greatly appreciated.

Joy

Debug "LAST ENUM CONSTANT"
Debug #Image_Dimensions_ButtonDown

ILFilename.s = "DataFiles\Interactive.dbf"

hdbInteractive.l = xdbOpen(ILFilename, "")

IndexName.s="DataFiles\GadgetType.idx"
idxHandle.l = xdbOpenIndex(IndexName, hdbInteractive)
FormRSR.l = xdbSeek(hdbInteractive,idxHandle,"Form")
If FormRSR = XDBFALSE
Debug "NOT FOUND"

EndIf

;- Read Form Values

GadgetName.s = xdbFieldValue(hdbInteractive, "G_NAME", 0)
GadgetX.s = xdbFieldValue(hdbInteractive, "GADGET_X",0)
GadgetY.s = xdbFieldValue(hdbInteractive, "GADGET_Y",0)
GadgetWidth.s = xdbFieldValue(hdbInteractive, "G_WIDTH",0)
GadgetHeight.s = xdbFieldValue(hdbInteractive, "G_HEIGHT",0)
GadgetSkin.s = xdbFieldValue(hdbInteractive, "G_IMAGE",0)
TemplateName.s = xdbFieldValue(hdbInteractive, "TEMPLATE",0)

Debug "FORM"
Debug "Gadget No"
Debug "Gadget Height"
Debug GadgetHeight
Debug "Template Name"
Debug TemplateName
Debug "Gadget Name"
Debug GadgetName
Debug "Skin"
Debug GadgetSkin

;- Create Interactive Form

If OpenWindow(#Window_TemplateA_001, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), #PB_Window_BorderLess|#PB_Window_Invisible, TemplateName)
SetWindowCallback(@WindowCallback())
If CreateGadgetList(WindowID(#Window_TemplateA_001))
PureSkin(#Window_TemplateA_001, #Gadget_TemplateA_001_xPureSkin2, #Image_TemplateA_001_xPureSkin2, GadgetSkin,0)
AdvancedGadgetEvents(#True)

NoOfRecords = xdbRecordCount(hdbInteractive)

For x = 1 To NoOfRecords
xdbGetRecord(hdbInteractive, x)

GadgetType.s = xdbFieldValue(hdbInteractive, "G_TYPE", 0)
GadgetName = xdbFieldValue(hdbInteractive, "G_NAME", 0)
GadgetNo.s = xdbFieldValue(hdbInteractive, "G_NO",0)
GadgetX = xdbFieldValue(hdbInteractive, "GADGET_X",0)
GadgetY = xdbFieldValue(hdbInteractive, "GADGET_Y",0)
GadgetWidth = xdbFieldValue(hdbInteractive, "G_WIDTH",0)
GadgetHeight = xdbFieldValue(hdbInteractive, "G_HEIGHT",0)
FontName.s = xdbFieldValue(hdbInteractive, "FONTNAME",0)
FontYSize.s = xdbFieldValue(hdbInteractive, "FONTSIZE",0)
LabelText.s = xdbFieldValue(hdbInteractive, "VAL_TEXT",0)
GadgetVisible.s = xdbFieldValue(hdbInteractive, "G_SHOW",0)
TextColor.s = xdbFieldValue(hdbInteractive, "TXT_COLR",0)
BkgrdColor.s = xdbFieldValue(hdbInteractive, "BK_COLOR",0)
FieldText.s = xdbFieldValue(hdbInteractive, "FLD_VAL",0)
Alignment.s = xdbFieldValue(hdbInteractive, "G_ALIGN",0)
FontType.s = xdbFieldValue(hdbInteractive, "FONTTYPE",0)
ButtonType.s = xdbFieldValue(hdbInteractive, "VAL_TYPE",0)

If GadgetVisible = "Yes"
GNo = Val(GadgetNo)
If GadgetType = "Label"
FontYSizeSel = Val(FontYSize)
TextColorNew.l = Val(TextColor)
BkgrdColorNew.l = Val(BkgrdColor)
Select FontType
Case "Standard"
Select Alignment
Case "Left"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
Debug "SEE LABEL CONSTANT"
Debug Label(GNo)
;SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel))
Case "Center"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Center | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
Case "Right"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Right | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
EndSelect
Case "Italic"
Select Alignment
Case "Left"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , RGBTextColorNew, BkgrdColorNew)
SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
Case "Center"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Center | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
Case "Right"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Right | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
EndSelect
Case "Bold"
Select Alignment
Case "Left"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
Case "Center"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Center | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
Case "Right"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Right | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
EndSelect
Case "Bold/Italic"
Select Alignment
Case "Left"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
Case "Center"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Center | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
Case "Right"
Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Right | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
EndSelect
EndSelect
Debug "LABEL"
Debug GadgetName
EndIf
If GadgetType = "Field"
FontYSizeSel = Val(FontYSize)
TextColorNew.l = Val(TextColor)
BkgrdColorNew.l = Val(BkgrdColor)
Select FontType
Case "Standard"
Select Alignment
Case "Left"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
Case "Center"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Center | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
Case "Right"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Right | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
EndSelect
Case "Italic"
Select Alignment
Case "Left"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
Case "Center"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Center | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
Case "Right"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Right | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
EndSelect
Case "Bold"
Select Alignment
Case "Left"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
Case "Center"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Center | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
Case "Right"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Right | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
EndSelect
Case "Bold/Italic"
Select Alignment
Case "Left"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
Case "Center"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Center | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
Case "Right"
Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Right | #PB_String_BorderLess )
PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
EndSelect
EndSelect
Debug "Field"
Debug GadgetName
EndIf
If GadgetType = "Button"
FontYSizeSel = Val(FontYSize)
TextColorNew.l = Val(TextColor)
BkgrdColorNew.l = Val(BkgrdColor)
Select ButtonType
Case "Standard"
Button(GNo) = ButtonGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Button_MultiLine)
PureCOLOR_SetButtonColor(Button(GNo), TextColorNew, BkgrdColorNew)
Debug "Standard Button"
;SetGadgetFont(Button(GNo), LoadFont(#FFont_35, FontName, FontYSize))
Case "Image"
;Button(GadgetNo) = ButtonImageGadget(#PB_Any, GadgetX , GadgetY, GadgetWidth, GadgetHeight, FieldText, #PB_Font_Italic)
Button(GNo) = PVGadgets_TransparentButtonImageGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight),"Images\button_icon.bmp")
PureCOLOR_SetButtonColor(Button(GNo), TextColorNew, BkgrdColorNew)
Debug "Image Button"
;SetGadgetFont(Button(GNo), LoadFont(#FFont_35, FontName, FontYSize))
Case "Toggle"
Button(GNo) = ButtonGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Button_Toggle | #PB_Button_MultiLine)
PureCOLOR_SetButtonColor(Button(GNo), TextColorNew, BkgrdColorNew)
;SetGadgetFont(Button(GNo), LoadFont(#FFont_35, FontName, FontYSize))
Debug "Toggle button"
EndSelect
EndIf
EndIf
Next

PureSkinHide(#Window_TemplateA_001,0)
EndIf
EndIf
okasvi
Enthusiast
Enthusiast
Posts: 150
Joined: Wed Apr 27, 2005 9:41 pm
Location: Finland

Post by okasvi »

Hi,

I'm sorry that I can't help you, but you should really put code inside code tags and indent it... I would even try to look what is wrong just because im curious but now that there is new PB IDE without nice indenting which jaPBe had there isnt many who wants to go thru that code :(
jpotting
User
User
Posts: 12
Joined: Sat Jun 11, 2005 10:28 pm
Location: Texas, USA

Re: PB_Any Generates Very Large Constant

Post by jpotting »

Sorry, this is my first post. I'm not sure how to do that.
Last edited by jpotting on Wed Aug 24, 2005 7:22 am, edited 1 time in total.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

not that way. sorry i dont have time to look at it but i put it into japbe and did an auto-indent formation on it:

Code: Select all

Debug "LAST ENUM CONSTANT"
Debug #Image_Dimensions_ButtonDown

ILFilename.s = "DataFiles\Interactive.dbf"

hdbInteractive.l = xdbOpen(ILFilename, "")

IndexName.s="DataFiles\GadgetType.idx"
idxHandle.l = xdbOpenIndex(IndexName, hdbInteractive)
FormRSR.l = xdbSeek(hdbInteractive,idxHandle,"Form")
If FormRSR = XDBFALSE
  Debug "NOT FOUND"
  
EndIf

;- Read Form Values

GadgetName.s = xdbFieldValue(hdbInteractive, "G_NAME", 0)
GadgetX.s = xdbFieldValue(hdbInteractive, "GADGET_X",0)
GadgetY.s = xdbFieldValue(hdbInteractive, "GADGET_Y",0)
GadgetWidth.s = xdbFieldValue(hdbInteractive, "G_WIDTH",0)
GadgetHeight.s = xdbFieldValue(hdbInteractive, "G_HEIGHT",0)
GadgetSkin.s = xdbFieldValue(hdbInteractive, "G_IMAGE",0)
TemplateName.s = xdbFieldValue(hdbInteractive, "TEMPLATE",0)

Debug "FORM"
Debug "Gadget No"
Debug "Gadget Height"
Debug GadgetHeight
Debug "Template Name"
Debug TemplateName
Debug "Gadget Name"
Debug GadgetName
Debug "Skin"
Debug GadgetSkin

;- Create Interactive Form

If OpenWindow(#Window_TemplateA_001, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), #PB_Window_BorderLess|#PB_Window_Invisible, TemplateName)
  SetWindowCallback(@WindowCallback())
  If CreateGadgetList(WindowID(#Window_TemplateA_001))
    PureSkin(#Window_TemplateA_001, #Gadget_TemplateA_001_xPureSkin2, #Image_TemplateA_001_xPureSkin2, GadgetSkin,0)
    AdvancedGadgetEvents(#True)
    
    NoOfRecords = xdbRecordCount(hdbInteractive)
    
    For x = 1 To NoOfRecords
      xdbGetRecord(hdbInteractive, x)
      
      GadgetType.s = xdbFieldValue(hdbInteractive, "G_TYPE", 0)
      GadgetName = xdbFieldValue(hdbInteractive, "G_NAME", 0)
      GadgetNo.s = xdbFieldValue(hdbInteractive, "G_NO",0)
      GadgetX = xdbFieldValue(hdbInteractive, "GADGET_X",0)
      GadgetY = xdbFieldValue(hdbInteractive, "GADGET_Y",0)
      GadgetWidth = xdbFieldValue(hdbInteractive, "G_WIDTH",0)
      GadgetHeight = xdbFieldValue(hdbInteractive, "G_HEIGHT",0)
      FontName.s = xdbFieldValue(hdbInteractive, "FONTNAME",0)
      FontYSize.s = xdbFieldValue(hdbInteractive, "FONTSIZE",0)
      LabelText.s = xdbFieldValue(hdbInteractive, "VAL_TEXT",0)
      GadgetVisible.s = xdbFieldValue(hdbInteractive, "G_SHOW",0)
      TextColor.s = xdbFieldValue(hdbInteractive, "TXT_COLR",0)
      BkgrdColor.s = xdbFieldValue(hdbInteractive, "BK_COLOR",0)
      FieldText.s = xdbFieldValue(hdbInteractive, "FLD_VAL",0)
      Alignment.s = xdbFieldValue(hdbInteractive, "G_ALIGN",0)
      FontType.s = xdbFieldValue(hdbInteractive, "FONTTYPE",0)
      ButtonType.s = xdbFieldValue(hdbInteractive, "VAL_TYPE",0)
      
      If GadgetVisible = "Yes"
        GNo = Val(GadgetNo)
        If GadgetType = "Label"
          FontYSizeSel = Val(FontYSize)
          TextColorNew.l = Val(TextColor)
          BkgrdColorNew.l = Val(BkgrdColor)
          Select FontType
            Case "Standard"
              Select Alignment
                Case "Left"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                  Debug "SEE LABEL CONSTANT"
                  Debug Label(GNo)
                  ;SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel))
                Case "Center"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Center | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                Case "Right"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Right | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
              EndSelect
            Case "Italic"
              Select Alignment
                Case "Left"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , RGBTextColorNew, BkgrdColorNew)
                  SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
                Case "Center"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Center | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
                Case "Right"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Right | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
              EndSelect
            Case "Bold"
              Select Alignment
                Case "Left"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
                Case "Center"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Center | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
                Case "Right"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Right | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
              EndSelect
            Case "Bold/Italic"
              Select Alignment
                Case "Left"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
                Case "Center"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Center | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
                Case "Right"
                  Label(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), LabelText, #PB_Text_Right | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Label(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
              EndSelect
          EndSelect
          Debug "LABEL"
          Debug GadgetName
        EndIf
        If GadgetType = "Field"
          FontYSizeSel = Val(FontYSize)
          TextColorNew.l = Val(TextColor)
          BkgrdColorNew.l = Val(BkgrdColor)
          Select FontType
            Case "Standard"
              Select Alignment
                Case "Left"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                Case "Center"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Center | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                Case "Right"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Right | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
              EndSelect
            Case "Italic"
              Select Alignment
                Case "Left"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
                Case "Center"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Center | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
                Case "Right"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Right | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Italic))
              EndSelect
            Case "Bold"
              Select Alignment
                Case "Left"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
                Case "Center"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Center | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
                Case "Right"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Right | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
              EndSelect
            Case "Bold/Italic"
              Select Alignment
                Case "Left"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
                Case "Center"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Center | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
                Case "Right"
                  Field(GNo) = StringGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Text_Right | #PB_String_BorderLess )
                  PureCOLOR_SetGadgetColor(Field(GNo) , TextColorNew, BkgrdColorNew)
                  SetGadgetFont(Field(GNo), LoadFont(Field(GNo), FontName, FontYSizeSel, #PB_Font_Bold))
              EndSelect
          EndSelect
          Debug "Field"
          Debug GadgetName
        EndIf
        If GadgetType = "Button"
          FontYSizeSel = Val(FontYSize)
          TextColorNew.l = Val(TextColor)
          BkgrdColorNew.l = Val(BkgrdColor)
          Select ButtonType
            Case "Standard"
              Button(GNo) = ButtonGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Button_MultiLine)
              PureCOLOR_SetButtonColor(Button(GNo), TextColorNew, BkgrdColorNew)
              Debug "Standard Button"
              ;SetGadgetFont(Button(GNo), LoadFont(#FFont_35, FontName, FontYSize))
            Case "Image"
              ;Button(GadgetNo) = ButtonImageGadget(#PB_Any, GadgetX , GadgetY, GadgetWidth, GadgetHeight, FieldText, #PB_Font_Italic)
              Button(GNo) = PVGadgets_TransparentButtonImageGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight),"Images\button_icon.bmp")
              PureCOLOR_SetButtonColor(Button(GNo), TextColorNew, BkgrdColorNew)
              Debug "Image Button"
              ;SetGadgetFont(Button(GNo), LoadFont(#FFont_35, FontName, FontYSize))
            Case "Toggle"
              Button(GNo) = ButtonGadget(#PB_Any, Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), Val(GadgetHeight), FieldText, #PB_Button_Toggle | #PB_Button_MultiLine)
              PureCOLOR_SetButtonColor(Button(GNo), TextColorNew, BkgrdColorNew)
              ;SetGadgetFont(Button(GNo), LoadFont(#FFont_35, FontName, FontYSize))
              Debug "Toggle button"
          EndSelect
        EndIf
      EndIf
    Next
    
    PureSkinHide(#Window_TemplateA_001,0)
  EndIf
EndIf
jpotting
User
User
Posts: 12
Joined: Sat Jun 11, 2005 10:28 pm
Location: Texas, USA

Post by jpotting »

Thanks. I appreciate it.

Joy
jpotting
User
User
Posts: 12
Joined: Sat Jun 11, 2005 10:28 pm
Location: Texas, USA

Post by jpotting »

Still hoping for some help here. These large constants are causing the program to crash hard with a "Stack Overflow", when performing certain functions (See below). The error (in debug mode) says "#Gadget object number is very high (over 10000)".

I determine the gadget selected with event code...

Code: Select all

Event = EventType() 
       Select Event
           Case #PB_EventType_Focus             
               For n=1 To 100
                   If EventGadgetID()= Label(n) 
                        CurrentText = GetGadgetText(Label(n))
                        CurrentText= Chr(34) + CurrentText + Chr(34)
                        CreateThread(@LabelSetup(), n)
                   EndIf
               Next
No problem changing colors (the following works fine)

Code: Select all

       PureCOLOR_SetGadgetColor(Label(n),RGB(255,255,255), RGB(255,255,255))
BUT

Code: Select all

       FreeGadget(Label(n))  ; Only tried as a last resort
and

Code: Select all

      StringGadget(Label(n), Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), GWidth, LabelText)
and changing fonts

Code: Select all

      SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel))
all result in the error and a stack overflow.

I've tried reducing the program to just the code shown in the original post, to see if a lower value constant is generated, but the same constants are generated.

Do the Arrays affect the number of constants generated? Running out of ideas....been trying to fix this for 4 days.
okasvi
Enthusiast
Enthusiast
Posts: 150
Joined: Wed Apr 27, 2005 9:41 pm
Location: Finland

Post by okasvi »

if you use userlibraries on example code which generates errors you might want to tell us what you use, etc.

have you asked from author of the lib?

i havent ever had problems with #PB_Any
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: PB_Any Generates Very Large Constant

Post by PB »

> the constants generated were 14086180, and similiar

That's normal... read on.

> the last enumerated constant was 61. Why is PB_Any generating such
> a large value

Because when using #PB_Any, the value of the gadget is a handle, not a
constant. See this code for an example:

Code: Select all

If OpenWindow(1,300,250,400,200,#PB_Window_SystemMenu,"Window")
  CreateGadgetList(WindowID())
  b1=ButtonGadget(#PB_Any,50,50,60,25,"1")
  b2=ButtonGadget(#PB_Any,150,50,60,25,"2")
  Repeat
    ev=WaitWindowEvent()
    If ev=#PB_Event_Gadget
      Select EventGadgetID()
        Case b1 : Debug b1
        Case b2 : Debug b2
      EndSelect
    EndIf
  Until ev=#PB_EventCloseWindow
EndIf
Click the buttons, and you'll see where the large numbers come from, even
though only 2 gadgets were created. As for your "Very large constant"
error, what causes it to appear? Can you pinpoint the action that brings
up this error?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

"#Gadget object number is very high (over 10000)".
This error means that you have created a very high number of gadgets, it has nothing to do with the values of the handles.
jpotting
User
User
Posts: 12
Joined: Sat Jun 11, 2005 10:28 pm
Location: Texas, USA

Post by jpotting »

PB Moderator;

Thanks for your input. The specific action that causes the error happens when I try to modify the gadget. When a Label receives the focus, I iterate though a maximum of 100 items (the Label array), to find which gadget

Code: Select all

Event = EventType()
       Select Event
           Case #PB_EventType_Focus             
               For n=1 To 100
                   If EventGadgetID()= Label(n)
                        CurrentText = GetGadgetText(Label(n))
                        CurrentText= Chr(34) + CurrentText + Chr(34)
                        CreateThread(@LabelSetup(), n)
                   EndIf
               Next 
then call a threaded procedure which passes the value "n", and pops up a form to change, color, sizes etc for the gadget. From this popup another procedure performs the changes.

The color change procedure using pure_Color works fine.

Code: Select all

PureCOLOR_SetGadgetColor(Label(n),RGB(255,255,255), RGB(255,255,255)) 
The procedures that change dimensions or fonts (executes either of the following commands)....cause the error.

Code: Select all

 
StringGadget(Label(n), Val(GadgetX) , Val(GadgetY), Val(GadgetWidth), GWidth, LabelText) 

SetGadgetFont(Label(GNo), LoadFont(Label(GNo), FontName, FontYSizeSel))
Trond;
Thank you for responding. Point well taken...handles versus gadget ids.
This error means that you have created a very high number of gadgets, it has nothing to do with the values of the handles.
Yes, that's what I thought the error was ....but I can't seem to find out why. I use enumeration for all the procedures....i.e. 61 gadgets, outside of the dynamically created form. The form actually creates about 60 gadgets...a record that defines each gadget is maintained in the table. I use arrays for labels (Text), buttons and fields (Strings), of 100 each.....so a maximum of 300 gadets on a form. I actually set the arrays to 20 each to see if the error changed but it did not.

okasvi;
Thanks. The user libaries used are Pure_Color and Cheetah for the database of gadget characteristics.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

>> #Gadget object number is very high (over 10000)".
>
> This error means that you have created a very high number of gadgets

Actually, not quite -- it just means you're using a gadget number that is too
high. You could have only 1 gadget on a form and still get this error if you
reference it with the wrong number.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
jpotting
User
User
Posts: 12
Joined: Sat Jun 11, 2005 10:28 pm
Location: Texas, USA

Post by jpotting »

PB Moderator;
Thanks....that's insightful......So it appears that

Code: Select all

 PureCOLOR_SetGadgetColor(Label(n),RGB(255,255,255), RGB(255,255,255))
uses the Gadget handle. While the following does not. The handle being that large number, and it's looking for a gadget identifier.

Code: Select all

StringGadget(Label(n), x , y, Width, Height, LabelText) 
If so...can you get the PB identifier from the handle? The opposite of GadgetID() that will return the handle from the Gadget identifier?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> can you get the PB identifier from the handle?

Yep: Gadget_Constant = GetDlgCtrlID_(Gadget_hWnd)

(I still can't remember who originally posted this tip, sorry).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
jpotting
User
User
Posts: 12
Joined: Sat Jun 11, 2005 10:28 pm
Location: Texas, USA

Post by jpotting »

Thanks for all the help. I've resolved my problem.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I've resolved my problem

Don't leave us hanging... what did you do? :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Post Reply