• Splitting a string in MPL...

    From Ktulu@21:2/122 to All on Tuesday, December 05, 2017 19:10:51
    hi guys!

    How do I go about splitting a string into an array in MPL?

    For instance I have a string:

    Banana:Cream:Pie

    How do I split this into an array that I can use the individual array items?

    Thanks!

    --- Mystic BBS v1.12 A35 (Windows/32)
    * Origin: Insane Asylum (21:2/122)
  • From xqtr@21:1/111 to Ktulu on Thursday, December 07, 2017 17:40:10
    For instance I have a string:
    Banana:Cream:Pie
    How do I split this into an array that I can use the individual array items?

    Use The WORD functions ;)

    Function WordCount(S: String; C:Char):Integer;
    Returns the number of words in a string using the final parameter to define
    the character that determines what separates words.

    Function WordGet(P:Byte; S:String; C:Char):String;
    Returns the actual word at a specific word count.

    Function WordPos((P:Byte; S:String; C:Char):Integer;
    WordPos returns the character position in the string where s specific word is located.

    .----- --- -- -
    | Another Droid BBS
    : Telnet : andr01d.zapto.org:9999 [UTC 11:00 - 20:00]
    . Contact : xqtr.xqtr@gmail.com

    --- Mystic BBS v1.12 A34 (Raspberry Pi/32)
    * Origin: Another Droid BBS (21:1/111)
  • From Ktulu@21:2/122 to xqtr on Thursday, December 07, 2017 13:10:18
    Yep. I got it. Thank you. Works great too.



    Use The WORD functions ;)

    --- Mystic BBS v1.12 A35 (Windows/32)
    * Origin: Insane Asylum (21:2/122)
  • From Gryphon@21:1/120 to Ktulu on Thursday, December 07, 2017 11:54:39
    On 12/05/17, Ktulu said the following...

    hi guys!

    How do I go about splitting a string into an array in MPL?

    For instance I have a string:

    Banana:Cream:Pie

    How do I split this into an array that I can use the individual array items?

    The WordCount() and WordGet() functions should help you.

    no_of_words=WordCount(':',TestString)

    for loop := 1 To no_of_words do begin
    some_array[loop]:=WordGet(loop,TestString,':')
    end

    --- Mystic BBS v1.12 A36 2017/12/03 (Linux/64)
    * Origin: Cyberia BBS | cyberia.darktech.org | San Jose, CA (21:1/120)