Hi Adak and Whiteflags! thanks for the advices. but, the problem is more complicated than you thought. okay, i'll share the real problem.
the M character and numbers next to it have meaning. It's the control for the numbers in output file
M 0.0 => 401
M 0.1 => 402
M 1.1 => 409
M 250.0 => 2401
M 700.0 => 6001 ...
M X.Y => 401 + 8*X + Y
to sum up, I list several lines that represent my problems
INPUT
Code:
"10-12B-CTRL ","M 0.0 ","BOOL "," "
"10-22B-CTRL ","M 0.1 ","BOOL "," "
"10-42B-CTRL ","M 0.2 ","BOOL "," "
"10-32B-CTRL ","M 0.3 ","BOOL "," "
"14-22A-CTRL ","M 0.7 ","BOOL "," "
"14-42A-CTRL ","M 1.0 ","BOOL "," "
"14-32A-CTRL ","M 1.1 ","BOOL "," "
"M10-EKR-DI ","M 700.0 ","BOOL "," "
"M11-EKR-DI ","M 700.1 ","BOOL "," "
"M12-EKR-DI ","M 700.2 ","BOOL "," "
DESIRED OUTPUT
Code:
401,10-12B-CTRL,,,,,,,,PLC-OUT,,#, //M 0.0 is 401
402,10-22B-CTRL,,,,,,,,PLC-OUT,,#,
403,10-42B-CTRL,,,,,,,,PLC-OUT,,#,
404,14-22A-CTRL,,,,,,,,PLC-OUT,,#,
405,,,,,,,,,PLC-OUT,,#, //because there is no M 0.4
406,,,,,,,,,PLC-OUT,,#, //because there is no M 0.5
407,,,,,,,,,PLC-OUT,,#, //because there is no M 0.6
408,14-42A-CTRL,,,,,,,,PLC-OUT,,#,
409,14-32A-CTRL,,,,,,,,PLC-OUT,,#,
410,,,,,,,,,PLC-OUT,,#, //because there is no M 1.2
411,,,,,,,,,PLC-OUT,,#, //because there is no M 1.3
... //the template is continued
6000,,,,,,,,,PLC-OUT,,#, //because there is no M 699.7
6001,M10-EKR-DI,M10-EKR-DI turned on,M10-EKR-DI turned off,,,,,,,,#, // M10-EKR-DI is used again in the next comma, PLC-OUT is no longer printed.
6002,M11-EKR-DI,M11-EKR-DI turned on,M11-EKR-DI turned off,,,,,,,,#,
6002,M12-EKR-DI,M11-EKR-DI turned on,M12-EKR-DI turned off,,,,,,,,#,
That's all folks!
I have to check the numbers next to M,
take the symbols in every input line,
concat it with turned on and off,
and put it in order one by one, separated with commas.
what confuse me is the missing sequence numbers. I don't know how to make the template is continued printed when the M numbers is missing. I'm thinking about making a temporary file that contents
Code:
401,10-12B-CTRL,,,,,,,,PLC-OUT,,#,
402,10-22B-CTRL,,,,,,,,PLC-OUT,,#,
403,10-42B-CTRL,,,,,,,,PLC-OUT,,#,
404,14-22A-CTRL,,,,,,,,PLC-OUT,,#,
408,14-42A-CTRL,,,,,,,,PLC-OUT,,#,
409,14-32A-CTRL,,,,,,,,PLC-OUT,,#,
6001,M10-EKR-DI,M10-EKR-DI turned on,M10-EKR-DI turned off,,,,,,,,#,
6002,M11-EKR-DI,M11-EKR-DI turned on,M11-EKR-DI turned off,,,,,,,,#,
6002,M12-EKR-DI,M11-EKR-DI turned on,M12-EKR-DI turned off,,,,,,,,#,
and then check every line once again and if the next sequence number is not prevnum+1, then print the template. how about it?