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

Re: [libertybasic] Re:

Expand Messages
  • Stefan Pendl
    ... To get the last 60 lines, you need to first count all lines in the file and then do a second run, where you skip the first lines until you encounter the
    Message 1 of 16 , Jun 14, 2013
    • 0 Attachment
      Am 14.06.2013 15:47, schrieb paradisejb:
      >>
      >> It didn't remove the last number
      >> I want the last 60 tickets,not the first 60
      >>

      To get the last 60 lines, you need to first count all lines in the file
      and then do a second run, where you skip the first lines until you
      encounter the 60th line from the back.

      It is not easy to read a file from the back to front.


      --
      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
    • Lorne Russell
      here s another way to get last 60 lines in file dim lastlines$(60) numlines=0 open file.txt for input as #infile [read] if eof(#infile)
      Message 2 of 16 , Jun 14, 2013
      • 0 Attachment
        'here's another way to get last 60 lines in file

        dim lastlines$(60)
        numlines=0
        open "file.txt" for input as #infile

        [read]
        if eof(#infile)<0 then [alldone]
        line input #infile, g$
        numlines=numlines+1
        if numlines<60 then lastlines$(numlines)=g$ : goto [read]

        for x=2 to 60
        lastlines$(x-1)=lastlines$(x)
        next x
        lastlines$(60)=g$ : goto [read]

        [alldone]
        close #infile
        'do whatever you want now

        Lorne Russell


        From: Stefan Pendl
        Sent: Friday, June 14, 2013 11:05 AM
        To: libertybasic@yahoogroups.com
        Subject: Re: [libertybasic] Re:


        Am 14.06.2013 15:47, schrieb paradisejb:
        >>
        >> It didn't remove the last number
        >> I want the last 60 tickets,not the first 60
        >>

        To get the last 60 lines, you need to first count all lines in the file
        and then do a second run, where you skip the first lines until you
        encounter the 60th line from the back.

        It is not easy to read a file from the back to front.

        --
        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




        [Non-text portions of this message have been removed]
      • paradisejb
        ... This seems to extract the lines beginning at line 60 rather than the last 60 lines in the file.
        Message 3 of 16 , Jun 14, 2013
        • 0 Attachment
          --- In libertybasic@yahoogroups.com, "Lorne Russell" <lorneokb@...> wrote:
          >
          > 'here's another way to get last 60 lines in file
          >
          > dim lastlines$(60)
          > numlines=0
          > open "file.txt" for input as #infile
          >
          > [read]
          > if eof(#infile)<0 then [alldone]
          > line input #infile, g$
          > numlines=numlines+1
          > if numlines<60 then lastlines$(numlines)=g$ : goto [read]
          >
          > for x=2 to 60
          > lastlines$(x-1)=lastlines$(x)
          > next x
          > lastlines$(60)=g$ : goto [read]
          >
          > [alldone]
          > close #infile
          > 'do whatever you want now
          >
          > Lorne Russell
          >
          This seems to extract the lines beginning at line 60 rather than the last 60 lines in the file.
        • Lorne Russell
          Well there was one line wrong Should read if numlines
          Message 4 of 16 , Jun 14, 2013
          • 0 Attachment
            Well there was one line wrong Should read

            if numlines<61 then .......

            Try this – grabs last 60 numbers
            --------------------------

            open "file.txt" for output as #outfile
            for x=1 to 100
            g$=str$(x)
            print #outfile, g$
            next x
            close #outfile

            dim lastlines$(60)
            numlines=0
            open "file.txt" for input as #infile

            [read]
            if eof(#infile)<0 then [alldone]
            line input #infile, g$
            numlines=numlines+1
            if numlines<61 then lastlines$(numlines)=g$ : goto [read]

            for x=2 to 60
            lastlines$(x-1)=lastlines$(x)
            next x
            lastlines$(60)=g$ : goto [read]

            [alldone]
            close #infile
            'do whatever you want now

            for x=1 to 60
            print lastlines$(x)
            next x

            end
            --------------

            Lorne Russell


            From: paradisejb
            Sent: Friday, June 14, 2013 3:01 PM
            To: libertybasic@yahoogroups.com
            Subject: [libertybasic] Re:




            --- In mailto:libertybasic%40yahoogroups.com, "Lorne Russell" <lorneokb@...> wrote:
            >
            > 'here's another way to get last 60 lines in file
            >
            > dim lastlines$(60)
            > numlines=0
            > open "file.txt" for input as #infile
            >
            > [read]
            > if eof(#infile)<0 then [alldone]
            > line input #infile, g$
            > numlines=numlines+1
            > if numlines<60 then lastlines$(numlines)=g$ : goto [read]
            >
            > for x=2 to 60
            > lastlines$(x-1)=lastlines$(x)
            > next x
            > lastlines$(60)=g$ : goto [read]
            >
            > [alldone]
            > close #infile
            > 'do whatever you want now
            >
            > Lorne Russell
            >
            This seems to extract the lines beginning at line 60 rather than the last 60 lines in the file.





            [Non-text portions of this message have been removed]
          • jurgen
            Still not working to take the last 60 tickets en remove the bonus number but thanks everyone.
            Message 5 of 16 , Jun 26, 2013
            • 0 Attachment
              Still not working to take the last 60 tickets en remove the bonus number but thanks everyone.
            • jurgen
              I mean example 1 is taking the last 60 tickets but didn t remove the bonus number.
              Message 6 of 16 , Jun 26, 2013
              • 0 Attachment
                I mean example 1 is taking the last 60 tickets but didn't remove the bonus number.
              • green8819
                Hello all, If you don t mind, please continue the series with a new title called tickets . Thanks.
                Message 7 of 16 , Jun 26, 2013
                • 0 Attachment
                  Hello all,
                  If you don't mind, please continue the series with a new title called "tickets".
                  Thanks.


                  --- In libertybasic@yahoogroups.com, "jurgen" <dovejurgen@...> wrote:
                  >
                  > I mean example 1 is taking the last 60 tickets but didn't remove the bonus number.
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.