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

Re: [libertybasic] Re: SIMPLE

Expand Messages
  • henriknilson
    Thank you John ... From: John Subject: [libertybasic] Re: SIMPLE To: libertybasic@yahoogroups.com Date: Thursday, September 30,
    Message 1 of 17 , Oct 1, 2010
      Thank you John


      --- On Thu, 9/30/10, John <john_siejkowski@...> wrote:


      From: John <john_siejkowski@...>
      Subject: [libertybasic] Re: SIMPLE
      To: libertybasic@yahoogroups.com
      Date: Thursday, September 30, 2010, 3:03 AM



      Like this??

      nomainwin
      WindowWidth = 600
      WindowHeight = 300
      TEXTBOX #A.txtbox, 100,140,60,50
      STATICTEXT #A "Input 1=", 30, 140, 60, 25
      STATICTEXT #A "Input 2=", 30, 165, 60, 25
      GRAPHICBOX #A.textresult, 100, 40, 400, 50
      BUTTON #A.Default, "Calculate",[enter],UL, 100, 200,70 , 25
      OPEN "TEXTBOX" FOR DIALOG AS #A
      #A "trapclose [quit]"
      #A "font Times_New_Roman 12"
      #A.txtbox "100"; chr$(13); chr$(10); "200"
      a=20
      b=30
      #A.txtbox a; chr$(13); chr$(10);b
      wait
      [enter]
      PRINT #A.txtbox, "!contents? a$"
      a1=val(word$(a$,1))
      b1=val(word$(a$,2))
      #A.textresult "place 5 25"
      #A.textresult "\Input 1= "; a1;space$(5); " Input 2= ";b1;space$(5);"Multiplication= ";a1*b1;
      wait
      [quit]
      CLOSE #A
      END

      John "Psycho" Siejkowski

      --- In libertybasic@yahoogroups.com, Henrik <henriknilson@...> wrote:
      >
      > Thanks a lot John, I have modified the code lightly, now is it possible to have the results written horizontally instead of vertically, I would like to learn how to control the locations please.
      > ‘The Code
      > nomainwin
      > WindowWidth = 600
      > WindowHeight = 300
      > TEXTBOX #A.txtbox, 100,140,60,50
      > STATICTEXT #A "Input 1=", 30, 140, 60, 25
      > STATICTEXT #A "Input 2=", 30, 165, 60, 25
      > GRAPHICBOX #A.textresult, 100, 40, 400, 80
      > BUTTON #A.Default, "Calculate",[enter],UL, 100, 200,70 , 25
      > OPEN "TEXTBOX" FOR DIALOG AS #A
      > #A "trapclose [quit]"
      > #A "font Times_New_Roman 12"
      > #A.txtbox "100"; chr$(13); chr$(10); "200"
      > a=20
      > b=30
      > #A.txtbox a; chr$(13); chr$(10);b
      > wait
      > [enter]
      > PRINT #A.txtbox, "!contents? a$"
      > a1=val(word$(a$,1))
      > b1=val(word$(a$,2))
      > #A.textresult "place 5 25"
      > #A.textresult "\Input 1= "; a1;
      > #A.textresult "\Input 2= "; b1;
      > #A.textresult "\Multiplication= ";a1*b1;
      > wait
      > [quit]
      > CLOSE #A
      > END
      >
      > Â
      >
      > --- On Thu, 9/30/10, John <john_siejkowski@...> wrote:
      >
      >
      > From: John <john_siejkowski@...>
      > Subject: [libertybasic] Re: SIMPLE
      > To: libertybasic@yahoogroups.com
      > Date: Thursday, September 30, 2010, 12:25 AM
      >
      >
      > Â
      >
      >
      >
      > Take your modified code from Stefan and get the contents of the textbox as a string, then parse the variables with word$:
      >
      > 'The code
      > nomainwin
      > WindowWidth = 400
      > WindowHeight = 300
      > TEXTBOX #A.txtbox, 100,140,60,50
      > STATICTEXT #A "Input 1=", 30, 140, 60, 25
      > STATICTEXT #A "Input 2=", 30, 165, 60, 25
      > GRAPHICBOX #A.textresult, 100, 40, 160, 80
      > BUTTON #A.Default, "Calculate",[enter],UL, 100, 200,70 , 25
      > OPEN "TEXTBOX" FOR DIALOG AS #A
      > #A "trapclose [quit]"
      > #A "font Times_New_Roman 12"
      > #A.txtbox "100"; chr$(13); chr$(10); "200"
      > a=20
      > b=30
      > #A.txtbox a; chr$(13); chr$(10);b
      > wait
      > [enter]
      > PRINT #A.txtbox, "!contents? a$"
      > a1=val(word$(a$,1))
      > b1=val(word$(a$,2))
      > #A.textresult "place 5 25"
      > #A.textresult "\Input 1= "; a1;
      > #A.textresult "\Input 2= "; b1;
      > #A.textresult "\Multiplication= ";a1*b1;
      > wait
      > [quit]
      > CLOSE #A
      > END
      >
      > John "Psycho" Siejkowski
      >
      > --- In libertybasic@yahoogroups.com, "henriknilson" <henriknilson@> wrote:
      > >
      > >
      > > Thank you so much Stefan, I have developed your code to the following. It is working correctly even if I change the value of "a" and "b" to whatever. But if I deactivate variable "a" and "b", and use copy for instance the following variables
      > > 6
      > > 7
      > > Or any other values, and past it inside the txtbox then I noticed that variable "a" will be ok, but variable b "input 2" will be zero. It takes only the first variable.
      > > Is there any solution for that, to use copy and paste inside the txtbox and have corrected result by having the second variable correct.
      > > Please.
      > >
      > > 'The code
      > > nomainwin
      > > WindowWidth = 400
      > > WindowHeight = 300
      > > TEXTBOX #A.txtbox, 100,140,60,50
      > > STATICTEXT #A "Input 1=", 30, 140, 60, 25
      > > STATICTEXT #A "Input 2=", 30, 165, 60, 25
      > > GRAPHICBOX #A.textresult, 100, 40, 160, 80
      > > BUTTON #A.Default, "Calculate",[enter],UL, 100, 200,70 , 25
      > > OPEN "TEXTBOX" FOR DIALOG AS #A
      > > #A "trapclose [quit]"
      > > #A "font Times_New_Roman 12"
      > > '#A.txtbox "100"; chr$(13); chr$(10); "200"
      > > a=20
      > > b=30
      > > 'a=20
      > > 'b=30
      > > #A.txtbox a; chr$(13); chr$(10);b
      > > wait
      > > [enter]
      > > PRINT #A.txtbox, "!contents? a"
      > > 'PRINT #A.txtbox, "!contents? b"
      > > #A.textresult "place 5 25"
      > > '#A.textresult "place 15 25"
      > > #A.textresult "\Input 1= "; a;
      > > #A.textresult "\Input 2= "; b;
      > > #A.textresult "\Multiplication= ";a*b;
      > > wait
      > > [quit]
      > > CLOSE #A
      > > END
      > >
      > >
      > > > I know that John, you can have as many textboxs as number of
      > > > individual variables, my question was, is it possible to have
      > > > many variables in one textbox?
      > > > Thanks
      > > >
      > >
      > > You can fill the text box with separated lines, but it will be hard for the user to achieve this.
      > >
      > > '---code start (watch for line wraps)
      > > 'The code
      > > nomainwin
      > > WindowWidth = 400
      > > WindowHeight = 300
      > > TEXTBOX #A.txtbox, 100,120,60,50
      > > STATICTEXT #A "Input 1=", 30, 120, 60, 25
      > > STATICTEXT #A "Input 2=", 30, 145, 60, 25
      > > OPEN "TEXTBOX" FOR DIALOG AS #A
      > > #A "trapclose [quit]"
      > > #A "font Times_New_Roman 12"
      > > #A.txtbox "100"; chr$(13); chr$(10); "200"
      > > wait
      > > [quit]
      > > CLOSE #A
      > > END
      > >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    • henriknilson
      Ok Stefan, if it is wrong from a GUI point of view, then can we use copy and paste for the following values inside the two txtboxs just by one step, i.e. to
      Message 2 of 17 , Oct 1, 2010
        Ok Stefan, if it is wrong from a GUI point of view, then can we use copy and paste for the following values inside the two txtboxs just by one step, i.e. to put the curser on the upper txtbox and past two variables, the first one would be in the upper txtbox and the second would be in the lower txtbox."just by one step"
        There are some serials of some software accept this way although the boxes are arranged horizontally in this case.
        Thank you

        The variables are:
        7
        11


        'The code
        nomainwin
        WindowWidth = 400
        WindowHeight = 300
        TEXTBOX #A.txtbox1, 100,140,60,25
        TEXTBOX #A.txtbox2, 100,170,60,25
        STATICTEXT #A "Input 1=", 30, 140, 60, 25
        STATICTEXT #A "Input 2=", 30, 165, 60, 25
        GRAPHICBOX #A.textresult, 100, 40, 160, 80
        BUTTON #A.Default, "Calculate",[enter],UL, 100, 230,70 , 25
        OPEN "TEXTBOX" FOR DIALOG AS #A
        #A "trapclose [quit]"
        #A "font Times_New_Roman 12"

        '#A.txtbox1 "40"
        '#A.txtbox2 "10"

        wait
        [enter]
        PRINT #A.txtbox1, "!contents? a"
        PRINT #A.txtbox2, "!contents? b"
        #A.textresult "place 5 25"
        #A.textresult "\Input 1= "; a;
        #A.textresult "\Input 2= "; b;
        #A.textresult "\Multiplication= ";a*b;
        wait
        [quit]
        CLOSE #A
        END



        > Thanks a lot John, I have modified the code lightly, now is
        > it possible to have the results written horizontally instead
        > of vertically, I would like to learn how to control the
        > locations please.

        Even if you are insisting of using one single text box to collect two values from the user, it is plain wrong from a GUI point of
        view.
        In addition it adds another layer of complexity to the whole thing.

        Using two separate text boxes to collect two separate values from the user is the preferred way.
        You just have to ask each text box for its contents and there is no parsing involved.

        ---
        Stefan Pendl
        http://stefanpendl.runbasichosting.com/

        Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
        Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

        Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

        Books at http://www.lulu.com/ and http://www.amazon.com/
        Alyce Watson ... APIs for Liberty BASIC
        Carl Gundel .... Beginning Programming with Liberty BASIC

        Windows 7 Home Premium 64-bit RTM
        AMD Turion X2 RM-70 2GHz, 4GB RAM
      • Stefan Pendl
        ... Please test the following example: ---code start (watch for line wraps) nomainwin WindowWidth = 400 WindowHeight = 300 TEXTBOX #A.txtbox1, 100,140,60,25
        Message 3 of 17 , Oct 2, 2010
          >
          > Ok Stefan, if it is wrong from a GUI point of view, then can
          > we use copy and paste for the following values inside the two
          > txtboxs just by one step, i.e. to put the curser on the upper
          > txtbox and past two variables, the first one would be in the
          > upper txtbox and the second would be in the lower
          > txtbox."just by one step"
          > There are some serials of some software accept this way
          > although the boxes are arranged horizontally in this case.
          > Thank you
          >
          > The variables are:
          > 7
          > 11
          >

          Please test the following example:

          '---code start (watch for line wraps)
          nomainwin
          WindowWidth = 400
          WindowHeight = 300
          TEXTBOX #A.txtbox1, 100,140,60,25
          TEXTBOX #A.txtbox2, 100,170,60,25
          STATICTEXT #A "Input 1=", 30, 140, 60, 25
          STATICTEXT #A "Input 2=", 30, 165, 60, 25
          GRAPHICBOX #A.textresult, 100, 40, 160, 80
          BUTTON #A.Default, "Calculate",[enter],UL, 100, 230,70 , 25
          OPEN "TEXTBOX" FOR DIALOG AS #A
          #A "trapclose [quit]"
          #A "font Times_New_Roman 12"

          #A.txtbox1 "!contents? OldEntry$"
          #A.txtbox1 "!setfocus"

          timer 100, [IsChanged]
          wait

          [IsChanged]
          #A.txtbox1 "!contents? Entry$"

          if Entry$ <> OldEntry$ then
          #A.txtbox1 word$(Entry$, 1)
          #A.txtbox2 word$(Entry$, 2)
          #A.txtbox1 "!contents? OldEntry$"
          end if
          wait

          [enter]
          PRINT #A.txtbox1, "!contents? a"
          PRINT #A.txtbox2, "!contents? b"
          #A.textresult "place 5 25"
          #A.textresult "\Input 1= "; a;
          #A.textresult "\Input 2= "; b;
          #A.textresult "\Multiplication= ";a*b;
          wait

          [quit]
          CLOSE #A
          END
          '---code end

          ---
          Stefan Pendl
          http://stefanpendl.runbasichosting.com/

          Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
          Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

          Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

          Books at http://www.lulu.com/ and http://www.amazon.com/
          Alyce Watson ... APIs for Liberty BASIC
          Carl Gundel .... Beginning Programming with Liberty BASIC

          Windows 7 Home Premium 64-bit RTM
          AMD Turion X2 RM-70 2GHz, 4GB RAM
        • Henrik
          Thank you Stefan, but may I ask you why the value of timer is 100? I change it for trial to 1 and to1000 to see the effect, with 1 the paste will be faster in
          Message 4 of 17 , Oct 2, 2010
            Thank you Stefan, but may I ask you why the value of timer is 100?
            I change it for trial to 1 and to1000 to see the effect, with 1 the paste will be faster in compression with 1000. But the results are correct by the two values.
            Could we have your comment please.
             
             

            --- On Sat, 10/2/10, Stefan Pendl <pendl2megabit@...> wrote:


            From: Stefan Pendl <pendl2megabit@...>
            Subject: RE: [libertybasic] SIMPLE
            To: libertybasic@yahoogroups.com
            Date: Saturday, October 2, 2010, 7:25 AM


             



            >
            > Ok Stefan, if it is wrong from a GUI point of view, then can
            > we use copy and paste for the following values inside the two
            > txtboxs just by one step, i.e. to put the curser on the upper
            > txtbox and past two variables, the first one would be in the
            > upper txtbox and the second would be in the lower
            > txtbox."just by one step"
            > There are some serials of some software accept this way
            > although the boxes are arranged horizontally in this case.
            > Thank you
            >
            > The variables are:
            > 7
            > 11
            >

            Please test the following example:

            '---code start (watch for line wraps)
            nomainwin
            WindowWidth = 400
            WindowHeight = 300
            TEXTBOX #A.txtbox1, 100,140,60,25
            TEXTBOX #A.txtbox2, 100,170,60,25
            STATICTEXT #A "Input 1=", 30, 140, 60, 25
            STATICTEXT #A "Input 2=", 30, 165, 60, 25
            GRAPHICBOX #A.textresult, 100, 40, 160, 80
            BUTTON #A.Default, "Calculate",[enter],UL, 100, 230,70 , 25
            OPEN "TEXTBOX" FOR DIALOG AS #A
            #A "trapclose [quit]"
            #A "font Times_New_Roman 12"

            #A.txtbox1 "!contents? OldEntry$"
            #A.txtbox1 "!setfocus"

            timer 100, [IsChanged]
            wait

            [IsChanged]
            #A.txtbox1 "!contents? Entry$"

            if Entry$ <> OldEntry$ then
            #A.txtbox1 word$(Entry$, 1)
            #A.txtbox2 word$(Entry$, 2)
            #A.txtbox1 "!contents? OldEntry$"
            end if
            wait

            [enter]
            PRINT #A.txtbox1, "!contents? a"
            PRINT #A.txtbox2, "!contents? b"
            #A.textresult "place 5 25"
            #A.textresult "\Input 1= "; a;
            #A.textresult "\Input 2= "; b;
            #A.textresult "\Multiplication= ";a*b;
            wait

            [quit]
            CLOSE #A
            END
            '---code end

            ---
            Stefan Pendl
            http://stefanpendl.runbasichosting.com/

            Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
            Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

            Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

            Books at http://www.lulu.com/ and http://www.amazon.com/
            Alyce Watson ... APIs for Liberty BASIC
            Carl Gundel .... Beginning Programming with Liberty BASIC

            Windows 7 Home Premium 64-bit RTM
            AMD Turion X2 RM-70 2GHz, 4GB RAM











            [Non-text portions of this message have been removed]
          • Henrik
            Hello Stefan Following to my previous message, I tried to have the following code working ok but it does not, the first column of txtboxes “time” is
            Message 5 of 17 , Oct 2, 2010
              Hello Stefan
              Following to my previous message, I tried to have the following code working ok but it does not, the first column of txtboxes “time” is working ok but the second column of “distance” doesn’t. I tried to modify your code in a right way.
              Could you please help by copying the following variables, each group to its txtboxes, so that the code will work ok.  Thank you.
              Times
              10
              20
              30
              40
              50
              Distances
              100
              200
              300
              400
              500
              The code
               nomainwin
              WindowWidth = 600
              WindowHeight = 400
              BUTTON #A.1 "Quit", [quit],UL, 500, 300, 70, 25
              BUTTON #A.Default, " Calculate ",[enter],UL, 400,300 , 70, 25
              TEXTBOX #A.txtbox1, 10,60,50,25
              TEXTBOX #A.txtbox2, 10,100,50,25
              TEXTBOX #A.txtbox3, 10,140,50,25
              TEXTBOX #A.txtbox4, 10,180,50,25
              TEXTBOX #A.txtbox5, 10,220, 50, 25
              TEXTBOX #A.txtbox6, 70,60,50,25
              TEXTBOX #A.txtbox7, 70,100,50,25
              TEXTBOX #A.txtbox8, 70,140,50,25
              TEXTBOX #A.txtbox9, 70,180,50,25
              TEXTBOX #A.txtbox10, 70,220, 50, 25
              STATICTEXT #A "time", 20,25, 250, 25
              STATICTEXT #A "distance", 70,25, 250, 25
              GRAPHICBOX #A.textresult, 180, 60, 300, 180
              OPEN "Velocity" FOR DIALOG AS #A
              #A "trapclose [quit]"
              #A "font Times_New_Roman 12"
              #A.textresult "place 5 15 "
              #A.textresult "\";"time"
              #A.textresult "\";"-----------------------------------------------------"
              #A.textresult "place 90 15 "
              #A.textresult "\";"distance "
              #A.textresult "place 180 15 "
              #A.textresult "\";"velocity"
              #A.txtbox1 "!contents? OldEntry$"
              #A.txtbox1 "!setfocus"
              timer 100, [time]
              wait
              [time]
              #A.txtbox1 "!contents? Entry$"
              if Entry$ <> OldEntry$ then
              #A.txtbox1 word$(Entry$, 1)
              #A.txtbox2 word$(Entry$, 2)
              #A.txtbox3 word$(Entry$, 3)
              #A.txtbox4 word$(Entry$, 4)
              #A.txtbox5 word$(Entry$, 5)
              #A.txtbox1 "!contents? OldEntry$"
              end if
              wait
              #A.txtbox6 "!contents? OldEntryy$"
              #A.txtbox6 "!setfocus"
              timer 10, [dist]
              wait
              [dist]
              #A.txtbox6 "!contents? Entryy$"
              if Entryy$ <> OldEntryy$ then
              #A.txtbox6 word$(Entryy$, 6)
              #A.txtbox7 word$(Entryy$, 7)
              #A.txtbox8 word$(Entryy$, 8)
              #A.txtbox9 word$(Entryy$, 9)
              #A.txtbox10 word$(Entryy$, 10)
              #A.txtbox6 "!contents? OldEntryy$"
              end if
              wait
              [enter]
              PRINT #A.txtbox1, "!contents? a"
              PRINT #A.txtbox2, "!contents? b"
              PRINT #A.txtbox3, "!contents? c"
              PRINT #A.txtbox4, "!contents? d"
              PRINT #A.txtbox5, "!contents? e"
              PRINT #A.txtbox6, "!contents? f"
              PRINT #A.txtbox7, "!contents? g"
              PRINT #A.txtbox8, "!contents? h"
              PRINT #A.txtbox9, "!contents? i"
              PRINT #A.txtbox10, "!contents? j"
              #A.textresult "place 5 50"
              #A.textresult "\" ; a
              #A.textresult "place 5 70"
              #A.textresult "\" ; b
              #A.textresult "place 5 90"
              #A.textresult "\" ; c
              #A.textresult "place 5 110"
              #A.textresult "\" ; d
              #A.textresult "place 5 130"
              #A.textresult "\" ; e
              #A.textresult "place 100 50"
              #A.textresult "\" ; f
              #A.textresult "place 100 70"
              #A.textresult "\" ; g
              #A.textresult "place 100 90"
              #A.textresult "\" ; h
              #A.textresult "place 100 110"
              #A.textresult "\" ; i
              #A.textresult "place 100 130"
              #A.textresult "\" ; j
              #A.textresult "place 200 50"
              #A.textresult "\" ; a*f
              #A.textresult "place 200 70"
              #A.textresult "\" ; b*g
              #A.textresult "place 200 90"
              #A.textresult "\" ; c*h
              #A.textresult "place 200 110"
              #A.textresult "\" ; d*i
              #A.textresult "place 200 130"
              #A.textresult "\" ; e*j
              wait
              [quit]
              CLOSE #A
              END
               
               
              --- On Sat, 10/2/10, Stefan Pendl <pendl2megabit@...> wrote:


              From: Stefan Pendl <pendl2megabit@...>
              Subject: RE: [libertybasic] SIMPLE
              To: libertybasic@yahoogroups.com
              Date: Saturday, October 2, 2010, 7:25 AM


               



              >
              > Ok Stefan, if it is wrong from a GUI point of view, then can
              > we use copy and paste for the following values inside the two
              > txtboxs just by one step, i.e. to put the curser on the upper
              > txtbox and past two variables, the first one would be in the
              > upper txtbox and the second would be in the lower
              > txtbox."just by one step"
              > There are some serials of some software accept this way
              > although the boxes are arranged horizontally in this case.
              > Thank you
              >
              > The variables are:
              > 7
              > 11
              >

              Please test the following example:

              '---code start (watch for line wraps)
              nomainwin
              WindowWidth = 400
              WindowHeight = 300
              TEXTBOX #A.txtbox1, 100,140,60,25
              TEXTBOX #A.txtbox2, 100,170,60,25
              STATICTEXT #A "Input 1=", 30, 140, 60, 25
              STATICTEXT #A "Input 2=", 30, 165, 60, 25
              GRAPHICBOX #A.textresult, 100, 40, 160, 80
              BUTTON #A.Default, "Calculate",[enter],UL, 100, 230,70 , 25
              OPEN "TEXTBOX" FOR DIALOG AS #A
              #A "trapclose [quit]"
              #A "font Times_New_Roman 12"

              #A.txtbox1 "!contents? OldEntry$"
              #A.txtbox1 "!setfocus"

              timer 100, [IsChanged]
              wait

              [IsChanged]
              #A.txtbox1 "!contents? Entry$"

              if Entry$ <> OldEntry$ then
              #A.txtbox1 word$(Entry$, 1)
              #A.txtbox2 word$(Entry$, 2)
              #A.txtbox1 "!contents? OldEntry$"
              end if
              wait

              [enter]
              PRINT #A.txtbox1, "!contents? a"
              PRINT #A.txtbox2, "!contents? b"
              #A.textresult "place 5 25"
              #A.textresult "\Input 1= "; a;
              #A.textresult "\Input 2= "; b;
              #A.textresult "\Multiplication= ";a*b;
              wait

              [quit]
              CLOSE #A
              END
              '---code end

              ---
              Stefan Pendl
              http://stefanpendl.runbasichosting.com/

              Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
              Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

              Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

              Books at http://www.lulu.com/ and http://www.amazon.com/
              Alyce Watson ... APIs for Liberty BASIC
              Carl Gundel .... Beginning Programming with Liberty BASIC

              Windows 7 Home Premium 64-bit RTM
              AMD Turion X2 RM-70 2GHz, 4GB RAM











              [Non-text portions of this message have been removed]
            • Stefan Pendl
              ... I chose 100ms to allow the program to do other things too. The smallest resolution the timer can have is about 16ms, but then the program may only consist
              Message 6 of 17 , Oct 3, 2010
                >
                > Thank you Stefan, but may I ask you why the value of timer is 100?
                > I change it for trial to 1 and to1000 to see the effect, with
                > 1 the paste will be faster in compression with 1000. But the
                > results are correct by the two values.
                > Could we have your comment please.
                >  

                I chose 100ms to allow the program to do other things too.

                The smallest resolution the timer can have is about 16ms, but then the program may only consist of the timer.

                You have to select the timer interval wisely or you will end up crashing your program, because missed timer events build up on the
                stack.

                To monitor a GUI window for change events 100ms is small enough.

                ---
                Stefan Pendl
                http://stefanpendl.runbasichosting.com/

                Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
                Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

                Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

                Books at http://www.lulu.com/ and http://www.amazon.com/
                Alyce Watson ... APIs for Liberty BASIC
                Carl Gundel .... Beginning Programming with Liberty BASIC

                Windows 7 Home Premium 64-bit RTM
                AMD Turion X2 RM-70 2GHz, 4GB RAM
              • Stefan Pendl
                ... The part to initiate the second timer will never be executed and you can only have one timer for one program. You will have to read the help file topics
                Message 7 of 17 , Oct 3, 2010
                  >
                  > Hello Stefan
                  > Following to my previous message, I tried to have the
                  > following code working ok but it does not, the first column
                  > of txtboxes “time” is working ok but the second column of
                  > “distance” doesn’t. I tried to modify your code in a right way.
                  > Could you please help by copying the following variables,
                  > each group to its txtboxes, so that the code will work ok.  Thank you.

                  The part to initiate the second timer will never be executed and you can only have one timer for one program.
                  You will have to read the help file topics about the commands you use very carefully.

                  You need to manage all in one timer event handler, which is easy.
                  You do not have ten values for the distance, so you need to start with the first word in the distance string too, not with the
                  sixth.

                  As always, not only check the code, but more important check the commands used.

                  '---code start (watch for line wraps)
                  nomainwin
                  WindowWidth = 600
                  WindowHeight = 400
                  BUTTON #A.1 "Quit", [quit],UL, 500, 300, 70, 25
                  BUTTON #A.Default, " Calculate ",[enter],UL, 400,300 , 70, 25
                  TEXTBOX #A.txtbox1, 10,60,50,25
                  TEXTBOX #A.txtbox2, 10,100,50,25
                  TEXTBOX #A.txtbox3, 10,140,50,25
                  TEXTBOX #A.txtbox4, 10,180,50,25
                  TEXTBOX #A.txtbox5, 10,220, 50, 25
                  TEXTBOX #A.txtbox6, 70,60,50,25
                  TEXTBOX #A.txtbox7, 70,100,50,25
                  TEXTBOX #A.txtbox8, 70,140,50,25
                  TEXTBOX #A.txtbox9, 70,180,50,25
                  TEXTBOX #A.txtbox10, 70,220, 50, 25
                  STATICTEXT #A "time", 20,25, 250, 25
                  STATICTEXT #A "distance", 70,25, 250, 25
                  GRAPHICBOX #A.textresult, 180, 60, 300, 180
                  OPEN "Velocity" FOR DIALOG AS #A
                  #A "trapclose [quit]"
                  #A "font Times_New_Roman 12"
                  #A.textresult "place 5 15 "
                  #A.textresult "\";"time"
                  #A.textresult "\";"-----------------------------------------------------"
                  #A.textresult "place 90 15 "
                  #A.textresult "\";"distance "
                  #A.textresult "place 180 15 "
                  #A.textresult "\";"velocity"
                  #A.txtbox1 "!contents? OldTimes$"
                  #A.txtbox6 "!contents? OldDistance$"
                  #A.txtbox1 "!setfocus"
                  timer 100, [CheckInput]
                  wait
                  [CheckInput]
                  #A.txtbox1 "!contents? Times$"
                  if Times$ <> OldTimes$ then
                  #A.txtbox1 word$(Times$, 1)
                  #A.txtbox2 word$(Times$, 2)
                  #A.txtbox3 word$(Times$, 3)
                  #A.txtbox4 word$(Times$, 4)
                  #A.txtbox5 word$(Times$, 5)
                  #A.txtbox1 "!contents? OldTimes$"
                  end if
                  #A.txtbox6 "!contents? Distance$"
                  if Distance$ <> OldDistance$ then
                  #A.txtbox6 word$(Distance$, 1)
                  #A.txtbox7 word$(Distance$, 2)
                  #A.txtbox8 word$(Distance$, 3)
                  #A.txtbox9 word$(Distance$, 4)
                  #A.txtbox10 word$(Distance$, 5)
                  #A.txtbox6 "!contents? OldDistance$"
                  end if
                  wait
                  [enter]
                  PRINT #A.txtbox1, "!contents? a"
                  PRINT #A.txtbox2, "!contents? b"
                  PRINT #A.txtbox3, "!contents? c"
                  PRINT #A.txtbox4, "!contents? d"
                  PRINT #A.txtbox5, "!contents? e"
                  PRINT #A.txtbox6, "!contents? f"
                  PRINT #A.txtbox7, "!contents? g"
                  PRINT #A.txtbox8, "!contents? h"
                  PRINT #A.txtbox9, "!contents? i"
                  PRINT #A.txtbox10, "!contents? j"
                  #A.textresult "place 5 50"
                  #A.textresult "\" ; a
                  #A.textresult "place 5 70"
                  #A.textresult "\" ; b
                  #A.textresult "place 5 90"
                  #A.textresult "\" ; c
                  #A.textresult "place 5 110"
                  #A.textresult "\" ; d
                  #A.textresult "place 5 130"
                  #A.textresult "\" ; e
                  #A.textresult "place 100 50"
                  #A.textresult "\" ; f
                  #A.textresult "place 100 70"
                  #A.textresult "\" ; g
                  #A.textresult "place 100 90"
                  #A.textresult "\" ; h
                  #A.textresult "place 100 110"
                  #A.textresult "\" ; i
                  #A.textresult "place 100 130"
                  #A.textresult "\" ; j
                  #A.textresult "place 200 50"
                  #A.textresult "\" ; a*f
                  #A.textresult "place 200 70"
                  #A.textresult "\" ; b*g
                  #A.textresult "place 200 90"
                  #A.textresult "\" ; c*h
                  #A.textresult "place 200 110"
                  #A.textresult "\" ; d*i
                  #A.textresult "place 200 130"
                  #A.textresult "\" ; e*j
                  wait
                  [quit]
                  CLOSE #A
                  END
                  '---code end

                  ---
                  Stefan Pendl
                  http://stefanpendl.runbasichosting.com/

                  Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
                  Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

                  Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

                  Books at http://www.lulu.com/ and http://www.amazon.com/
                  Alyce Watson ... APIs for Liberty BASIC
                  Carl Gundel .... Beginning Programming with Liberty BASIC

                  Windows 7 Home Premium 64-bit RTM
                  AMD Turion X2 RM-70 2GHz, 4GB RAM
                • Stefan Pendl
                  ... I forgot to mention, that it is recommended to turn the timer off, if it is no longer needed, so you do not get unexpected results due to code being
                  Message 8 of 17 , Oct 3, 2010
                    >
                    > >
                    > > Hello Stefan
                    > > Following to my previous message, I tried to have the
                    > > following code working ok but it does not, the first column
                    > > of txtboxes “time” is working ok but the second column of
                    > > “distance” doesn’t. I tried to modify your code in a right way.
                    > > Could you please help by copying the following variables,
                    > > each group to its txtboxes, so that the code will work ok.  
                    > Thank you.
                    >
                    > The part to initiate the second timer will never be executed
                    > and you can only have one timer for one program.
                    > You will have to read the help file topics about the commands
                    > you use very carefully.
                    >

                    ---snip

                    > [quit]
                    > CLOSE #A
                    > END
                    > '---code end
                    >

                    I forgot to mention, that it is recommended to turn the timer off, if it is no longer needed, so you do not get unexpected results
                    due to code being executed, which is no longer relevant.

                    In your case the timer must only be stopped in the quit event handler.

                    '---code start (watch for line wraps)
                    [quit]
                    TIMER 0 '<<--- Turn timer off
                    CLOSE #A
                    END
                    '---code end

                    ---
                    Stefan Pendl
                    http://stefanpendl.runbasichosting.com/

                    Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
                    Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

                    Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

                    Books at http://www.lulu.com/ and http://www.amazon.com/
                    Alyce Watson ... APIs for Liberty BASIC
                    Carl Gundel .... Beginning Programming with Liberty BASIC

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