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

Can't seem to get my Text box to retrive data

Expand Messages
  • Michael Pinger
    Started this program to moniter fire growth and fighter need to complete a job. Yet I can not seem to be able to retrive my data input to the Textbox with just
    Message 1 of 2 , Apr 29, 2008
    • 0 Attachment
      Started this program to moniter fire growth and fighter need to
      complete a job. Yet I can not seem to be able to retrive my data
      input to the Textbox with just one button or seperate. It all worked
      when I used Prompts....to green at programming to figure it out. Any
      suggestions.


      '-----Begin code for #main
      ' Parmiters for Pasadena Fire .002, .0015, .05, .0001


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

      '-----Begin GUI objects code

      TexteditorColor$ = "white"
      texteditor #main.textedit1, 5, 5, 250, 150
      textbox #main.tbx1, 405, 40, 100, 25
      textbox #main.tbx2, 405, 70, 100, 25
      textbox #main.tbx3, 405, 100, 100, 25
      textbox #main.tbx4, 405, 130, 100, 25
      textbox #main.tbx5, 405, 190, 100, 25
      button #main.tb5, "start",[start], UL, 350,190, 50, 25
      graphicbox #main.graphicbox1, 5, 222, 200, 100
      statictext #main.statictext1, "Fire no fighters % day", 265, 42,
      135, 20
      statictext #main.statictext2, "Fire end fighters % day", 265, 72,
      134, 20
      statictext #main.statictext3, "extra Fighter with fire %", 265,
      102, 134, 20
      statictext #main.statictext4, "Fighter less no fires % ", 265,
      132, 134, 20
      statictext #main.statictext4, "Number of days to test! ", 200,
      192, 150, 20
      '-----End GUI objects code

      '-----Begin menu code

      menu #main, "Edit" ' <-- Texteditor menu.

      '-----End menu code

      open "Firefighter" for window as #main

      print #main, "font ms_sans_serif 10"

      print #main.graphicbox1, "font ms_sans_serif 10"
      print #main.graphicbox1, "down; fill white; flush"
      print #main, "trapclose [quit.main]"

      ' graphics box work start

      #main.graphicbox1, "\"
      #main.graphicbox1, "\"
      #main.graphicbox1, "\ Fire Fighters Enter Paramiters"
      #main.graphicbox1, "\ then enter times to run"
      #main.graphicbox1, "\ Then hit Enter."
      wait
      'Graphics box end
      ' text box work start
      [start]
      print #main.tbx1, "!contents? M$";
      input #main.tb5, M$
      M = val(M$)

      print #main.tbx2, "!contents? K$";
      input #main.tb5, K$
      K = val(K$)

      print #main.tbx3, "!contents? G$";
      input #main.tb5, G$
      G = val(G$)

      print #main.tbx4, "!contents? D$";
      input #main.tb5, D$
      D =val(D$)

      print #main.tbx5, "!contents? C$";
      input #main.tb5, C$
      C = val(C$)

      ' Text box work end

      wait


      for x = 1 to C
      Restore[Fireacre]
      Read Var$

      Restore[Fighters]
      Read Vrr$

      [Fireacre]
      Data "RB*(1 + (M -(K*WX))) "

      [Fighters]
      Data "WB*((1 + (G*RX))-D) "

      If x = 1 then
      RB = 400 ' number fire acre spread start
      WB = 500 ' Number of fire fighters attacking the job
      else
      RB = eval(Var$)
      WB = eval(Vrr$)
      end if


      #main.textedit1 "The Number Acres burning = "; int(eval(Var$))
      #main.textedit1 "The Number of fighterss = "; int(eval(Vrr$))
      RX = eval(Var$)
      WX = eval(Vrr$)

      next x

      wait

      [quit.main] 'End the program
      close #main
      end
    • Stefan Pendl
      ... Below find a running version of your code. What I have changed: 1) I removed the lines with DATA and READ and placed the definition of the equitation s at
      Message 2 of 2 , Apr 29, 2008
      • 0 Attachment
        >
        > Started this program to moniter fire growth and fighter need to
        > complete a job. Yet I can not seem to be able to retrive my data
        > input to the Textbox with just one button or seperate. It all worked
        > when I used Prompts....to green at programming to figure it out. Any
        > suggestions.
        >

        Below find a running version of your code.

        What I have changed:
        1) I removed the lines with DATA and READ and placed the definition
        of the equitation's at the top of the code. They do not change, so
        no need to reread them for each run of the loop.
        2) I removed any additional GUI code, that was just adding to the
        complexity of the code, but not to the usefulness of it.
        3) You mixed two ways of receiving the values from a textbox
        The "old" way:
        #main.tbx1 "!contents?"
        input #main.tbx1, M
        The "new" way:
        #main.tbx1 "!contents? M"
        4) You can receive numerical values directly from textboxes, no need
        do complicate things.
        5) The main problem was an extra WAIT statement between receiving the
        textbox contents and the calculation loop, this was causing the
        program to never reach the output.

        You can see this, if you run your program through the debugger, the program will sit and wait just before the calculation loop.

        Best is to add one feature after the other, you can build your GUI in steps too, which will show you what you need and what you
        don't need.

        '---code start (watch for line wraps)
        '-----Begin code for #main
        ' Parameters for Pasadena Fire .002, .0015, .05, .0001

        'Fire acre
        Var$ = "RB*(1 + (M -(K*WX)))"

        'Fighters
        Vrr$ = "WB*((1 + (G*RX))-D)"

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

        '-----Begin GUI objects code
        texteditor #main.textedit1, 5, 5, 250, 150
        textbox #main.tbx1, 405, 40, 100, 25
        textbox #main.tbx2, 405, 70, 100, 25
        textbox #main.tbx3, 405, 100, 100, 25
        textbox #main.tbx4, 405, 130, 100, 25
        textbox #main.tbx5, 405, 190, 100, 25
        button #main.tb5, "start",[start], UL, 350,190, 50, 25
        graphicbox #main.graphicbox1, 5, 222, 200, 100
        statictext #main.statictext1, "Fire no fighters % day", 265, 42, 135, 20
        statictext #main.statictext2, "Fire end fighters % day", 265, 72, 134, 20
        statictext #main.statictext3, "extra Fighter with fire %", 265, 102, 134, 20
        statictext #main.statictext4, "Fighter less no fires % ", 265, 132, 134, 20
        statictext #main.statictext4, "Number of days to test! ", 200, 192, 150, 20
        '-----End GUI objects code

        open "Firefighter" for window as #main
        #main "trapclose [quit.main]"
        #main "font ms_sans_serif 10"

        #main.graphicbox1 "down"
        #main.graphicbox1 "\"
        #main.graphicbox1 "\"
        #main.graphicbox1 "\ Fire Fighters Enter Paramiters"
        #main.graphicbox1 "\ then enter times to run"
        #main.graphicbox1 "\ Then hit the Start button."
        wait

        [start]
        #main.tbx1 "!contents? M"
        #main.tbx2 "!contents? K"
        #main.tbx3 "!contents? G"
        #main.tbx4 "!contents? D"
        #main.tbx5 "!contents? C"

        for x = 1 to C
        If x = 1 then
        RB = 400 ' number fire acre spread start
        WB = 500 ' Number of fire fighters attacking the job
        else
        RB = eval(Var$)
        WB = eval(Vrr$)
        end if

        #main.textedit1 "The Number Acres burning = "; int(eval(Var$))
        #main.textedit1 "The Number of fighters = "; int(eval(Vrr$))
        RX = eval(Var$)
        WX = eval(Vrr$)
        next x
        wait

        [quit.main] 'End the program
        close #main
        end
        '---code end

        ---
        Stefan Pendl
      Your message has been successfully submitted and would be delivered to recipients shortly.