Paradox Community

Items in pnews.paradox-programming

Subject:Re: PopUpMenu exceeds the limit
Date:Tue, 7 Aug 2018 14:02:25 -0400
From:"Steven Green" <greens@diamondsg.com>
Newsgroups:pnews.paradox-programming
I had an app with a few large popups, and the guy had been using 
menusetlimit() on-the-fly, with an occasional conflict.. I put the 
menusetlimit() in his startup process, no problems since then


--

Steven Green
Myrtle Beach, South Carolina, USA

http://www.OasisTradingPost.com

Collectibles and Memorabilia
Vintage Lego Sets and Parts
- and Paradox support, too
"Thies Grimm"  wrote in message news:5b69651d$1@pnews.thedbcommunity.com...


Hi there

I want to build a user Select via PopUpMenu

for example I read some data in a TCursor and let the user choose as many
values as he or she wants to choose.


so far everything works as desired.

after about 10 choices I get an error

The number of menu items has exceeded the limit set
p.addText(tc.(2), tc.(3))

Why? It works about 10 times, I empty the popUpMenu,
the menuSetLimit is set to 254. So what is wrong?


you might check it on your PC, creating a new script and paste the code.

Read it before you start it. :-)

There are to procs and one method

Thanks in advance

Thies




proc cpUserSelect(
            stTitle String,
            var tc TCursor
            )Logical
var
   pnt               Point
   p                  popUpMenu
   stChoice            String
endVar

   pnt = Point(1440,1440)

   tc.edit()

; // let the user choose as long as he or she wants tos do so
; // stop it, using okay, cancel ...
; //
   while 2> 1
      p.unassign()
      cpBuildPopUp(tc, p)

      stChoice = p.show(pnt.X(), pnt.Y())

      switch
         case stChoice = "Okay":       return True
         case stChoice = "Cancel":     errorLog(UserError, "Cancel")
                                       return False
         case stChoice.isblank():      errorLog(UserError, "No Choice")
                                       return False
         case tc.locate(2, stChoice):  if tc.(3) = MenuChecked then
                                          tc.(3) = MenuNotChecked
                                       else
                                          tc.(3) = MenuChecked
                                       endIf
                                       tc.unlockRecord()
         otherWise:                    errorLog(UserError, "nn error")
                                       return False
      endSwitch
   endWhile

   tc.endEdit()

   return True

endProc

proc cpBuildPopUp(
            var tc TCursor,
            var p PopUpMenu
            )Logical
var
   si                  SmallInt
endVar

   menuSetLimit(254)

   p.empty()
   si = 0

; // having a break every 40 lines
   scan tc:
      if si.mod(40) = 0 then
         p.addBreak()
         si = 0
      endIf
      si = si + 1

      p.addText(tc.(2), tc.(3))

   endScan

; // adding Okay and Cancel
   p.addSeparator()
   p.addText("Okay")
   p.addText("Abbrechen")


   return True
endProc

method run(var eventInfo Event)
var
   tc                  TCursor
   db                  DataBase
   itemSQL             SQL
   li                  LongInt
endVar

; // create some test data ==> tc

   enumRTLConstants(":priv:__tblRTLConstants.db")

   db.open("priv")
   li = MenuChecked
   itemSQL =
      SQL
         SELECT GroupName, ConstantName, ~li AS Choice
         FROM '__tblRTLConstants.db'
         WHERE GroupName like 'A%'
      endSQL
   itemSQL.wantInMemoryTCursor(Yes)
   if not itemSQL.executeSQL(db, tc) then
      errorShow()
      return
   endIf

; // ask the user
   if not cpUserSelect("RTLConstants", tc) then
      errorshow()
      return
   endIf

; // if succes ==>
   tc.instantiateView(":priv:__tblRTLConstantsChoice.db")
   tc.close()

endMethod





Copyright © 2004 thedbcommunity.com