1
votes

My program is a Windows Form Application in C#.

I have an interpreter/compiler IDE w/c basically runs a custom Language through a customized console window.

When interpreting input lines like "scanf", how do pause the interpreting while the user doesn't press enter?

Sample custom code to parse:

1     VAR x AS INT
2     START
3        INPUT: x
4        OUTPUT: x
5     STOP

For example, in those lines, when my program processes line 3, it doesn't process the other lines until the user inputs something and presses enter.

Pseudo-Snippet for line by line parsing:

foreach (string line in inputCode)
{
   LineType lineType = line.getType();

   if(lineType.InputStatement)
   {
   //wait for input here
   }
   else if(lineType.OutputStatement)
   {
   //analyze output code here
   }
   else if(lineType.AssignmentStatement)
   {
   //do Evaluation here
   }
}
2

2 Answers

1
votes

Console.Readline or Console.ReadKey will allow you to read input from the console simillar to scanf.

1
votes

You should make each method raise an event to fire the next line.
The INPUT method should fire that event after the user presses enter.