### phone number questions

Mon, 07/19/2004 - 09:05

### Forums:

Hi, all,

I want to get the last 10 digits of the MDN (31000510xxxxxxx) returned using ITAPI interface, ITAPI_GetStatus() to be exact. How do I do that?

on Verizon phones, this can always get the correct number by doing some trimming, for example, if your number is 510xxxxxxx, the szMobileID obtained will be 31000510xxxxxxx. all you need to do is to get the last 10 digits.

My question is, what specific functions or C helper functions do I use, to tell the program only start at a postion that I desired? Some code snippets would help.

Thank you.

Mon, 07/19/2004 - 10:14

ruben wrote:Modulo division by 10 would do that for you

Can you be more specific? Do you mean %10? How would that solve anything? Could you give a code sample, just a line, maybe that'll help me a lot.

Thank you.

ruben wrote:Modulo division by 10 would do that for you

Can you be more specific? Do you mean %10? How would that solve anything? Could you give a code sample, just a line, maybe that'll help me a lot.

Thank you.

Mon, 07/19/2004 - 11:18

Ruben probably meant to say modulo by 100000 and he's correct. Simply do a modulo of 100000 on the number and you should be all set. Actually, since you need the last 10 digits it would have to be a modulo 10000000000 operation. Boy, that's a big number...

Alternatively, you could convert it into a string, then truncate the string to only the last 10 characters and convert it back to an integer. Normally sprintf( buffer, "%-10d", number ) would do the trick but I do not think that the BREW implementation of the function is good enough to handle that. You can always give it a try, though.

Ruben probably meant to say modulo by 100000 and he's correct. Simply do a modulo of 100000 on the number and you should be all set. Actually, since you need the last 10 digits it would have to be a modulo 10000000000 operation. Boy, that's a big number...

Alternatively, you could convert it into a string, then truncate the string to only the last 10 characters and convert it back to an integer. Normally sprintf( buffer, "%-10d", number ) would do the trick but I do not think that the BREW implementation of the function is good enough to handle that. You can always give it a try, though.

Tue, 07/20/2004 - 00:35

MDN returned by ITAPI_GetStatus is already a string, isn't it?

And string is an array of chars... So, walterm, why you just don't start with an array element you need?

ITAPI* pTAPI = NULL;

TAPIStatus tapiStatus;

int phonenumlast3digits = 0;

int phonenumfirst3digits = 0;

// get phone number

ISHELL_CreateInstance(pmb->a.m_pIShell, AEECLSID_TAPI, (void**)&pTAPI);

if (pTAPI)

{

ITAPI_GetStatus(pTAPI, &tapiStatus);

if(!pmb->m_sync_config.m_szPassword[0])

// here is how you get any part of the number

DBGPRINTF(&tapiStatus.szMobileID[5]);

phonenumlast3digits = ATOI((&tapiStatus.szMobileID[MOBILE_ID_LEN - 3]);

tapiStatus.szMobileID[3] = 0;

phonenumfirst3digits = ATOI(tapiStatus.szMobileID);

ITAPI_Release(pTAPI);

MDN returned by ITAPI_GetStatus is already a string, isn't it?

And string is an array of chars... So, walterm, why you just don't start with an array element you need?

ITAPI* pTAPI = NULL;

TAPIStatus tapiStatus;

int phonenumlast3digits = 0;

int phonenumfirst3digits = 0;

// get phone number

ISHELL_CreateInstance(pmb->a.m_pIShell, AEECLSID_TAPI, (void**)&pTAPI);

if (pTAPI)

{

ITAPI_GetStatus(pTAPI, &tapiStatus);

if(!pmb->m_sync_config.m_szPassword[0])

// here is how you get any part of the number

DBGPRINTF(&tapiStatus.szMobileID[5]);

phonenumlast3digits = ATOI((&tapiStatus.szMobileID[MOBILE_ID_LEN - 3]);

tapiStatus.szMobileID[3] = 0;

phonenumfirst3digits = ATOI(tapiStatus.szMobileID);

ITAPI_Release(pTAPI);

Mon, 07/19/2004 - 09:39

Modulo division by 10 would do that for you

Modulo division by 10 would do that for you