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

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

Expand Messages
  • 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 1 of 13 , Mar 26 12:24 PM
    • 0 Attachment
      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.