Hi I am currently using Basic Sharp link: https://github.com/Timu5/BasicSharp
This is a basic language interpreter. We need to use merge fields in this code to replace mergefields with values.
For example:
IF {Clients.Name} = "Patrick" THEN
#Do something
ENDIF
the merge field needs to be setup as a token and then it's value parsed and replaced depending on its type.
so the above would be parsed and replaced like so:
IF "Patrick" = "Patrick" THEN
#Do Something
ENDIF
Any help would be much appreciated, I am available to go through this in more detail on a screenshare if this would help!
What I have tried:
I have tried the below code from the interpreter, as it parses line by line. This is one of the requirements. As this can be used in the DO While loop, where the database value can change:
void Line()
{
string lineText = GetLine();
string regularExpressionPattern = @"\[.*?\]";
string inputText = lineText;
int intVal = 0;
double Double123 = 0.00;
Regex re = new Regex(regularExpressionPattern);
string finalvalue = "";
Run_Code rc = new Run_Code();
rc.case_ref = case_ref;
rc.CaseTypeIndex = CaseTypeIndex;
foreach (Match m in re.Matches(inputText))
{
inputText = inputText.Replace(m.Value,'"' + rc.getDBValue(m.Value.Replace("[", "").Replace("]", "")) + '"');
}
while (lastToken == Token.NewLine) GetNextToken();
if (lastToken == Token.EOF)
{
exit = true;
return;
}
lineMarker = lex.TokenMarker;
Statment();
if (lastToken != Token.NewLine && lastToken != Token.EOF)
Error("Expect new line got " + TranslateToken(lastToken.ToString()));
}