Re: lineoffset - In Reverse
Thanks Mark. I extrapolated it from something Jerry Daniels said at one of the Rev conferences in Monterey. Phil Mark Wieder wrote: Phil- Tuesday, November 17, 2009, 10:30:32 AM, you wrote: -- get the data chunk in question replace ... with tMarkerChar in vFile set the lineDelimiter to tMarkerChar put line -2 of vFile into tFoundSegment set the lineDelimiter to CR !! That's a brilliant use of lineDelimiter. I've been doing this the hard way (as in just yesterday). I think this will simplify my code quite a bit. -- Phil Davis PDS Labs Professional Software Development http://pdslabs.net ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
lineoffset - In Reverse
I'm trying to parse a file, who's format I have no control over. I have found the pattern that I need but in order to make it work (easily) I need the equivalent of lineoffset to work from the end mark (which I can reliably find) and the start of that section which is a variable number of lines above the end mark. The start of a section is a line by itself with ... but this same line is also used to mark off other sections that I don't need. So, what I need to do is: 1) find the line offset to the next end-of-section marker 2) find the line offset from #1 BACKWARDS to the first line that starts with ... Is there such a function? I can always roll my own and just read lines backwards from #1 above until I find the start mark but why reinvent the wheel if such a function is already in revTalk. len ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: lineoffset - In Reverse
Are there many cases of these sections within the file? I think you could work the lineOffset function with the lines to skip offering, and work a routine out of it. But here is a find function that lists all the lineNumbers of a searchstring. You can then process successive instances any way you need. You would call: get revFullFind(textToSearch,textToFind,lineNum,true) function revFullFind tText,tFind,form,exactly switch case exactly = true and form = lineNum repeat for each line tline in tText add 1 to counter if tFind = tline then put counter return after temp22 end if end repeat break case exactly = true and form = txt repeat for each line tline in tText add 1 to counter if tFind = tline then put theLine return after temp22 end if end repeat break case exactly = false and form = lineNum repeat for each line tline in tText add 1 to counter if tFind is in tline then put counter return after temp22 end if end repeat break case exactly = false and form = txt repeat for each line tline in tText add 1 to counter if tFind is in tline then put theLine return after temp22 end if end repeat break end switch return temp22 end revFullFind Hope this helps Craig Newman In a message dated 11/17/09 9:38:17 AM, len-mor...@crcom.net writes: 1) find the line offset to the next end-of-section marker 2) find the line offset from #1 BACKWARDS to the first line that starts with ... Is there such a function? I can always roll my own and just read lines backwards from #1 above until I find the start mark but why reinvent the wheel if such a function is already in revTalk. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: lineoffset - In Reverse
Hi Len, Here's an approach that might give you what you need. It assumes the file is already in a vFile variable, and that the contents of vFile won't be rewritten - in other words it's disposable: -- find an unused character to use as a line delimiter put empty into tMarkerChar repeat with x = 255 down to 1 -- I didn't include 0 - it might cause problems in this context if numToChar(x) is not in vFile then put numToChar(x) into tMarkerChar exit repeat end if end repeat -- exit if every ASCII char is used in the file if tMarkerChar = empty then answer Can't do it! exit to top end if -- get the data chunk in question replace ... with tMarkerChar in vFile set the lineDelimiter to tMarkerChar put line -2 of vFile into tFoundSegment set the lineDelimiter to CR So now you've isolated your data chunk. I may have missed something, but this approach is simple and should work. Hope this helps - Phil Davis Len Morgan wrote: I'm trying to parse a file, who's format I have no control over. I have found the pattern that I need but in order to make it work (easily) I need the equivalent of lineoffset to work from the end mark (which I can reliably find) and the start of that section which is a variable number of lines above the end mark. The start of a section is a line by itself with ... but this same line is also used to mark off other sections that I don't need. So, what I need to do is: 1) find the line offset to the next end-of-section marker 2) find the line offset from #1 BACKWARDS to the first line that starts with ... Is there such a function? I can always roll my own and just read lines backwards from #1 above until I find the start mark but why reinvent the wheel if such a function is already in revTalk. len -- Phil Davis PDS Labs Professional Software Development http://pdslabs.net ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: lineoffset - In Reverse
Phil- Tuesday, November 17, 2009, 10:30:32 AM, you wrote: -- get the data chunk in question replace ... with tMarkerChar in vFile set the lineDelimiter to tMarkerChar put line -2 of vFile into tFoundSegment set the lineDelimiter to CR !! That's a brilliant use of lineDelimiter. I've been doing this the hard way (as in just yesterday). I think this will simplify my code quite a bit. -- -Mark Wieder mwie...@ahsoftware.net ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution