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

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

Expand Messages
  • 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 1 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 2 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.