Dear All,
My application runs with input from a text file. So it parse the text file, and then use the value inside to do several things.
But last time, a typo occured, and the application shows and error. Lucky I put exception to the application. I just wondering whether I can make another application with C# that will scan and detect syntax error inside the text file, so before uploading it, the error is detected.
Any idea how to do this? what came into my mind is I parse the text and then check for value error. But how if I put command also inside the text file? Like a simple loop.
Kindest Regards,
E

2 answers
well if this is available, its preferable to fix any syntax error before inserting it to the text file like when the user wants to save the data. now concerning the checker, its all dependent on the way of the text that is being parsed so if you want to keep the program safe and fast, make a checker that will check the file in a time interval. this checker should do the same parsing of the file when u need to retrieve a specific data from so you won't feel that anything is being done but it will be in the background.
To make a thread:
answered one year ago by:
1556
301
thanks for the input muster, anyway I was thinking of doing it sequencially, so it was like this: button -> opentxt -> parse -> and now, it is like button -> opentxt -> check -> if error dont parse, if not error, parse and use as input. So it is like a compiler in between them. What come into my mind is on how to 'compile' the text file and see whether there is any mistake like typo made by the user. Thanks :)
Here's a possible pattern for dealing with that situation, if I've understood it correctly:
I'd only run CheckFile on a separate thread if you're processing large files and want to keep the UI responsive in the meantime.
Incidentally, given that you're talking about 'syntax checking', does the text file contain source code in C# or some other programming language?
answered one year ago by:
17279