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

Re: [libertybasic] loop untill 3 numbers are the same

Expand Messages
  • Glen McInnis
    Ok, I quit - forget my suggestions. other s earlier submittals work. On Sun, Mar 24, 2013 at 10:31 PM, Glen McInnis ... [Non-text portions of this message have
    Message 1 of 13 , Mar 24, 2013
      Ok, I quit - forget my suggestions. other's earlier submittals work.

      On Sun, Mar 24, 2013 at 10:31 PM, Glen McInnis
      <jesusforgavemebro@...>wrote:

      > Oh yea you could
      >
      > do until (nr1 - nr2 + nr3 = nr2)
      >
      >
      > On Sun, Mar 24, 2013 at 10:28 PM, Glen McInnis <
      > jesusforgavemebro@...> wrote:
      >
      >> Nah! Sorry that don't work.
      >>
      >>
      >> On Sun, Mar 24, 2013 at 10:25 PM, Glen McInnis <
      >> jesusforgavemebro@...> wrote:
      >>
      >>> You may also
      >>>
      >>> do until (nr1 - nr2 + nr3 = nr1)
      >>>
      >>>
      >>> On Fri, Mar 22, 2013 at 5:26 PM, Fred Jensen <k6dgw@...> wrote:
      >>>
      >>>> **
      >>>>
      >>>>
      >>>> On 3/22/2013 10:50 AM, edcxport wrote:
      >>>>
      >>>> >
      >>>> > Do Until CSng(CurTemp) = CSng(Temp1MinOld) And CSng(Temp2MinOld)
      >>>>
      >>>> I think you want:
      >>>>
      >>>> do until (nr1=nr2 and nr1=nr3 and nr2=nr3)
      >>>>
      >>>> I believe LB [and other basic's] evaluate each of the conditionals to
      >>>> true or false. The boolean AND then combines all three of those to
      >>>> evaluate to true only if all 3 are true. Or something like that ..:-)
      >>>>
      >>>> Regards,
      >>>>
      >>>> Fred
      >>>>
      >>>>
      >>>>
      >>>
      >>>
      >>
      >


      [Non-text portions of this message have been removed]
    • Fred Jensen
      ... There are a multitude of cute coding tricks that will work in this and other isolated situations ... unfortunately that isn t one of them for his
      Message 2 of 13 , Mar 24, 2013
        On 3/24/2013 7:31 PM, Glen McInnis wrote:
        > Oh yea you could
        >
        > do until (nr1 - nr2 + nr3 = nr2)
        >

        There are a multitude of cute coding tricks that will work in this and
        other isolated situations ... unfortunately that isn't one of them for
        his situation. When programming was an art, you did what you could
        figure out would work. Then it became *Software Engineering*, and a Team
        Sport, and cute didn't work anymore. I once wrote a COBOL [OK, now you
        know how old I am] program that had about 6 lines in the main program.
        All the rest was in the REPORT section. Unfortunately, none of my
        colleagues knew much about the COBOL Report Writer. I once wrote a
        compiler for the DIBOL language for a DG Nova. I did it in FORTRAN. I
        REALLY do not recommend doing that.

        I read his original question to be, "How do I make a test on multiple
        conditionals?" The biggest help I get from groups like this is when
        someone actually explains the syntax or operations that will work ... in
        *all* cases.

        Fred
      • KELLER RICHARD
        So whats wrong with COBOL, how about Assembler, if you want to date yourself. COBOL, PL1, Assembler, Fortran, DOS, NOMAD, FOCUS; still, with all that, I m
        Message 3 of 13 , Mar 25, 2013
          So whats wrong with COBOL, how about Assembler, if you want to date yourself. COBOL, PL1, Assembler, Fortran, DOS, NOMAD, FOCUS; still, with all that, I'm frustrated that I can't code with something as simple as basic, well at least not as good as I would like. 

          --- On Sun, 3/24/13, Fred Jensen <k6dgw@...> wrote:

          From: Fred Jensen <k6dgw@...>
          Subject: Re: [libertybasic] loop untill 3 numbers are the same
          To: libertybasic@yahoogroups.com
          Date: Sunday, March 24, 2013, 10:59 PM
















           









          On 3/24/2013 7:31 PM, Glen McInnis wrote:

          > Oh yea you could

          >

          > do until (nr1 - nr2 + nr3 = nr2)

          >



          There are a multitude of cute coding tricks that will work in this and

          other isolated situations ... unfortunately that isn't one of them for

          his situation. When programming was an art, you did what you could

          figure out would work. Then it became *Software Engineering*, and a Team

          Sport, and cute didn't work anymore. I once wrote a COBOL [OK, now you

          know how old I am] program that had about 6 lines in the main program.

          All the rest was in the REPORT section. Unfortunately, none of my

          colleagues knew much about the COBOL Report Writer. I once wrote a

          compiler for the DIBOL language for a DG Nova. I did it in FORTRAN. I

          REALLY do not recommend doing that.



          I read his original question to be, "How do I make a test on multiple

          conditionals?" The biggest help I get from groups like this is when

          someone actually explains the syntax or operations that will work ... in

          *all* cases.



          Fred



























          [Non-text portions of this message have been removed]
        • edcxport
          Thanks Fred Your code works. I needed to loop (to get a new number) until the all numbers are the same. Paul
          Message 4 of 13 , Mar 25, 2013
            Thanks Fred
            Your code works.
            I needed to loop (to get a new number) until the all numbers are the same.


            Paul

            --- In libertybasic@yahoogroups.com, Fred Jensen <k6dgw@...> wrote:
            >
            > On 3/24/2013 7:31 PM, Glen McInnis wrote:
            > > Oh yea you could
            > >
            > > do until (nr1 - nr2 + nr3 = nr2)
            > >
            >
            > There are a multitude of cute coding tricks that will work in this and
            > other isolated situations ... unfortunately that isn't one of them for
            > his situation. When programming was an art, you did what you could
            > figure out would work. Then it became *Software Engineering*, and a Team
            > Sport, and cute didn't work anymore. I once wrote a COBOL [OK, now you
            > know how old I am] program that had about 6 lines in the main program.
            > All the rest was in the REPORT section. Unfortunately, none of my
            > colleagues knew much about the COBOL Report Writer. I once wrote a
            > compiler for the DIBOL language for a DG Nova. I did it in FORTRAN. I
            > REALLY do not recommend doing that.
            >
            > I read his original question to be, "How do I make a test on multiple
            > conditionals?" The biggest help I get from groups like this is when
            > someone actually explains the syntax or operations that will work ... in
            > *all* cases.
            >
            > Fred
            >
          • Fred Jensen
            ... Nothing whatsoever ... well, a bit verbose, but, like FORTRAN, really really durable and generally could be compiled by any system [unless you made
            Message 5 of 13 , Mar 25, 2013
              On 3/25/2013 6:32 AM, KELLER RICHARD wrote:
              > So whats wrong with COBOL,

              Nothing whatsoever ... well, a bit verbose, but, like FORTRAN, really
              really durable and generally could be compiled by any system [unless you
              made significant use of Report Writer. :-) That did differ some between
              systems].

              > how about Assembler, if you want to date yourself.

              First programs for me were in hex on a Bendix G-15D at Cal Poly Univ in
              1961. For my thesis, I wrote a symbolic assembler. It worked, however
              with only 2,100 "words" of recirculating memory, its coefficient of
              usefulness was, to be generous, low.

              > COBOL, PL1, Assembler, Fortran, DOS, NOMAD, FOCUS; still, with
              > all that, I'm frustrated that I can't code with something as simple as
              > basic, well at least not as good as I would like.

              LB worked OK for me. Many of the GUI things are somewhat contrived, but
              I found that keeping the help file up in Firefox pretty much solved all
              my problems.

              Single biggest missing piece in LB for me was lack of an event generated
              by a TEXTBOX when the focus left the control. My usage has a lot of
              textboxes. This led to a sync subroutine, called whenever an action
              like SAVE, SAVEAS, LOAD CONTROLLER, etc was called that read all of them
              and saved the contents in the program data structures since the program
              had no other way of knowing if the contents had changed. It works OK,
              but there are left many times when what's on the screen does not match
              what's in the primary data structures ... generally not the best situation.

              When I undertook this irrigation controller project, there were several
              pieces ... the controller and the relay stack were PIC-based in C and
              that went quite smoothly. My biggest uncertainty was the PC-based
              interface in Windows. I have no intrinsic Windows programming
              experience and even less desire to learn it. Liberty Basic seems to
              have solved that problem for me.

              Fred
              Auburn CA
            • Stefan Pendl
              ... You could incorporate a check event using a timer as done in http://groups.yahoo.com/group/libertybasic/message/39099 Sure it is not as elegant as
              Message 6 of 13 , Mar 25, 2013
                Am 25.03.2013 20:54, schrieb Fred Jensen:
                >
                > Single biggest missing piece in LB for me was lack of an event generated
                > by a TEXTBOX when the focus left the control. My usage has a lot of
                > textboxes. This led to a sync subroutine, called whenever an action
                > like SAVE, SAVEAS, LOAD CONTROLLER, etc was called that read all of them
                > and saved the contents in the program data structures since the program
                > had no other way of knowing if the contents had changed. It works OK,
                > but there are left many times when what's on the screen does not match
                > what's in the primary data structures ... generally not the best situation.
                >

                You could incorporate a check event using a timer as done in
                http://groups.yahoo.com/group/libertybasic/message/39099

                Sure it is not as elegant as specifying an event handler, but the
                GetFocus API function can be used to compare the last with the current
                control handle.

                You might even "misuse" the default button to do some checking, when you
                move from one text box to the other using the ENTER key.

                The GetAsyncKeyState API function could be used to trap the Tab key for
                instance.

                You see there are many options, even if the specific event handler is
                missing.


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

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

                LB Community Wiki .............. http://basic.wikispaces.com/
                LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
                LB 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 SP1
                AMD Turion X2 RM-70 2GHz, 4GB RAM
              • Rod
                Excellent example from Stefan. I suppose free text is the most complex way to take input. The down side of the timed update is that you are going to get half
                Message 7 of 13 , Mar 26, 2013
                  Excellent example from Stefan. I suppose free text is the most complex way to
                  take input. The down side of the timed update is that you are going to get half
                  entered numbers at some point. It only matters if you are error checking range
                  or values.

                  You may still need the user to tell you they are done or that they have
                  committed the changes to file, which is an event.

                  I respond just to remind readers that there are other ways to take input.


                  nomainwin
                  WindowWidth = 550
                  WindowHeight = 410
                  UpperLeftX=int((DisplayWidth-WindowWidth)/2)
                  UpperLeftY=int((DisplayHeight-WindowHeight)/2)

                  dim num$(100)
                  for n= 1 to 100
                  num$(n)=str$(n)
                  next

                  dim col$(16)
                  col$(1)="yellow"
                  col$(2)="brown"
                  col$(3)="red"
                  col$(4)="darkred"
                  col$(5)="pink"
                  col$(6)="darkpink"
                  col$(7)="blue"
                  col$(8)="darkblue"
                  col$(9)="green"
                  col$(10)="darkgreen"
                  col$(11)="cyan"
                  col$(12)="darkcyan"
                  col$(13)="white"
                  col$(14)="black"
                  col$(15)="lightgray"
                  col$(16)="darkgray"

                  ' set up the controls that will be displayed in the window
                  statictext #main.num, "Enter 1 - 100", 80, 80, 100, 20
                  textbox #main.tbnum, 80, 100, 100, 25
                  listbox #main.lbnum, num$(), [check], 200, 100, 100 ,45
                  combobox #main.cbnum, num$(), [check], 320, 100, 100, 25


                  statictext #main.col, "Enter color", 80, 130, 100, 20
                  textbox #main.tbcol, 80, 150, 100, 25
                  listbox #main.lbcol, col$(), [check], 200, 150, 100, 45
                  combobox #main.cbcol, col$(), [check], 320, 150, 100, 25

                  ' put a button on the screen to action the input
                  button #main.getinput,"Enter",[check], UL, 80, 200, 100, 25

                  textbox #main.tbans, 80, 250, 100, 25
                  textbox #main.lbans, 200, 250, 100, 25
                  textbox #main.cbans, 320, 250, 100, 25

                  ' open the window and set where it goes if the user closes it
                  open "User Input" for window as #main
                  #main "trapclose [quit]"
                  #main.lbnum "singleclickselect"
                  #main.lbcol "singleclickselect"
                  #main.tbnum "1"
                  #main.lbnum "selectindex 1"
                  #main.cbnum "selectindex 1"
                  #main.tbcol "yellow"
                  #main.lbcol "selectindex 1"
                  #main.cbcol "selectindex 1"
                  wait


                  [check]
                  #main.tbnum "!contents? tbnum$"
                  #main.lbnum "selection? lbnum$"
                  #main.cbnum "selection? cbnum$"
                  #main.tbcol "!contents? tbcol$"
                  #main.lbcol "selection? lbcol$"
                  #main.cbcol "selection? cbcol$"
                  c$="yellow brown red darkred pink darkpink blue darkblue green "
                  c$=c$+"darkgreen cyan darkcyan white black lightgray darkgray "
                  if val(tbnum$)<=0 or val(tbnum$)>100 then notice "Textbox error ";tbnum$
                  if val(lbnum$)<=0 or val(lbnum$)>100 then notice "Listbox error ";lbnum$
                  if val(cbnum$)<=0 or val(cbnum$)>100 then notice "Combobox error ";cbnum$
                  if instr(c$,tbcol$+" ",1)=0 then notice "Textbox error ";tbcol$
                  if instr(c$,lbcol$+" ",1)=0 then notice "Listbox error ";lbcol$
                  if instr(c$,cbcol$+" ",1)=0 then notice "Combobox error ";cbcol$
                  #main.tbans tbnum$;" ";tbcol$
                  #main.lbans lbnum$;" ";lbcol$
                  #main.cbans cbnum$;" ";cbcol$

                  wait

                  [quit]
                  close #main
                  end
                Your message has been successfully submitted and would be delivered to recipients shortly.