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

Re: spreadheet lookalike

Expand Messages
  • JanetTerra
    ... best is NOT ... files (or ... suggested. ... I took the question to mean that he wanted to use the LB4.01 printing capabilities to print the spreadsheet,
    Message 1 of 14 , Oct 12, 2004
      --- In libertybasic@yahoogroups.com, Chergarj@c... wrote:
      > If the information functionality is what is most important, then
      best is NOT
      > to use graphics, but to use comboboxes, textboxes, and sequential
      files (or
      > random access files if you have the skill for them) as I just
      suggested.
      >
      > G C

      I took the question to mean that he wanted to use the LB4.01 printing
      capabilities to print the spreadsheet, yet was 'losing' graphics. If
      mouse clicking is desired, then a graphic box can be used. Heck,
      there are a hundred different ways of designing this.

      I do agree, though, Gordon, a graphic box is certainly not the most
      efficient. I would capture the information as you suggested, then,
      when all editing is done, print the information nicely formatted to a
      graphicbox and then print out that graphicbox for a nice display.

      For what it's worth, here is a demo showing how to mouseclick and
      edit. It is very simple, sequential code. It can be greatly
      polished by creating some functions and subs for duplicated code.

      'Demo
      nStudents = 5
      nTests = 4
      Dim testScores(nStudents, nTests)
      For student = 1 to nStudents
      For score = 1 to nTests
      testScore(student, score) = Int(Rnd(1)*40)+60
      Next score
      Next student

      Dim studentName$(nStudents,2)
      For student = 1 to nStudents
      Read lName$
      studentName$(student,1) = lName$
      Read fName$
      studentName$(student,2) = fName$
      Next student
      Data "Adams", "Curt", "Brady", "Pedro", "Collins", "Bronson"
      Data "Dawson", "Tim", "Erikson", "Derek"

      WindowWidth = 600
      WindowHeight = 200
      ' Nomainwin

      Graphicbox #w.g, 0, 0, WindowWidth, WindowHeight
      Open "Gradebook Demo" For Graphics as #w
      #w.g, "Trapclose [quit]"
      #w.g, "When leftButtonDouble [editScore]"

      #w.g, "Down"
      #w.g, "Color Lightgray"
      y = 55
      For xBar = 1 to 6
      #w.g, "Line 0 ";y;" ";WindowWidth;" ";y
      y = y + 20
      Next xBar

      x = 200
      For yBar = 1 to 6
      #w.g, "Line ";x;" ";0;" ";x;" ";WindowHeight
      x = x + 75
      Next yBar

      #w.g, "Font Courier_New 10 Bold"
      #w.g, "Color Black"
      x = 215
      For test = 1 to nTests
      #w.g, "Place ";x;" 50"
      #w.g, "\Test ";test
      x = x + 75
      Next test
      #w.g, "Place ";x-10;" 50"
      #w.g, "\Test Avg"

      #w.g, "Font Courier_New 12 Bold"
      #w.g, "Color Darkblue"
      For student = 1 to 5
      #w.g, "Place 10, ";50 + student*20
      #w.g, "\";studentName$(student,1);", ";studentName$(student,2)
      Next student

      x = 200
      y = 70

      For student = 1 to nStudents
      testTotal = 0
      For test = 1 to nTests
      score = testScore(student, test)
      If score < 70 Then
      #w.g, "Color Red"
      Else
      #w.g, "Color Black"
      End If
      testTotal = testTotal + score
      score$ = Using("###.#",Str$(score))
      #w.g, "Stringwidth? score$ width"
      x = 185 + 75*test - width
      #w.g, "Place ";x;" ";y
      #w.g, "\";score$
      Next test
      testAvg = Int((testTotal/nTests)*10 + 0.5)/10
      If testAvg < 70 Then
      #w.g, "Color Red"
      Else
      #w.g, "Color Black"
      End If
      testAvg$ = Using("###.#", Str$(testAvg))
      #w.g, "Stringwidth? testAvg$ width"
      x = 185 + 75*test - width
      #w.g, "Place ";x;" ";y
      #w.g, "\";testAvg$
      x = 200
      y = y + 20
      Next student
      #w.g, "Getbmp grades 0 0 ";WindowWidth;" ";WindowHeight
      #w.g, "Drawbmp grades 0 0"
      #w.g, "Flush"
      Wait

      [editScore]
      x = MouseX
      y = MouseY
      test = Int((x - 125)/75)
      If test > nTests Then
      test = 0
      End If
      student = Int((y - 35)/20)
      If student > nStudents Then
      student = 0
      End If
      If test = 0 or student = 0 Then
      Playwave "Beep"
      Else
      #w.g, "Redraw gradeID"
      editScore$ = Using("###.#",Str$(testScore(student, test)))
      msg$ = studentName$(student,1);", ";studentName$(student,2)
      msg$ = msg$;Chr$(13);"Test #";test
      Prompt msg$;editScore$
      editScore = Val(editScore$)
      testScore(student, test) = editScore
      If editScore < 70 Then
      #w.g, "Color Red"
      Else
      #w.g, "Color Black"
      End If
      editScore$ = Using("###.#", editScore)
      #w.g, "Stringwidth? editScore$ width"
      x = 185 + 75 * test - width
      y = 50 + student * 20
      #w.g, "Place ";x;" ";y
      #w.g, "\";editScore$
      testTotal = 0
      For n = 1 to nTests
      testTotal = testTotal + testScore(student, n)
      Next n
      testAvg = Int((testTotal/nTests)*10 + 0.5)/10
      If testAvg < 70 Then
      #w.g, "Color Red"
      Else
      #w.g, "Color Black"
      End If
      testAvg$ = Using("###.#", Str$(testAvg))
      #w.g, "Stringwidth? testAvg$ width"
      x = 185 + 75 * (nTests+1) - width
      #w.g, "Place ";x;" ";y
      #w.g, "\";testAvg$
      #w.g, "Getbmp grade 0 0 ";WindowWidth;" ";WindowHeight
      #w.g, "Drawbmp grade 0 0"
      #w.g, "Flush"
      #w.g, "Discard"
      End If
      Wait

      [quit]
      Close #w
      End
    • pendl2megabit
      Janet, very polished demo ;-) To make TRAPCLOSE work, you should asign it to the window not the graphicsbox ;-) #w, Trapclose [quit] instead of #w.g,
      Message 2 of 14 , Oct 12, 2004
        Janet,
        very polished demo ;-)
        To make TRAPCLOSE work, you should asign it to the window not the graphicsbox
        ;-)

        #w, "Trapclose [quit]"
        instead of
        #w.g, "Trapclose [quit]"

        ---
        Stefan Pendl


        > -----Urspr√ľngliche Nachricht-----
        > Von: JanetTerra
        >
        > For what it's worth, here is a demo showing how to mouseclick and
        > edit. It is very simple, sequential code. It can be greatly
        > polished by creating some functions and subs for duplicated code.
      • Chergarj@cs.com
        The main concern was the presence or absence of the comma in the trapclose line. The line needs the comma between the handlename and the first quotation mark.
        Message 3 of 14 , Oct 13, 2004
          The main concern was the presence or absence of the comma in the trapclose
          line. The line needs the comma between the handlename and the first quotation
          mark.

          G C

          In a message dated 10/13/2004 2:07:07 AM Pacific Daylight Time,
          pendl2megabit@... writes:
          > GC,
          > since LB3 the PRINT command is optional when you are printing to a
          > HANDLE.
          > This means that:
          > print #handle, "xy"
          > is equal to
          > #handle "xy"
          >
          > You can find this information in the helpfile under "Graphical User
          > Interface".
          > Find it under "LB 3 Help" -> "Introducing Liberty BASIC 3".
          >
          > ---
          > Stefan Pendl
          >
          >
          > >-----Ursprungliche Nachricht-----
          > >Von: Chergarj@...
          > >
          > >Very strange comment. We may forget the exact form and structure in the
          > >'trapclose' line when we use FreeForm.
          > >
          > >Mine must be like this:
          > >
          > >print #main, "trapclose [quit]"
          > >
          > >The exact handle name can vary. The exact label for quitting can
          > >vary. The
          > >form is required like this in LB 3.03 (but maybe #main, "trapclose
          > >[quit]"
          > >works too; I can't remember, and FreeForm puts in the "print" part
          > >automatically).
          > >
          > >G C
          >
          >


          [Non-text portions of this message have been removed]
        • bbjen@hotPOP.com
          ... Cool demo, Janet! I like the colors and I m partial to graphicbox displays myself. I think you might need a SCAN loop to make this work: #w.g, When
          Message 4 of 14 , Oct 13, 2004
            At 12:38 AM 10/13/04 -0000, you wrote:

            > . . . I do agree, though, Gordon, a graphic box is certainly not the most
            >efficient. I would capture the information as you suggested, then,
            >when all editing is done, print the information nicely formatted to a
            >graphicbox and then print out that graphicbox for a nice display.
            >
            >For what it's worth, here is a demo showing how to mouseclick and
            >edit. It is very simple, sequential code.
            >--------------------------------------

            Cool demo, Janet! I like the colors and I'm partial to graphicbox displays
            myself.

            I think you might need a SCAN loop to make this work:
            #w.g, "When leftButtonDouble [editScore]"
            When I run the pgm, it zips right to the cool scores display.

            Stefan -- Here's something odd (I'm running win98SE)
            In LB3, Janet's trapclose works with either #w.g, or #w,
            In LB4, it works with #w.g, but shows an error for both #w and #w,

            Bill J.
          • Mike
            ... like ... (300 ... it. ... The next newsletter may contain something I wrote which could fit the bill, using graphics boxes split into sections by drawn
            Message 5 of 14 , Oct 13, 2004
              --- In libertybasic@yahoogroups.com, "Anthony J. Arnold"
              <arnold@g...> wrote:
              > Help!
              >
              > I just bought LB and am a teacher trying to write a spreadsheet-
              like
              > "gradebook" utility that will let me update a 2-dimensional array
              (300
              > students by 40 grades) by clicking on a grade in a box and editing
              it.
              >

              The next newsletter 'may' contain something I wrote which could fit
              the bill, using graphics boxes split into sections by drawn lines.
              The mouse coords determine the section selected when a mouse button
              is clicked.

              Mike.
            • pendl2megabit
              GC, the comma is only needed if you use the PRINT command, without it, it is optional. Carl seems to have enhanced the error checking, because the combination
              Message 6 of 14 , Oct 13, 2004
                GC,
                the comma is only needed if you use the PRINT command, without it, it is
                optional.
                Carl seems to have enhanced the error checking, because the combination comma
                without print won't work in LB4.01 for me ???

                ---
                Stefan Pendl


                > -----Ursprungliche Nachricht-----
                > Von: Chergarj
                >
                > The main concern was the presence or absence of the comma in the trapclose
                > line. The line needs the comma between the handlename and the
                > first quotation
                > mark.
                >
                > G C
              • fearworks
                I just made the Nomainwin line operative instead of a remark, and it worked like a dream... Keith. ... graphicsbox
                Message 7 of 14 , Oct 13, 2004
                  I just made the "Nomainwin" line operative instead of a remark, and
                  it worked like a dream...

                  Keith.

                  --- In libertybasic@yahoogroups.com, "pendl2megabit"
                  <pendl2megabit@y...> wrote:
                  > Janet,
                  > very polished demo ;-)
                  > To make TRAPCLOSE work, you should asign it to the window not the
                  graphicsbox
                  > ;-)
                  >
                  > #w, "Trapclose [quit]"
                  > instead of
                  > #w.g, "Trapclose [quit]"
                  >
                  > ---
                  > Stefan Pendl
                  >
                  >
                  > > -----Urspr√ľngliche Nachricht-----
                  > > Von: JanetTerra
                  > >
                  > > For what it's worth, here is a demo showing how to mouseclick and
                  > > edit. It is very simple, sequential code. It can be greatly
                  > > polished by creating some functions and subs for duplicated code.
                • pendl2megabit
                  Bill, in LB4.00 you need a SCAN-LOOP in certain cases when you use KEY- or MOUSE-EVENT checking. This is corrected in LB4.01 ;-D I use LB4.01 on Win2k SP4 ;-)
                  Message 8 of 14 , Oct 13, 2004
                    Bill,
                    in LB4.00 you need a SCAN-LOOP in certain cases when you use KEY- or
                    MOUSE-EVENT checking.
                    This is corrected in LB4.01 ;-D

                    I use LB4.01 on Win2k SP4 ;-)

                    When I ran the demo as is, the NOMAINWIN was remarked and after closing the
                    console window, the error for closing #w occured. So I checked the code for
                    the TRAPCLOSE command.
                    I first changed it to use #w with comma and got a compile error, but I think
                    this was due to Windows >:-(
                    Then after removing the comma all was fine :-)

                    If you check the program flow, you will see that this is by design.
                    The double click is only used for editing the displayed data ;-)

                    ---
                    Stefan Pendl


                    > -----Ursprungliche Nachricht-----
                    > Von: bbjen
                    >
                    > Cool demo, Janet! I like the colors and I'm partial to graphicbox displays
                    > myself.
                    >
                    > I think you might need a SCAN loop to make this work:
                    > #w.g, "When leftButtonDouble [editScore]"
                    > When I run the pgm, it zips right to the cool scores display.
                    >
                    > Stefan -- Here's something odd (I'm running win98SE)
                    > In LB3, Janet's trapclose works with either #w.g, or #w,
                    > In LB4, it works with #w.g, but shows an error for both #w and #w,
                    >
                    > Bill J.
                  Your message has been successfully submitted and would be delivered to recipients shortly.