>I need my program to parse some fairly sizable text based files. The file >specification is quite loose, however, so I can't know exactly where each >element of the file will be. What I'm looking for is a fast way to locate, >for example, the first character in the handle that is NOT a white space >(CHR's 9 through 13) or the first character that IS the start of a >subsection: ({[< and such. I'm using some FN MUNGER code that was posted >here a while back for most of my parsing, but I haven't found a way to do >this with that yet. Here's the basic idea of MUNGER: 'h&=your text handle search$="(" searchChar&=@search$+1 ' allow for length byte startOffset&=0 openBracket&=FN MUNGER(h&,startOffset&,searchChar&,LEN(search$),0,0) This returns the offset of the character in your text file, if found, otherwise returns a negative number. I'm not sure what the last two 0's are for--something to do with replacing text, I think. The limitation of MUNGER seems to be that you can only look for one search string at a time. So Tedd's solution might be quicker anyways, if you look for more than one character at a time: LOCAL FN readByte 'read 1 byte DIM a, 2 a$ a = PEEK ( [gTextH&] + gOffSet&) a$=chr$(a) select a$ case "(", etc end select INC (gOffSet&) END FN = a > >While I'm at it, if anyone knows a way to search for a string that is not >within a subsection (a pair of the above characters: {}, (), etc.) I'd >appreciate hearing that, as well. My current solution is to search for the >string, and then search for the start and end of the subsections leading up >to the string and making sure that the last subsection ends before the >string begins. It works, but it seems to me like there should be a faster >method. I assume you're looking for mathematical formulas. Perhaps you could try searching for the brackets first, and take action based on whether a bracket has been opened yet. In the SELECT part of the above code, you could set flags like this: select a$ case "{" openLarge=_true case "[" openBracket=_true case "(" openParenthesis=_true case "}" open large=_false etc. case else ...take action based on what is true at this point... Hope this helps. >Thanks in advance. > >-- Brian Victor > > >-- >To unsubscribe, send ANY message to <futurebasic-unsubscribe@...> ____________________ Use e-mail with integrity. M Goodes (wave@...)