Home AMX User Forum AMX General Discussion

PROPER_STRING Function

Anyone have one of these floating around so I don't have to roll my own?

Comments

  • mpullinmpullin Posts: 949
    Yes I happen to have one here
    DEFINE_FUNCTION CHAR[20] TITLE_STRING(CHAR str[]){
        STACK_VAR CHAR c[2];
        if(LENGTH_STRING(str) < 2) return UPPER_STRING(str);
        c = LEFT_STRING(str,1);
        GET_BUFFER_CHAR(str);
        return "UPPER_STRING(c),LOWER_STRING(str)";
    }
    

    Hmm I just noticed that this was only designed for single words, sorry... it's a start anyway, you'll have to tokenize for spaces and call this function on each part.
  • PhreaKPhreaK Posts: 966
    Although it's not quite a title case function (still capitalizes 'and', 'or' etc) string_ucwords(..) from the NetLinx Common Libraries may help you out.
Sign In or Register to comment.