// PARAM -cd -ns
load "pipe"

// example for with pipe
string persist=" -persist";
persist="";
string sgnuplot ="gnuplot"+persist;
string sls ="ls -l";
if (onWIN32)
{ // windows command ...
	sls="dir";
	sgnuplot= "\"C:\\Program Files (x86)\\gnuplot\\bin\\pgnuplot.exe\""+persist;
}

if(1) {// input case ..
	pstream  ls(sls,"r");

	while (!ls.eof)
	{
		string file;
		getline(ls,file);
		cout <<  file << endl;
	}
}
cout << "pipe on " << sgnuplot << endl;
pstream  f(sgnuplot,"w");
try {
	f << "set terminal png" << endl;
	f << "set output \"pipe.png\"" << endl;
	for(int i=0;i<100; i++)
	{
		cout << "plot sin(x+" + (i*.01) + ") w l;" << endl;
		f  << "plot sin(x+" + (i*.01) + ") w l;" << endl;
	}
	f << "pause 2"<<endl;
}
catch (...)
	{cout << " catch  error ??? "<< endl;}
