www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why foreach do not print value during every single Insert request in

reply "Suliman" <evermind live.ru> writes:
		void IMGsInsert(string [] fullimgurl)
		{
			foreach (url; fullimgurl)
			{
				string sqlinsert = (sqlrequest)
				writeln(sqlinsert);
				write("|");
				auto rs = stmt.executeUpdate(sqlinsert);
			}

		}

I expect nice progress indicator "|" which move forward after 
every Insert request.
Like:
||||
and so on.

The problem that App wait some time and only in prints a heap of 
"|". Why?
Jan 15 2015
next sibling parent Rikki Cattermole <alphaglosined gmail.com> writes:
On 16/01/2015 1:05 a.m., Suliman wrote:
          void IMGsInsert(string [] fullimgurl)
          {
              foreach (url; fullimgurl)
              {
                  string sqlinsert = (sqlrequest)
                  writeln(sqlinsert);
                  write("|");
                  auto rs = stmt.executeUpdate(sqlinsert);
              }

          }

 I expect nice progress indicator "|" which move forward after every
 Insert request.
 Like:
 ||||
 and so on.

 The problem that App wait some time and only in prints a heap of "|". Why?
That writeln won't be helping anything. Other then that? No idea sorry.
Jan 15 2015
prev sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Thursday, 15 January 2015 at 12:05:24 UTC, Suliman wrote:
 		void IMGsInsert(string [] fullimgurl)
 		{
 			foreach (url; fullimgurl)
 			{
 				string sqlinsert = (sqlrequest)
 				writeln(sqlinsert);
 				write("|");
 				auto rs = stmt.executeUpdate(sqlinsert);
 			}

 		}

 I expect nice progress indicator "|" which move forward after 
 every Insert request.
 Like:
 ||||
 and so on.

 The problem that App wait some time and only in prints a heap 
 of "|". Why?
Terminal output is line-buffered by default. To display an incomplete line to the user, add "stdout.flush()" after your "write" call.
Jan 15 2015