Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define iStrLoop(%0,%1) for (new %1 = 0, j = strlen(%0); %1 < j; ++%1)
- #define MaxChars 256
- stock iStrReverse(sStr[])
- {
- new sTmp[MaxChars];
- for(new j = strlen(sStr); j > -1; --j)
- {
- sTmp[strlen(sTmp)] = sStr[j];
- }
- return sTmp;
- }
- stock iStrReplace(sFrom[],sStr[],sTo[])
- {
- new iFind = strfind(sFrom,sStr,true);
- strdel(sFrom,iFind,iFind + strlen(sStr));
- strins(sFrom,sTo,iFind,MaxChars);
- return sFrom;
- }
- stock iStringDel(sFrom[],sDel[])
- {
- return iStrReplace(sFrom,sDel,"");
- }
- stock iStrNumeric(sStr[])
- {
- iStrLoop(sStr,o)
- if (sStr[o] > '9' || sStr[o] < '0') return false;
- return true;
- }
- stock iValToStr(iVal)
- {
- new sStr[12];
- valstr(sStr,iVal);
- return sStr;
- }
- stock iCharToChar(sStr[],cChar1,cChar2)
- {
- iStrLoop(sStr,o) if(sStr[o] == cChar1) sStr[o] = cChar2;
- return sStr;
- }
- stock iStrToStr(sStr[],sTo[],iIni,iEnd)
- {
- strmid(sTo,sStr,iIni,iEnd,MaxChars);
- strdel(sStr,iIni,iEnd);
- return sTo;
- }
- stock iStrCopyStr(sStr[],sTo[])
- {
- format(sTo,MaxChars,sStr);
- return sTo;
- }
- stock iRamdomStr(iMaxLen)
- {
- new
- sStr[128],
- sOut[61] = "qwertyuiop´[asdfghjklç~]zxcvbnm,.;/\'1234567890-=¹³£²³¢£³¢£¢¬";
- for(new i, j = strlen(sOut); i < iMaxLen; ++i)
- {
- sStr[i] = sOut[random(j)];
- }
- return sStr;
- }
- stock iStrLower(sStr[])
- {
- iStrLoop(sStr,i) if (0x41 <= sStr[i] <= 0x5A) sStr[i] += 32;
- return sStr;
- }
- stock iStrUpper(sStr[])
- {
- iStrLoop(sStr,i) if (0x61 <= sStr[i] <= 0x7A) sStr[i] -= 32;
- return sStr;
- }
- //#define strtok(%1,%0) iStrTok(%1,1)
- stock iStrTok(sStr[],iSpace,cSplit = ' ')
- {
- new iLoop = 0,iSpaces = 0,iStr[32];
- while(iSpaces != iSpace) if(sStr[++iLoop] == cSplit) ++iSpaces;
- ++iLoop,format(iStr,32,sStr[iLoop]);
- return iStr;
- }
- stock iStrFilter(sStr[])
- {
- new sFilter[56] = "çÇáéíóúýÁÉÍÓÚÝàèìòùÀÈÌÒÙãõñäëïöüÿÄËÏÖÜÃÕÑâêîôûÂÊÎÔÛ æ¿•";
- new sFiltred[56] = "cCaeiouyAEIOUYaeiouAEIOUaonaeiouyAEIOUAONaeiouAEIOU o?°";
- iStrLoop(sStr,i) for(new l; sFilter[l]; ++l)
- if(sStr[i] == sFilter[l]) sStr[i] = sFiltred[l];
- return sStr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement