im trying to use a Print("") function with my own lang. it finds the Print("") but wont print whats between the "".
heres the code.
if(!strcmp(parsel.c_str(),"Print(\"") || !strcmp(parsel.c_str(),"Print (\""))
{
int at = parsel.find("Print(\"",0); //if the at is Print("
int at2; // used to see if at is Print ("
bool flag = 1; // used to see which print was called
if( at = string::npos)
{
flag = 0;
at2 = parsel.find("Print (\"",0);
at2 += 8;
}else
{at += 7;}
//test for Print("
while( flag )
{
at++;
int pos;//used to keep the number of chars in between the "'s
bool run = 1; //used to keep the while going
while( run )
{
string test = parsel.substr(at, 1);
if(! strcmp(test.c_str(),"\""))
{
at++;
pos++;
}
else{
run = 0;
at = at - pos;
string tmp = parsel.substr(at, pos);
cout << tmp;
}
}
}
//test for Print ("
if(! flag)
{
at2++;
int pos;
bool run = 1;
while( run )
{
string test = parsel.substr(at2, 1);
if(! strcmp(test.c_str(),"\""))
{
at2++;
pos++;
}
else
{
run = 0;
at2 = at2 - pos;
string printer = parsel.substr(at2, pos);
cout << printer;
}
}
}
}
}
heres the code.
if(!strcmp(parsel.c_str(),"Print(\"") || !strcmp(parsel.c_str(),"Print (\""))
{
int at = parsel.find("Print(\"",0); //if the at is Print("
int at2; // used to see if at is Print ("
bool flag = 1; // used to see which print was called
if( at = string::npos)
{
flag = 0;
at2 = parsel.find("Print (\"",0);
at2 += 8;
}else
{at += 7;}
//test for Print("
while( flag )
{
at++;
int pos;//used to keep the number of chars in between the "'s
bool run = 1; //used to keep the while going
while( run )
{
string test = parsel.substr(at, 1);
if(! strcmp(test.c_str(),"\""))
{
at++;
pos++;
}
else{
run = 0;
at = at - pos;
string tmp = parsel.substr(at, pos);
cout << tmp;
}
}
}
//test for Print ("
if(! flag)
{
at2++;
int pos;
bool run = 1;
while( run )
{
string test = parsel.substr(at2, 1);
if(! strcmp(test.c_str(),"\""))
{
at2++;
pos++;
}
else
{
run = 0;
at2 = at2 - pos;
string printer = parsel.substr(at2, pos);
cout << printer;
}
}
}
}
}