Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting lang problem

Status
Not open for further replies.

deranged

Programmer
Nov 25, 2003
4
US
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;
}
}
}

}
}
 
use the debugger

Ion Filipski
1c.bmp
 
You're setting yourself up for a lot of work if you regard [tt]Print("[/tt] and [tt]Print ("[/tt] as slightly different but ultimately doing the same thing.

What happens if you type [tt]Print ("[/tt]

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top