<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>parseUALR</title></head> <body><h1>parseUALR</h1>A simple parser to create a formated console output for fldigi's <EXEC> macro:<br><br>snip------------------------------------------<br>#include <ctime><br>#include <cstdio><br>#include <cstdlib><br>#include <unistd.h><br>#include <string><br>#include <iostream><br>#include <fstream><br><br>using namespace std;<br>using std::cout;<br>using std::cin;<br><br>int main(int argc, char *argv[])<br>{<br> size_t pos = 0, pos2 = 0, pos3 = 0, pos4 = 0, pos5 = 0;<br> <br> string commandline = "";<br> string name = "";<br> string qth = "";<br> string answer = "";<br> <br> char c = cin.get();<br> while (!cin.eof()) { <br> commandline += c;<br> c = cin.get();<br> }<br><br> if (commandline.find("No match found") != string::npos)<br> goto noresponse;<br> <br> pos = commandline.find(", ");<br> if (pos == string::npos)<br> goto noresponse;<br><br> pos += 2;<br><br> pos2 = commandline.find("\n", pos);<br> if (pos2 == string::npos)<br> goto noresponse;<br> <br> name = commandline.substr(pos, pos2 - pos);<br> <br> pos3 = name.find(32);<br> if (pos3 != string::npos)<br> name = name.substr(0, pos3);<br><br> for (size_t i = 1; i < name.length(); i++) name[i] = tolower(name[i]);<br><br> answer = "$NAME";<br> answer.append(name);<br> <br> pos4 = commandline.find(", ", pos2);<br><br> pos4 = commandline.rfind( "\n", pos4);<br> pos4 += 1;<br> pos5 = commandline.find("\n", pos4);<br><br> qth = commandline.substr(pos4, pos5 - pos4);<br> <br> answer.append("$QTH");<br> answer.append(qth);<br> cout << answer.c_str();<br> <br> return 0;<br><br>noresponse:<br> cout << "$NAME?$QTH?";<br> return 0;<br>}<br><br>snip-----------------------------------------------<br><br>save the above as "parseUALR.cxx" and then compile and link as follows:<br><br>g++ parseUALR.cxx -o parseUALR<br><br>copy the "parseUALR" executable to a directory on your shell exec PATH.<br></body></html>