Hi, all,
I am using CodeBlocks 12.11 with IDE on a Windows system and writing a console program.
I am progressing with various pieces of my project, which involves converting the contents of a text file from one standard format to another standard format. I can convert lines that don't vary in content, but I haven't been able to figure out how to convert lines that do vary in content. More specifically...
I need to read one line of code from a text file, which could be any of the following lines 1-8, convert the line to its equivalent (shown after the = sign) and send the equivalent to an output file. I know how to convert lines 1, 2, 5, 6, 7, and (I think) 8 using a nested if file, and I know how to write the equivalent to the output file, but I don't know how to convert the input for lines 3 and 4, because their content will vary. Note: x, y, and z values in the input file vary from 0 to ~300.
1. Black wins by resignation! = B+Resign
2. White wins by resignation! = W+Resign
3. Black wins by winxxx.5 points! >> White(yyy):Black(zzz) = B+xxx.5
4. White wins by winxxx.5 points! >> White(yyy):Black(zzz) = W+xxx.5
5. White loses on time = B+Time
6. Black loses on time = W+Time
7. Progressing! = Progressing
8. [Any other possibility] = Unknown
I haven't written the code for lines 3-8 yet, but here is what I have so far for lines 1 and 2. These lines compile and write to the output file as intended. I can continue this routine for lines 5, 6, and 7, but this won't work for lines 3 and 4. I think I can handle line 8 by the final else statement. If it isn't lines 1-7, then 8. To convert lines 3 and 4, I have tried parsing the strings if they start with "Black wins by win" or "White wins by win" and erasing the first three characters of winxxx.5. But I am kind of fumbling around and haven't been able to make this work.
I hope someone will give me some guidance.
Thanks,
Michael
1 2 3 4 5 6 7 8 9 10 11
|
outputfile << "RE[";
if (Result == "White wins by resign!")
outputfile << "W+Resign]";
else
if (Result == "Black wins by resign!")
outputfile << "B+Resign]";
else
outputfile << Result << "]";
|