Hello Friends, i had used a very useful installscript function for testing a string for alphanumeric characters. The function will accept the string to be tested as a parameter.
You can use the below code and can edit according to your need.
prototype IsAlphanumeric (string);
function IsAlphanumeric (szStuff)
/* Check if a string is alphanumeric
In: szStuff -- string to test
Out: Returns TRUE or FALSE
*/
#define ALPHANUMERIC_CHARS "abcdefghijklmnopqrstuvwxyz_0123456789"
// For my purposes, underscore is considered alphanumeric.
number nPos;
string szChar;
begin
for nPos = 0 to StrLength (szStuff)
StrSub (szChar, szStuff, nPos - 1, 1);
if !(ALPHANUMERIC_CHARS % szChar) then
return FALSE;
endif;
endfor;
return TRUE;
end;
You can use the below code and can edit according to your need.
prototype IsAlphanumeric (string);
function IsAlphanumeric (szStuff)
/* Check if a string is alphanumeric
In: szStuff -- string to test
Out: Returns TRUE or FALSE
*/
#define ALPHANUMERIC_CHARS "abcdefghijklmnopqrstuvwxyz_0123456789"
// For my purposes, underscore is considered alphanumeric.
number nPos;
string szChar;
begin
for nPos = 0 to StrLength (szStuff)
StrSub (szChar, szStuff, nPos - 1, 1);
if !(ALPHANUMERIC_CHARS % szChar) then
return FALSE;
endif;
endfor;
return TRUE;
end;
No comments:
Post a Comment