Announcement

Collapse
No announcement yet.

Getting lines from a text file....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting lines from a text file....

    I am using a text file with AMS, and I am making an html file within AMS to print what is in that text file in a webobject(inside a tex area), so as to allow for a decorative border. I have a specific number of rows I can have in this text file, or it will not show them all, as I have removed the scrollbars so they will not be printed. Is there an easy way to have AMS get all of the lines from a certain point on in a text file, or from one specified line to another? It just seems that althought the average person using my program may not even use more than one page, someone may, and I do not know how long that file will be in the end, and how many individual html files I will have to make, so I am looking for an easy way to do this.
    Thanks,
    Rob

  • #2
    Re: Getting lines from a text file....

    TEXT FILE > GET LINE action allows you to get a specific line, sandwich it in a WHILE loop and you can grab chunks of lines, i.e. line 10 to line 20, etc.

    TEXT FILE > FIND LINE action allows you to find lines in your text file based upon search criteria.

    Both are easy to use and well documented in the help file...

    Corey Milner
    Creative Director, Indigo Rose Software

    Comment


    • #3
      Re: Getting lines from a text file....

      Yes, I have succesfully used a while loop with this action, the problem is that I don't have any clue how many times I would have to do this to write separate text files. Asume for a minute that the html file I am writing only has room for 30 lines of text. I am writing an html file that contains all this text, if the line count = < 20. However, if it is more than 30 lines, say 500 lines, I need to be able to write the rest of the lines, in 30 line chunks to different text files. I can then use these to write separate html files, which I can then print. I don't want to have to copy each line one at a time, and write them one at a time. It would be great if I could tell it to copy lines 30 - to whatever the line count is, as long as the line count is less than 59. If it is not, I could then copy lines 60- whatever the line count is, and so on. Basically the problem is this whole print thing. I could quite easily print a text file, but I wanted some decoration around it, to make it look nicer. To do this, I have to put it into an html file, which is where all the trouble begins. I'm starting to think that maybe it would be a **** of a lot easier to just have my program open the text file to be printed, and have them copy/paste it into the text area themselves, that way they could see for themselves whether or not they need to print more than one page. This whole using html to print seems really unnecessary, and makes things way to complicated.

      Comment


      • #4
        Re: Getting lines from a text file....


        However, if it is more than 30 lines, say 500 lines, I need to be able to write the rest of the lines, in 30 line chunks to different text files.
        If you can get it to work for 30 lines, then you can get it to work for 1000. One way would be to use nested loops (a loop inside a loop). One loop to handle writing up to 30 lines (i.e. starting from a given line number, incrementing it each time, looping 30 times). Put that loop inside another loop that keeps restarting the process (with another file as the target, or whatever it is you're doing) until all the lines have been done.

        In human terms, it would make sense to say "output 30 lines" all at once, but computers don't work that way. There's nothing wrong with doing it one line at a time. In fact, it's perfectly normal. Just be glad you have access to things like WHILE loops so you don't have to write 10000 instructions to do it. [img]/ubbthreads/images/icons/smile.gif[/img]

        Processing one line at a time isn't always the fastest or best way of working with text files, but often that's the only way to get the job done...it all depends on what's in the text files, and what you want to do with their contents.
        --[[ Indigo Rose Software Developer ]]

        Comment

        Working...
        X