matlab textreads has a "commentstyle" option where all lines starting with a "#" or "%" or "//" are commented out when flag is set to "matlab" or "shell" or "c++" resp. this should be simple to implement. I gave a try (see patch below) but haven't succeed so far. textread.cc uses classes and I am not familiar with this type of programming. may I ask real C++ programmers in this forum to help me solving this problem?
with the patch below, the lines that start with # are ignored. the output structure has the right number of rows but they are all empty :-( eric PS: a test example textread("file.txt","%d %d %d") http://www.nabble.com/file/p25803121/file.txt file.txt diff -c old/textread.cc new/textread.cc *** old/textread.cc 2009-10-08 16:12:30.000000000 +0200 --- new/textread.cc 2009-10-08 16:12:59.000000000 +0200 *************** *** 94,99 **** --- 94,100 ---- while (!tmpdata.eof()) { tmpdata.getline(buf, BUFFER_SIZE); if (_lines < headerlines || std::string(buf).length() != 0) { + if (std::string(buf)[0] != '#') _lines++; } } *************** *** 130,140 **** void readline() { ! data.getline(buffer, BUFFER_SIZE,'#'); ! if (std::string(buffer).length() != 0) { line.str(buffer); line.clear(); ! } } bool --- 131,144 ---- void readline() { ! data.getline(buffer, BUFFER_SIZE); ! ! if (std::string(buffer).length() != 0) ! if (std::string(buffer)[0] != '#') { line.str(buffer); line.clear(); ! } ! } bool *************** *** 224,229 **** --- 228,234 ---- std::string filename = args(0).string_value(); std::string format = args(1).string_value(); + std::string commentstyle = ""; unsigned int headerlines = 0; int repeat = 0; *************** *** 241,246 **** --- 246,253 ---- if (prop == "headerlines") headerlines = args(i+1).int_value(); + else if (prop == "commentstyle") + commentstyle = args(i+1).int_value(); else error("Unknown property %s.",prop.c_str()); *************** -- View this message in context: http://www.nabble.com/textread%3A-comment-out-lines-starting-with---tp25803121p25803121.html Sent from the octave-dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Octave-dev mailing list Octave-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/octave-dev