2.1.2.53 string_to_prefix_end_number


Description

Break the given string into prefix string and a terminating integer.

Syntax

int string_to_prefix_end_number( LPSTR lpszBuffer, LPCTSTR lpcszString )

Parameters

lpszBuffer
[output] buffer to receive the prefix string, must allocate enough space
lpcszString
[input] pointer to string to be broken up

Return

returns the end number, or 0 if not terminating with numeric.

Examples

EX1

// This is a self contained sample program for the function string_to_prefix_end_number, 
// Its sample data is created at the beginning of the program. 
// To run the program, enter the following command in the Script window:
//   string_to_prefix_end_number_ex1
// This will return a message like following:
//   Created Workbook Name="Book7" ==> Prefix="Book" Enumeration=7    
//
void string_to_prefix_end_number_ex1()
{
    int nn;
    char szBuffer[MAXLINE];
    
    Worksheet wks;
    wks.Create();
    String szString=wks.GetPage().GetName();  // workbook name as an input string
    
    nn = string_to_prefix_end_number(szBuffer,szString); //Demonstration of string_to_prefix_end_number
    
    if(lstrlen(szBuffer) != szString.GetLength()) // test if not broken up
        printf("Created Workbook Name=\"%s\" ==> Prefix=\"%s\" Enumeration=%d\n",szString,szBuffer,nn);
    else
        printf("Error: string_to_prefix_end_number failed to break up %s.\n",szString);
}

Remark

break the given string into prefix string and a terminating integer. If the string is terminating with 0, then the return value will be zero. In this case,you will need to compare the resulting prefix string with the original string to see if it was indeed broken up. This function supports a largest termination value of 99999.

See Also

Header to Include

origin.h

Reference