1

I am using the function here The Function Here

I do this, StartProcess('b4a_c2dm.bat','send ' + Trim(edit1.Text)+' ' + Trim(edit2.Text ),False,False);

This works great for the edit1.text (This is the name to send message to)

There will be a memo1 with multiple lines of names to send to. I need a way to call the StartProcess using the memo1 list of names instead of the edit1 single name.

The goal is to have it use the StartProcess over and over using the list of names in the memo1.

Thanks for your help.

Community
  • 1
  • 1
grant1842
  • 357
  • 1
  • 7
  • 23
  • Why don't you loop over the lines of the memo? – Sertac Akyuz May 05 '12 at 18:56
  • I am not sure how to do that with the start process . – grant1842 May 05 '12 at 19:09
  • Could you post an example that might work ? – grant1842 May 05 '12 at 19:10
  • I was referring to `for i := 0 to Memo1.Lines.Count - 1 do whatever(Memo1.Lines[i]);`. But apparently I haven't understood the question at all. – Sertac Akyuz May 05 '12 at 19:12
  • Seriously dude, if you have never seen a `for` loop yet it's a bit early to be hopping on StackOverflow. Stick with the tutorials and learn a LITTLE bit of programming before you ask questions like this. I mean. Yes, I wanna be friendly, and all. But a million questions about how to do something like LOOPING X TIMES is getting rediculous. Hello. Welcome to stackoverflow. PLEASE LEARN A BIT OF DELPHI. – Warren P May 05 '12 at 21:30
  • Thanks for your welcome. yes I have seeen a for loop . Its been a little while for me. This may not be the right place where one can ask questions about something simple. – grant1842 May 05 '12 at 22:38

1 Answers1

4

Run a simple for loop over the lines of the memo like this:

for i := 0 to Memo1.Lines.Count-1 do
  StartProcess(..., Memo1.Lines[i], ...);
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Ok here is what i got. var args : String; i: Integer; begin args := ''; for i := 0 to Memo1.Lines.Count do args := args + '"' + Memo1.Lines[i] + '" '; StartProcess('b4a_c2dm.bat','send ' + Trim(args)+' ' + Trim(edit2.Text ),false,true); end; it only sends to the firs name it the memo and i notice the message it sends is the second name in the memo. there can be no spaces in the memo . – grant1842 May 05 '12 at 20:14
  • There was a silly mistake in my answer. Loop is from 0 to Count-1. But I cannot understand your comment. My answer is quite clear. It simply concatenates the lines of the memo into a single space separated string. If that's not what you need then please tell us what you do need. Be precise. If it helps provide sample input and desired output. – David Heffernan May 05 '12 at 20:30
  • the bat file b4a_c2dm.bat expects a line like this b4a_c2dm.bat send username message – grant1842 May 05 '12 at 20:51
  • THe start process method will only send to 1 name(edit1.text) and only 1 message at a time. I need to send messages to all the names in a memo1 – grant1842 May 05 '12 at 20:52
  • I need a way to call this start process for each name in a memo1. And thanks for your time and help this seems like a GREAT site. – grant1842 May 05 '12 at 20:53
  • My code does what you need. You can use the debugger to inspect exactly what you are passing to your `StartProcess` function. – David Heffernan May 05 '12 at 20:55
  • Thanks David. I did a show message. The provlem is it is passing every name in the memo. I need to call the start process with each name separate . I do not want to code 8 start process for eight names . Is there a way I can cal a start process use the firs name in memo then call the next start process with the second name in the memo , and so on. The memo gets new updated names from a mysql data base that is why i need a dynamic solution. – grant1842 May 05 '12 at 21:00
  • 3
    OK then you need to call StartProcess each time round the loop, as per my update. As a piece of general advice, spending time making your question clearer would make it easier to answer, both for us and, more importantly, for you. – David Heffernan May 05 '12 at 21:04