Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I'm currently working on a C# program and am trying to parse some parts of a text file and generate a dynamic dialogue based on the character it comes in contact with.

The type of dialogue to be displayed is denoted by @ or ! symbols, and the dialogue text is denoted by a ~ symbol, below is some sample text from one of the files.

#200<br />
@001 Enter the name of the INSURANCE COMPANY:<br />
~Enter the name of the insurance company. Should match name on<br />
~policy/declarations.<br />
@002 Enter the title of the signatory for insurance company.<br />
~Enter the title of the person sending the notice. For example:<br />
~claims manager.<br />
@003 Enter the name of the INSURED:<br />
~Enter the name of the insured. Should match the name on policy<br />
~declarations.<br />
@004 Enter the street mailing address of the insured:<br />
~Enter the street mailing address for the insured.<br />
@005 Enter the city, state and zip code of the insured:<br />
~Enter the city, state and zip code of the mailing address of<br />
~the insured.<br />
@006 Enter the salutation for the letter:<br />
~Enter the salutation for use in the letter.  Include the greeting<br />
~as well as name of the recipient, for example: Dear <br />
~Mr. Policy_holder.<br />
@007 Enter the name of the claimant:<br />
~Enter the name of the claimant or claimants.<br />
!008 Enter the total available limits of coverage:<br />
~Enter in dollar format the available coverage provided for the<br />
~incident.<br />
#end control section<br />
#200



If anybody has any advice on how to accomplish this it will be greatly appreciated.
Posted

1 solution

You can read this as an array of lines with File.ReadAllLines. If the delimiter is always the first character, then you just have to read that first character, and split on it to work out what to do with it. Otherwise, you can search for it in each line, using string.Split perhaps ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900