Loading ...
Sorry, an error occurred while loading the content.

problems with a program

Expand Messages
  • paullayer
    Hi everyone Stefan wrote me a routine. It worked fine, then I tried to use it a different part of the program. It is giving an error #Dhandle is invalid when
    Message 1 of 7 , Oct 13, 2009
    View Source
    • 0 Attachment
      Hi everyone

      Stefan wrote me a routine. It worked fine, then I tried to use it a different part of the program. It is giving an error #Dhandle is invalid when try to enter a message in the discription area. Can someone look at this and tell me what is wrong. Also how can I take the uppercase out of the description.

      Thank you paul

      Here is the code

      'use an array for the invoice items
      dim Items$(7,3)

      'usage of Items$ array
      ' Items$(x,1) ... Quantity
      ' Items$(x,2) ... Description
      ' Items$(x,3) ... Amount

      [setup.cominvoice.Window]
      NOMAINWIN

      '-----Begin code for #invoice

      WindowWidth = 1020
      WindowHeight = 660
      UpperLeftX=int((DisplayWidth-WindowWidth)/2)
      UpperLeftY=int((DisplayHeight-WindowHeight)/2)

      BackgroundColor$ = "green"
      ForegroundColor$ = "BLUE"
      TextboxColor$ = "WHITE"

      '-----Begin GUI objects code

      statictext #cominvoice.statictext2, "Hidden Greens", 330, 27, 365, 50
      statictext #cominvoice.statictext75, "Commerical Account", 370, 82, 270, 30
      'center heading
      stylebits #cominvoice.statictext2, _SS_CENTER, 0, 0, 0
      stylebits #cominvoice.statictext75, _SS_CENTER, 0, 0, 0

      statictext #cominvoice.statictext48, "Invoice #", 210, 142, 85, 20
      textbox #cominvoice.cominvoicenum, 310, 137, 105, 25
      statictext #cominvoice.statictext59, "Date", 530, 137, 45, 20
      textbox #cominvoice.date, 590, 137, 160, 25


      'allow only digits to be entered for the cominvoice#
      stylebits #cominvoice.cominvoicenum, _ES_NUMBER, 0, 0, 0

      statictext #cominvoice.statictext4, "Quantity", 200, 197, 80, 20
      statictext #cominvoice.statictext5, "Description", 410, 197, 100, 20
      statictext #cominvoice.statictext7, "Amount", 695, 197, 75, 20

      'center headings of columns
      stylebits #cominvoice.statictext4, _SS_CENTER, 0, 0, 0
      stylebits #cominvoice.statictext5, _SS_CENTER, 0, 0, 0
      stylebits #cominvoice.statictext7, _SS_CENTER, 0, 0, 0

      textbox #cominvoice.quan1, 210, 232, 35, 25
      textbox #cominvoice.desc1, 275, 232, 395, 25
      textbox #cominvoice.amou1, 690, 232, 100, 25
      textbox #cominvoice.quan2, 210, 262, 35, 25
      textbox #cominvoice.deac2, 275, 262, 395, 25
      textbox #cominvoice.amou2, 690, 262, 100, 25
      textbox #cominvoice.quan3, 210, 292, 35, 25
      textbox #cominvoice.desc3, 275, 292, 395, 25
      textbox #cominvoice.amou3, 690, 292, 100, 25
      textbox #cominvoice.quan4, 210, 322, 35, 25
      textbox #cominvoice.desc4, 275, 322, 395, 25
      textbox #cominvoice.amou4, 690, 322, 100, 25
      textbox #cominvoice.quan5, 210, 352, 35, 25
      textbox #cominvoice.desc5, 275, 352, 395, 25
      textbox #cominvoice.amou5, 690, 352, 100, 25
      textbox #cominvoice.quan6, 210, 382, 35, 25
      textbox #cominvoice.desc6, 275, 382, 395, 25
      textbox #cominvoice.amou6, 690, 382, 100, 25
      textbox #cominvoice.quan7, 210, 412, 35, 25
      textbox #cominvoice.desc7, 275, 412, 395, 25
      textbox #cominvoice.amou7, 690, 412, 100, 25

      'automatically convert description into uppercase
      stylebits #cominvoice.desc1, _ES_UPPERCASE, 0, 0, 0
      stylebits #cominvoice.desc2, _ES_UPPERCASE, 0, 0, 0
      stylebits #cominvoice.desc3, _ES_UPPERCASE, 0, 0, 0
      stylebits #cominvoice.desc4, _ES_UPPERCASE, 0, 0, 0
      stylebits #cominvoice.desc5, _ES_UPPERCASE, 0, 0, 0
      stylebits #cominvoice.desc6, _ES_UPPERCASE, 0, 0, 0
      stylebits #cominvoice.desc7, _ES_UPPERCASE, 0, 0, 0

      'right justify the amount values
      stylebits #cominvoice.amou1, _ES_RIGHT, 0, 0, 0
      stylebits #cominvoice.amou2, _ES_RIGHT, 0, 0, 0
      stylebits #cominvoice.amou3, _ES_RIGHT, 0, 0, 0
      stylebits #cominvoice.amou4, _ES_RIGHT, 0, 0, 0
      stylebits #cominvoice.amou5, _ES_RIGHT, 0, 0, 0
      stylebits #cominvoice.amou6, _ES_RIGHT, 0, 0, 0
      stylebits #cominvoice.amou7, _ES_RIGHT, 0, 0, 0

      statictext #cominvoice.statictext36, "Sub Total", 555, 447, 80, 20
      textbox #cominvoice.subtotal, 690, 442, 100, 25
      statictext #cominvoice.statictext38, "Dumping Fee", 555, 477, 120, 20
      textbox #cominvoice.dump, 690, 472, 100, 25
      statictext #cominvoice.statictext40, "Late Fees", 555, 507, 95, 20
      textbox #cominvoice.late, 690, 502, 100, 25
      statictext #cominvoice.statictext42, "Total Due", 555, 537, 100, 20
      textbox #cominvoice.totaldue, 690, 532, 100, 25

      'right justify the values and make the totals read-only
      stylebits #cominvoice.subtotal, _ES_RIGHT or _ES_READONLY, 0, 0, 0
      stylebits #cominvoice.dump, _ES_RIGHT, 0, 0, 0
      stylebits #cominvoice.late, _ES_RIGHT, 0, 0, 0
      stylebits #cominvoice.totaldue, _ES_RIGHT or _ES_READONLY, 0, 0, 0

      button #cominvoice.print,"PRINT",[prinv], UL, 275, 537, 55, 25
      button #cominvoice.cancel,"CANCEL",[STP], UL, 440, 537, 76, 25

      '-----End GUI objects code

      open "Comm Invoice Client" for window as #cominvoice
      #cominvoice "trapclose [STP]"
      print #cominvoice, "font arial 12"
      print #cominvoice.statictext2, "!font algerian 36"
      print #cominvoice.statictext75, "!font arial_black 16 bold"
      print #cominvoice.cominvoicenum, INVOICE
      print #cominvoice.date, DT$


      'set all amounts
      for i = 1 to 7
      handle$ = "#invoice.amou"; i
      #handle$ val(Items$(i, 3))
      next

      print #cominvoice.subtotal, SUBTOTAL
      #cominvoice.dump DF
      #cominvoice.late LF
      print #cominvoice.totaldue, TOTAL

      'place the cursor in the Invoice# field
      #cominvoice.cominvoicenum "!setfocus"

      'get Windows handles of controls, which update the totals
      'use a string for easy checking using INSTR()
      hCheckFocus$ = ""
      hCheckFocus$ = hCheckFocus$; " "; hwnd(#cominvoice.amou1); " "
      hCheckFocus$ = hCheckFocus$; " "; hwnd(#cominvoice.amou2); " "
      hCheckFocus$ = hCheckFocus$; " "; hwnd(#cominvoice.amou3); " "
      hCheckFocus$ = hCheckFocus$; " "; hwnd(#cominvoice.amou4); " "
      hCheckFocus$ = hCheckFocus$; " "; hwnd(#cominvoice.amou5); " "
      hCheckFocus$ = hCheckFocus$; " "; hwnd(#cominvoice.amou6); " "
      hCheckFocus$ = hCheckFocus$; " "; hwnd(#cominvoice.amou7); " "
      hCheckFocus$ = hCheckFocus$; " "; hwnd(#cominvoice.dump); " "
      hCheckFocus$ = hCheckFocus$; " "; hwnd(#cominvoice.late); " "

      TIMER 100, [CheckFocus]
      WAIT


      [CheckFocus]
      CallDLL #user32, "GetFocus", handle As ulong

      IF INSTR(hCheckFocus$, " "; handle; " ") > 0 THEN
      SUBTOTAL = 0

      'clear the array
      redim Items$(7,3)

      for i = 1 to 7
      Qhandle$ = "#cominvoice.quan"; i
      Dhandle$ = "#cominvoice.desc"; i
      Ahandle$ = "#cominvoice.amou"; i

      #Qhandle$ "!CONTENTS? Q$"
      #Dhandle$ "!CONTENTS? D$"
      #Ahandle$ "!CONTENTS? A"

      SUBTOTAL = SUBTOTAL + A

      Items$(i, 1) = Q$
      Items$(i, 2) = D$
      Items$(i, 3) = str$(A)
      next

      #cominvoice.dump "!CONTENTS? DF"
      #cominvoice.late "!CONTENTS? LF"

      TOTAL = SUBTOTAL + DF + LF
      PRINT #cominvoice.subtotal, SUBTOTAL
      PRINT #cominvoice.totaldue, TOTAL
      END IF
      WAIT
    • torpidai
      From what I can gather from running your proggy, remming the nomainwin and printing the variables and handlevars it produces, you just need to check through
      Message 2 of 7 , Oct 13, 2009
      View Source
      • 0 Attachment
        From what I can gather from running your proggy, remming the nomainwin and printing the variables and handlevars it produces, you just need to check through the help section in LB, check out the Handle variables and debug from there :)
      • Stefan Pendl
        ... To get rid of the handle error, you have forgotten to change one of the invoice handles to cominvoice as shown above. This was easy to spot, when running
        Message 3 of 7 , Oct 13, 2009
        View Source
        • 0 Attachment
          >
          > Hi everyone
          >
          > Stefan wrote me a routine. It worked fine, then I tried to
          > use it a different part of the program. It is giving an
          > error #Dhandle is invalid when try to enter a message in the
          > discription area. Can someone look at this and tell me what
          > is wrong. Also how can I take the uppercase out of the description.
          >
          > Thank you paul
          >

          ---snip

          >
          > 'automatically convert description into uppercase
          > stylebits #cominvoice.desc1, _ES_UPPERCASE, 0, 0, 0
          > stylebits #cominvoice.desc2, _ES_UPPERCASE, 0, 0, 0
          > stylebits #cominvoice.desc3, _ES_UPPERCASE, 0, 0, 0
          > stylebits #cominvoice.desc4, _ES_UPPERCASE, 0, 0, 0
          > stylebits #cominvoice.desc5, _ES_UPPERCASE, 0, 0, 0
          > stylebits #cominvoice.desc6, _ES_UPPERCASE, 0, 0, 0
          > stylebits #cominvoice.desc7, _ES_UPPERCASE, 0, 0, 0
          >

          ---snip

          >
          > 'set all amounts
          > for i = 1 to 7
          > handle$ = "#invoice.amou"; i
          > #handle$ val(Items$(i, 3))
          > next
          >

          To get rid of the handle error, you have forgotten to change one of the invoice handles to cominvoice as shown above.
          This was easy to spot, when running the program through the debugger in animate mode.
          You should really learn to use all the tools LB has to offer for debugging ;-)

          The paragraph quoted above has a comment about setting the description to upper case, so just remove that paragraph.

          ---
          Stefan Pendl

          Liberty BASIC Assist 4.03 ........ http://www.libertybasic.com/assist.html
          Liberty BASIC 4.04 public beta ... http://www.libertybasic.com/lb404b3setup.exe

          Windows Vista Home Premium 32-bit SP2
          AMD Turion X2 RM-70 2GHz, 4GB RAM
        • Stefan Pendl
          ... You may notice, the last handle quoted is misspelled, so an easy fix ;-) ... Stefan Pendl Liberty BASIC Assist 4.03 ........
          Message 4 of 7 , Oct 13, 2009
          View Source
          • 0 Attachment
            >
            > Hi everyone
            >
            > Stefan wrote me a routine. It worked fine, then I tried to
            > use it a different part of the program. It is giving an
            > error #Dhandle is invalid when try to enter a message in the
            > discription area. Can someone look at this and tell me what
            > is wrong. Also how can I take the uppercase out of the description.
            >
            > Thank you paul
            >

            ---snip

            >
            > textbox #cominvoice.quan1, 210, 232, 35, 25
            > textbox #cominvoice.desc1, 275, 232, 395, 25
            > textbox #cominvoice.amou1, 690, 232, 100, 25
            > textbox #cominvoice.quan2, 210, 262, 35, 25
            > textbox #cominvoice.deac2, 275, 262, 395, 25

            You may notice, the last handle quoted is misspelled, so an easy fix ;-)

            ---
            Stefan Pendl

            Liberty BASIC Assist 4.03 ........ http://www.libertybasic.com/assist.html
            Liberty BASIC 4.04 public beta ... http://www.libertybasic.com/lb404b3setup.exe

            Windows Vista Home Premium 32-bit SP2
            AMD Turion X2 RM-70 2GHz, 4GB RAM
          • Stefan Pendl
            ... In addition you need to turn the timer off, when closing the window or you will get into trouble. ... So your [STP] must include TIMER 0 at the beginning.
            Message 5 of 7 , Oct 13, 2009
            View Source
            • 0 Attachment
              > >
              > > Hi everyone
              > >
              > > Stefan wrote me a routine. It worked fine, then I tried to
              > > use it a different part of the program. It is giving an
              > > error #Dhandle is invalid when try to enter a message in the
              > > discription area. Can someone look at this and tell me what
              > > is wrong. Also how can I take the uppercase out of the description.
              > >
              > > Thank you paul
              > >
              >
              > ---snip
              >
              > >
              > > textbox #cominvoice.quan1, 210, 232, 35, 25
              > > textbox #cominvoice.desc1, 275, 232, 395, 25
              > > textbox #cominvoice.amou1, 690, 232, 100, 25
              > > textbox #cominvoice.quan2, 210, 262, 35, 25
              > > textbox #cominvoice.deac2, 275, 262, 395, 25
              >
              > You may notice, the last handle quoted is misspelled, so an
              > easy fix ;-)
              >

              In addition you need to turn the timer off, when closing the window or you will get into trouble.

              > open "Comm Invoice Client" for window as #cominvoice
              > #cominvoice "trapclose [STP]"

              So your [STP] must include TIMER 0 at the beginning.

              '---code start (watch for line wraps)
              [STP]
              timer 0

              ' code to gather the entered information

              close #cominvoice
              end 'or WAIT, if this is a helper window
              '---code end

              ---
              Stefan Pendl

              Liberty BASIC Assist 4.03 ........ http://www.libertybasic.com/assist.html
              Liberty BASIC 4.04 public beta ... http://www.libertybasic.com/lb404b3setup.exe

              Windows Vista Home Premium 32-bit SP2
              AMD Turion X2 RM-70 2GHz, 4GB RAM
            • paullayer
              Thanks Stefan. I don t write many programs so I don t study much of the features. Thanks Again Paul
              Message 6 of 7 , Oct 14, 2009
              View Source
              • 0 Attachment
                Thanks Stefan. I don't write many programs so I don't study much of the features.

                Thanks Again
                Paul






                --- In libertybasic@yahoogroups.com, "Stefan Pendl" <pendl2megabit@...> wrote:
                >
                > >
                > > Hi everyone
                > >
                > > Stefan wrote me a routine. It worked fine, then I tried to
                > > use it a different part of the program. It is giving an
                > > error #Dhandle is invalid when try to enter a message in the
                > > discription area. Can someone look at this and tell me what
                > > is wrong. Also how can I take the uppercase out of the description.
                > >
                > > Thank you paul
                > >
                >
                > ---snip
                >
                > >
                > > 'automatically convert description into uppercase
                > > stylebits #cominvoice.desc1, _ES_UPPERCASE, 0, 0, 0
                > > stylebits #cominvoice.desc2, _ES_UPPERCASE, 0, 0, 0
                > > stylebits #cominvoice.desc3, _ES_UPPERCASE, 0, 0, 0
                > > stylebits #cominvoice.desc4, _ES_UPPERCASE, 0, 0, 0
                > > stylebits #cominvoice.desc5, _ES_UPPERCASE, 0, 0, 0
                > > stylebits #cominvoice.desc6, _ES_UPPERCASE, 0, 0, 0
                > > stylebits #cominvoice.desc7, _ES_UPPERCASE, 0, 0, 0
                > >
                >
                > ---snip
                >
                > >
                > > 'set all amounts
                > > for i = 1 to 7
                > > handle$ = "#invoice.amou"; i
                > > #handle$ val(Items$(i, 3))
                > > next
                > >
                >
                > To get rid of the handle error, you have forgotten to change one of the invoice handles to cominvoice as shown above.
                > This was easy to spot, when running the program through the debugger in animate mode.
                > You should really learn to use all the tools LB has to offer for debugging ;-)
                >
                > The paragraph quoted above has a comment about setting the description to upper case, so just remove that paragraph.
                >
                > ---
                > Stefan Pendl
                >
                > Liberty BASIC Assist 4.03 ........ http://www.libertybasic.com/assist.html
                > Liberty BASIC 4.04 public beta ... http://www.libertybasic.com/lb404b3setup.exe
                >
                > Windows Vista Home Premium 32-bit SP2
                > AMD Turion X2 RM-70 2GHz, 4GB RAM
                >
              • Stefan Pendl
                ... Then it is more important to get used to the debugger, instead of waiting for hours to resolve such simple problems by others ;-) If you still can not
                Message 7 of 7 , Oct 14, 2009
                View Source
                • 0 Attachment
                  >
                  > Thanks Stefan. I don't write many programs so I don't study
                  > much of the features.
                  >
                  > Thanks Again
                  > Paul
                  >

                  Then it is more important to get used to the debugger, instead of waiting for hours to resolve such "simple" problems by others ;-)

                  If you still can not figure out what is wrong, you are always welcome to ask.

                  ---
                  Stefan Pendl

                  Liberty BASIC Assist 4.03 ........ http://www.libertybasic.com/assist.html
                  Liberty BASIC 4.04 public beta ... http://www.libertybasic.com/lb404b3setup.exe

                  Windows Vista Home Premium 32-bit SP2
                  AMD Turion X2 RM-70 2GHz, 4GB RAM
                Your message has been successfully submitted and would be delivered to recipients shortly.