It is currently Sun Apr 20, 2014 9:35 pm

Function to trim underscores in cell name

Function to trim underscores in cell name

Postby tu2011 » Wed Jun 27, 2012 11:10 pm

/********************************************************************************************************
*FUNCTION: This function trims cell names that ends with an underscore or cell names that ends with an *
* underscore follows by one or more digits. It does not work on a cell name that ends with an*
* underscore follows a string that is a combination of alpha and numerics such as Cell0_01T0. *
* The function returns an LStatusOK if the cell name is changed. Anythings else will be *
* returned as LCreateError. *
*********************************************************************************************************/
LStatus LCell_CellNameUnderscoreTrim(LFile pFile, LCell pCell)
{
char szCellName[MAX_CELL_NAME];
LCell_GetName(pCell, szCellName, MAX_CELL_NAME);

//search for the last occurence of "_" in the cell name.
char* pch;
char* pLast;
pch = strchr(szCellName,'_');
pLast = pch;
while (pch != NULL)
{
pch=strchr(pch+1,'_');
if (pch)
pLast = pch;
}
//If "_" is found, then analyze the rest of the string.
if (pLast)
{
char* pTemp;
pTemp = pLast;
LBoolean bFound = LTRUE;
//If the next character after "_" is not a NULL character, then check
//subsequent character to see if it is a digit or not.
if (pTemp[1] != '\0')
while ((bFound) && (pTemp[1] != '\0'))
{
pTemp++;
//if any of the character is not a digit, then set bFound to FALSE
if (!isdigit(pTemp[0]))
bFound = LFALSE;
}

//If the bFound == TRUE, then truncate the name at the last "_"
if (bFound)
{
pLast[0] = '\0';
LCell_SetName(pFile, pCell, szCellName);
LCell_SetChanged(pCell);
return LStatusOK;
}
else
return LCreateError;
}
if (pLast == NULL)
return LCreateError;
}
tu2011
 
Posts: 21
Joined: Thu Nov 17, 2011 4:08 pm
Location: Los Angeles

Return to UPI and TCL scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 35 on Thu Jan 09, 2014 2:15 am

Users browsing this forum: No registered users and 1 guest

Login Form