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

AW: spreadheet lookalike

Expand Messages
  • pendl2megabit
    Hello Arnold, controls will not work correctly in a graphics window or box. here is a small example of how to make a fake spreadsheet using only graphics
    Message 1 of 14 , Oct 12, 2004
    • 0 Attachment
      Hello Arnold,
      controls will not work correctly in a graphics window or box.

      here is a small example of how to make a fake spreadsheet using only graphics
      commands ;-))

      '---code start
      ' spreadsheet demo
      ' free to use
      ' tested on Win2k SP4 and LB 4.01

      nomainwin

      ' setup data
      student$(1,1) = "miller a b d f c"
      student$(2,1) = "smith c d a f e"
      student$(3,1) = "parker c b a b a"

      maxStudents = 3
      maxColumns = 6

      lineWidth = 5
      nameWidth = 50 + lineWidth
      gradeWidth = 20 + lineWidth
      fieldHeight = 15 + lineWidth

      ' fill the array
      for row = 1 to maxStudents
      for column = maxColumns to 1 step -1
      student$(row,column) = word$(student$(row,1), column)
      next
      next

      ' create the spreadsheet
      open "Spreadsheet test" for graphics_nsb as #main
      #main "trapclose [quit]"
      #main "when leftButtonUp [checkPos]"

      ' use a monospaced font to get correct alignment
      #main "font courier_new 0 14"

      ' set the color defaults to simulate a spreadsheet
      #main "down ;fill black; color black; backcolor white"

      ' create the spreadsheet
      for row = 1 to maxStudents
      for column = 1 to maxColumns
      xOffset = lineWidth
      if column > 1 then xOffset = (column - 1) * gradeWidth + nameWidth

      yOffset = row * fieldHeight
      #main "place "; xOffset; " "; yOffset

      if column = 1 then
      #main "\"; left$(" " + student$(row,column) + space$(10), 10)
      else
      #main "\ "; student$(row,column); " "
      end if
      next
      next
      #main "flush sheet"
      wait

      [quit]
      close #main
      end

      [checkPos]
      xPos = MouseX
      yPos = MouseY

      for row = 1 to maxStudents
      if yPos < row * fieldHeight then exit for
      next

      for column = 1 to maxColumns
      if xPos < nameWidth then exit for
      if xPos < column * gradeWidth + nameWidth then exit for
      next

      if column = 1 then
      studentName$ = student$(row,column)

      prompt "plaese enter new name "; studentName$
      student$(row,column) = studentName$

      #main "place "; lineWidth; " "; row * fieldHeight
      #main "\"; left$(" " + student$(row,column) + space$(10), 10)
      else
      studentGrade$ = student$(row,column)

      prompt "plaese enter new grade "; studentGrade$
      student$(row,column) = studentGrade$

      #main "place "; (column - 1) * gradeWidth + nameWidth; " "; row *
      fieldHeight
      #main "\ "; student$(row,column); " "
      end if

      ' free memory and keep changes
      #main "delsegment sheet"
      #main "flush sheet"
      wait
      '--- code end

      ---
      Stefan Pendl


      > -----Ursprungliche Nachricht-----
      > Von: Anthony J. Arnold
      >
      >
      > Help!
      >
      > (1) write the whole array (from a nested for/next loop) as statictext to a
      > graphics box
      > (2) detect where the mouse is clicked in that box and (a) from the mouse
      > position figure out which array element had been clicked and (b) place an
      > editable textbox over that location to capture the edited information.
      > (3) rewrite the array with the updated info.
    • Chergarj@cs.com
      In a message dated 10/12/2004 1:33:46 PM Pacific Daylight Time, ... If the information functionality is what is most important, then best is NOT to use
      Message 2 of 14 , Oct 12, 2004
      • 0 Attachment
        In a message dated 10/12/2004 1:33:46 PM Pacific Daylight Time,
        janetterra@... writes:
        > Graphic refreshing can be a bit tricky. There are a couple of things
        > you can do. The first, and easiest, is to issue FLUSH, GETBMP,
        > DRAWBMP, FLUSH, DISCARD commands.

        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


        [Non-text portions of this message have been removed]
      • Alyce
        ... like ... (300 Have you looked at the terrific custom control by Dennis McKinney? http://www.syberden.net/ -Alyce
        Message 3 of 14 , Oct 12, 2004
        • 0 Attachment
          --- 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


          Have you looked at the terrific custom control by Dennis McKinney?

          http://www.syberden.net/

          -Alyce
        • 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 4 of 14 , Oct 12, 2004
          • 0 Attachment
            --- 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 5 of 14 , Oct 12, 2004
            • 0 Attachment
              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 6 of 14 , Oct 13, 2004
              • 0 Attachment
                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 7 of 14 , Oct 13, 2004
                • 0 Attachment
                  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 8 of 14 , Oct 13, 2004
                  • 0 Attachment
                    --- 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 9 of 14 , Oct 13, 2004
                    • 0 Attachment
                      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 10 of 14 , Oct 13, 2004
                      • 0 Attachment
                        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 11 of 14 , Oct 13, 2004
                        • 0 Attachment
                          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.