;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;+ ; This function reads the next line of a given file. Any text on a ; line following a semicolon is treated as a comment. A $ at the end ; of a line indicates continuation to the next line. ; ; @param unit {type=Int} {Required} ; An open file I/O unit for the desired file. ; @keyword upCase {type=Boolean} {Default=0} ; Make the entire line uppercase. ; @keyword comment {type=String} {Default=';'} ; The string that denotes a comment. ; @keyword continuation {type=String} {Default='$'} ; The string that denotes the line is continued ; on the next line. ; ; @returns The next complete non-comment line in the given file. This ; means concatinating any lines that end with the ; continuation string. ; ; @author Nathaniel Livesey August 18, 1999 ; @version $Revision: 1.4 $ $Date: 2003/11/14 20:09:05 $ ;- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function ReadNextNonCommentLine, unit, upCase=upCase, comment=comment, $ continuation=continuation upCase = Keyword_Set(upCase) IF N_Elements(comment) eq 0 then comment=';' IF N_Elements(continuation) eq 0 then continuation='$' result='' REPEAT BEGIN ; Loop for continuation lines REPEAT BEGIN ; Loop for comment lines line = '' Readf, unit, line commentPos = StRegEx(line, comment) ; Strip out comments IF commentPos NE -1 THEN line = StrMid(line, 0, commentPos) line = StrTrim(line, 2) ENDREP UNTIL EOF(unit) OR line NE '' IF upCase EQ 1 THEN line = StrUpCase(line) ;; Now see if last character is $, if so, concatenate to next line. len = StrLen(line) IF StrMid(line, len - 1, 1) EQ continuation THEN BEGIN result = result + StrMid(line, 0, len - 1) finished = 0 ENDIF ELSE BEGIN result = result + line finished = 1 ENDELSE ENDREP UNTIL finished EQ 1 OR EOF(unit) Return, result END ;; $Log: readnextnoncommentline.pro,v $ ;; Revision 1.4 2003/11/14 20:09:05 fullerr ;; Added documentation and did some reformatting ;;