String Conversion maxOf()

Hi,

I have a problem with String field.

there is a field XNum as a string, this is used in .net Integration proj. Values are 1,2,3… but it is string value.

How could i find the Maximum of this XNum .

for Ex: XNum is 1,2,3,…,60

if i find MaxOf(XNum) then it is giving something like 9 (Based on string value it is giving the answer)

so first i need to convert it to ‘int’ then i need to find maxOf.

One way is we can put it in loop but it is time consuming…

instead of that, is there any way to find the maxOf(XNum) to get the correct Maximum number 60.

Please help me to resolve this.

Thanks,

Maria

if your string is something like str = “1,2,3,4,5,6,7,8,9,11,12”;

You can found the count of this by putting your string into a container and then count the elements in your container

static void job(Args _args)
{

container c;
str = “1,2,3,4,5,6,7,8,9,11,12”;

int maxLen;

;

c = str2con(s,’,’);

maxLen = conlen(c);

}

my string is like,

XNum = ‘1’

XNum = ‘2’

XNum = ‘10’

it is a record - column value.

thanks and waiting for your reply.

If these are records in table - write a select statement and use maxof in that.

Thanks for your reply.

For your information, this is a str field. So MaxOf is not giving the correct maximum value.

convert your string to a integer

str s = ‘10’;

int i;

i = str2int(‘10’) ;

Hi Maria,

U have to convert those values to int

Bcz if u compare with string values it take ascii values of a string

while taking ascii values it consider only first charecter

Eg:- The ascii value of a 6 is “54”

As well as the ascii value of 64 is also “54”

Since Its a string field you con’t get the maximum using maxOF() function …

but u can do some thing like this…

int maxvalue = 0;

int64 refrecid;

while select tablename

{

if(str2int(tablename.Xnum) >maxvalue)

{

refrecId = tablename.recid;

maxvalue = str2int(tablename)

}

}

Now using the refRecID you can get the maximum record

Best Wishes

Rajabudeen