Posts: 949
Threads: 153
Joined: Jan 2012
Reputation:
0
See the topic title - How would I go about doing this? A hex code in this system would be entered like so "{FFFFFF}", which is the hexadecimal code for white, but, how would I detect it? Just finding "{ }" wouldn't be accurate enough.
Posts: 2,593
Threads: 34
Joined: Dec 2007
My old version
pawn Код:
stock bool:IsHex(string[])
{
new pos[2] = {-1,-1},cnt,cur;
while((pos[0] = strfind(string, "{", true, (pos[0] + 1))) != -1)
{
cnt = 0;
for(new d = (pos[0]+1); d < (pos[0]+7); d++)
{
cur = string[d];
if(cur != '\0')
if(('0' <= cur <= '9') || ('A' <= cur <= 'F') || ('a' <= cur <= 'f'))
{
pos[1] = d;
cnt++;
}
}
if((cnt == 6) && (string[pos[1]+1] == '}'))
return true;
}
return false;
}