%%%% ======================================================================== %%%% @MP-file{ %%%% author = "Ulrik Vieth", %%%% version = "1.04", %%%% date = "02 May 1995", %%%% time = "11:25:41 MET", %%%% filename = "gpdata.mp", %%%% checksum = "50346 62 305 2578", %%%% email = "vieth@thphy.uni-duesseldorf.de", %%%% codetable = "ISO/ASCII", %%%% keywords = "MetaPost, Gnuplot, graphs, data files", %%%% supported = "yes", %%%% abstract = "This file modifies the `Grdln_' routine %%%% of the MetaPost graph package, so that %%%% it can parse and ignore comment lines %%%% in data files starting with a `#' sign, %%%% similar to the conventions in Gnuplot. %%%% %%%% Users of this package should be careful %%%% about not leaving extra blank lines %%%% before and after such comment lines, %%%% as blank lines in data files will still %%%% be interpreted as the end of a data set, %%%% even if they occur before any data. %%%% ", %%%% docstring = "The checksum field above contains a CRC-16 %%%% checksum as the first value, followed by %%%% the equivalent of the standard UNIX wc %%%% (word count) utility output of lines, %%%% words, and characters. This is produced %%%% by Robert Solovay's checksum utility.", %%%% } %%%% ======================================================================== % Load the graph package if it hasn't been loaded already. if unknown Gpaths: input graph fi % Read a line from file f, extract whitespace-separated tokens ignoring any % initial "%", and return true if at least one token is found. The tokens % are stored in @#1, @#2, .. with "" in the last @#[] entry. vardef Grdln_@#(expr f) = save n_, s_; forever: string s_; s_ = readfrom f; exitif s_=EOF; string @#[]; @#1 := loptok s_; exitif @#1<>"#"; endfor if s_<>EOF: n_ = if @#1="%": 0 else: 1 fi; forever: @#[incr n_] := loptok s_; exitif @#[n_]=""; endfor @#1<>"" else: false fi enddef;