Console App: pipe | to stdin of my app lazarus / 34-Windows ---------------------------------------------------------------------- Stefan · 2014-05-25 10:42 Hello community. I am Stefan, I am new to Pascal but have some knowledge with VBS, JS, PascalScript, Batch,... Now I wrote my first console application with fpc-2.6.4.i386-win32 on W7-32. Every thing works fine so far, but I can't find an answer about this question: How can I get input at stdin from piped output, of lets say 'DIR /B /S' ? Something : C:\Temp\>DIR /B | sed -e "///" Currently I utilize only ParamCount and ParamStr(). How can I get piped-in data on stdin? C:\Temp\>DIR /B | myapp.exe My current code (partially excerpt): Code: [Select]var begin     if(ParamCount > 1) Then     begin         sInputArg   := ParamStr(1);         sOutputStr := StringReplace( sInputArg ,  sBefore, sAfter, [rfReplaceAll]);     end;     WriteLn(sOutputStr); end. Usage: c:\FPC\2.6.4\demo\text>for /F "tokens=*" %a in ('dir /B') do @myapp.exe "%a" That works fine, but, Wanted usage: c:\FPC\2.6.4\demo\text>dir /B | myapp.exe Pascal code for this wanted usage: ??? need your help here please ! ---------------------------------------------------------------------- Leledumbo · 2014-05-25 11:20 Piped input is read from standard input, so use Read(Ln) for that. ---------------------------------------------------------------------- Stefan · 2014-05-25 11:50 Thank you very much. But I only get the first arg/filename piped. All the others are not printed. How can I manage to execute my app for each piped filename? So far I have: Code: [Select]program Hello; {$APPTYPE CONSOLE}   uses   SysUtils, StrUtils; var   sInputArg, sOutputStr, sBefore, sAfter : WideString; begin ReadLn(sInputArg);   if not (sInputArg = '') Then   //while not (sInputArg = '') do   begin     sBefore := 'A';     sAfter  := 'X';     sOutputStr := StringReplace(sInputArg,  sBefore, sAfter, [rfReplaceAll]);     WriteLn(sOutputStr);     sInputArg := '';   end; end. Thank you in advance. ---------------------------------------------------------------------- Stefan · 2014-05-25 11:57 I think I found it: Code: [Select]begin   Repeat       ReadLn(sInputArg);         sBefore := 'e';         sAfter  := 'X';         sOutputStr := StringReplace(sInputArg,  sBefore, sAfter, [rfReplaceAll]);         WriteLn(sOutputStr);   Until sInputArg = ''; end. . ---------------------------------------------------------------------- Leledumbo · 2014-05-25 12:00 better use: Code: [Select]while not EOF do begin   ReadLn(YourVar);   ... // process YourVar here end; ---------------------------------------------------------------------- Stefan · 2014-05-25 16:36 Thanks, solved.