RETURN_STRING |
![]() ![]() |
RETURN_STRING( string-value )
Returns a STRING. Note that you have to use mb_malloc, MAKE_STRING or COPY_STRING to create this string before returning it since it will be freed by the MyBASIC2 interpreter once it is no longer used. Omitting to do so will result in a memory error.
Example
///////////////////////////////////////////////////////////////////////////// // Capitalize each word in a string int _title_case_func( mb_interpreter_t* s, void** l ) { // Parse Parameter BEGIN_PARSE( s, l ) POP_STRING( pStrPar ) END_PARSE
// Make a copy that we can return COPY_STRING( pOutput, pStrPar )
// Make all lower first strlwr( pOutput );
// Always make sure first is Upper pOutput[0] = toupper( pOutput[0] );
// Convert first character of every word to upper case for ( unsigned i = 1; i < strlen( pOutput ); i++ ) { if ( ( pOutput[i-1] == ' ' ) || ( pOutput[i-1] == '\t' ) ) { pOutput[i] = toupper( pOutput[i] ); } }
// Return Converted String RETURN_STRING( pOutput ); }
|