Options

SelectStr usage

ericleungericleung Member Posts: 14
Hi,

I want to use selectstr to get the content of a comma-separated string, but if the content have repeated more than once, the function seems not work:

E.g. if the string is : 'abc,abc'
it prompt: 'STRSET' cannot contain "abc" more than once.

Do anyone know any ways to do with the function or another ways to do this??

Many Many Thanks in advance!

Comments

  • Options
    BeliasBelias Member Posts: 2,998
    if you hit F1 you'll see that the help online says:
    Comments
    SELECTSTR treats string values as OPTIONS. This means that identical values in different strings are not allowed.
    commaposition := strpos(mystring,',');
    copystr(mystring,1,commaposition - 1); //copy the first value
    
    this is stupid code, that you should elaborate in with some loops etc. to retrieve the values.
    basically, copystr and strpos function will do the trick for you
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    ericleungericleung Member Posts: 14
    That's OK. Really thanks for your comments!!!
  • Options
    reijermolenaarreijermolenaar Member Posts: 256
    Hi Eric,

    I always use the following function:
    SelectStr2(Number : Integer;VAR Options : Text[1024]) ExitValue : Text[1024]
    i := 1;
    SplitCounter := 1;
    WHILE (i <= STRLEN(Options)) AND (SplitCounter <= Number) DO BEGIN
      IF Options[i] = ',' THEN
        SplitCounter += 1
      ELSE
        IF SplitCounter = Number THEN
          ExitValue += FORMAT(Options[i]);
      i += 1;
    END;
    

    Regards,

    Reijer
    Reijer Molenaar
    Object Manager
Sign In or Register to comment.