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

[libertybasic] Button event

Expand Messages
  • Eirik Karlsen
    Hi, can someone look into this code...it is flawed in several places. What I want to do is to use the Next Frame button to step trough the for-next loop.
    Message 1 of 2 , Apr 3, 2004
    • 0 Attachment
      Hi,
      can someone look into this code...it is flawed in several places.

      What I want to do is to use the 'Next Frame' button to step trough the
      for-next loop.
      Have tried sub's but since variables are scoped locally this didn't work.

      The basic problem I guess is to read and respond to the button without exiting
      the for-next loop...so branching to the main program loop after the button
      is pushed is not really an option...must continue in the loop.

      Any ideas?

      '***********************************************************************************************************
      nomainwin
      WindowWidth = 200'800
      WindowHeight = 400'600
      UpperLeftX=int((DisplayWidth-WindowWidth)/2)-50
      UpperLeftY=int((DisplayHeight-WindowHeight)/2)
      BackgroundColor$ = "lightgray"

      dim frame$(2000)


      button #main.reset,"Send One byte",[sendClick], UL, 5, 006, 80, 24

      STATICTEXT #main.mon, "waiting for connection...", 5, 320, 150, 20


      GROUPBOX #main.boot, "From bootloader:", 0, 100, 90, 200
      button #main.reset,"Next frame",bootnextframeClick, UL, 5, 120, 80, 24




      open "Bootloader" for window as #main


      print #main, "trapclose [quit.main]"

      goto [main.inputloop]

      '------------------------------------------------------------
      [main.inputloop]
      'if lof(#comport) > 0 then gosub [receive]
      scan 'Check for input events


      'if rx$="N" then beep :rx$=""

      wait
      goto [main.inputloop]
      '------------------------------------------------------------



      [quit.main] 'End the program

      close #main

      close #txt2

      end



      '--------------------
      [sendClick]

      open "Out-table" for text as #txt2
      for linecnt=1 to 999

      FOR RR=0 TO 9599:NEXT RR 'delay

      '213 if n$="" then
      scan

      'goto 213
      'end if
      print #txt2,n$
      'n$=""
      next linecnt
      wait




      '--------------------
      sub bootnextframeClick handle$
      gosub 443
      'n$="gommmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm"':print #txt2,n$
      end sub

      443
      n$="gommmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm"
      return


      '**************************************************************************************************************

      --
      *******************************************
      VISIT MY HOME PAGE:
      <http://home.online.no/~eikarlse/index.htm>
      LAST UPDATED: 23/08/2003
      *******************************************
      Best Regards
      Eirik Karlsen
    • Eirik Karlsen
      Found out about it ( GLOBAL) ... ADVERTISEMENT [click here] ... -- ******************************************* VISIT MY HOME PAGE:
      Message 2 of 2 , Apr 3, 2004
      • 0 Attachment
        Found out about it ( GLOBAL)

        Eirik Karlsen wrote:

        > Hi,
        > can someone look into this code...it is flawed in several places.
        >
        > What I want to do is to use the 'Next Frame' button to step trough the
        > for-next loop.
        > Have tried sub's but since variables are scoped locally this didn't work.
        >
        > The basic problem I guess is to read and respond to the button without exiting
        > the for-next loop...so branching to the main program loop after the button
        > is pushed is not really an option...must continue in the loop.
        >
        > Any ideas?
        >
        > '***********************************************************************************************************
        > nomainwin
        > WindowWidth = 200'800
        > WindowHeight = 400'600
        > UpperLeftX=int((DisplayWidth-WindowWidth)/2)-50
        > UpperLeftY=int((DisplayHeight-WindowHeight)/2)
        > BackgroundColor$ = "lightgray"
        >
        > dim frame$(2000)
        >
        >
        > button #main.reset,"Send One byte",[sendClick], UL, 5, 006, 80, 24
        >
        > STATICTEXT #main.mon, "waiting for connection...", 5, 320, 150, 20
        >
        >
        > GROUPBOX #main.boot, "From bootloader:", 0, 100, 90, 200
        > button #main.reset,"Next frame",bootnextframeClick, UL, 5, 120, 80, 24
        >
        >
        >
        >
        > open "Bootloader" for window as #main
        >
        >
        > print #main, "trapclose [quit.main]"
        >
        > goto [main.inputloop]
        >
        > '------------------------------------------------------------
        > [main.inputloop]
        > 'if lof(#comport) > 0 then gosub [receive]
        > scan 'Check for input events
        >
        >
        > 'if rx$="N" then beep :rx$=""
        >
        > wait
        > goto [main.inputloop]
        > '------------------------------------------------------------
        >
        >
        >
        > [quit.main] 'End the program
        >
        > close #main
        >
        > close #txt2
        >
        > end
        >
        >
        >
        > '--------------------
        > [sendClick]
        >
        > open "Out-table" for text as #txt2
        > for linecnt=1 to 999
        >
        > FOR RR=0 TO 9599:NEXT RR 'delay
        >
        > '213 if n$="" then
        > scan
        >
        > 'goto 213
        > 'end if
        > print #txt2,n$
        > 'n$=""
        > next linecnt
        > wait
        >
        >
        >
        >
        > '--------------------
        > sub bootnextframeClick handle$
        > gosub 443
        > 'n$="gommmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm"':print #txt2,n$
        > end sub
        >
        > 443
        > n$="gommmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm"
        > return
        >
        >
        > '**************************************************************************************************************
        >
        > --
        > *******************************************
        > VISIT MY HOME PAGE:
        > <http://home.online.no/~eikarlse/index.htm>
        > LAST UPDATED: 23/08/2003
        > *******************************************
        > Best Regards
        > Eirik Karlsen
        >
        >
        >
        > Yahoo! Groups Sponsor
        ADVERTISEMENT
        [click here]

        >
        > ---------------------------------------------------------------
        > Yahoo! Groups Links
        >
        > * To visit your group on the web, go to:
        > http://groups.yahoo.com/group/libertybasic/
        >
        > * To unsubscribe from this group, send an email to:
        > libertybasic-unsubscribe@yahoogroups.com
        >
        > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
        >
        --
        *******************************************
        VISIT MY HOME PAGE:
        <http://home.online.no/~eikarlse/index.htm>
        LAST UPDATED: 23/08/2003
        *******************************************
        Best Regards
        Eirik Karlsen



        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.