Results 1 to 4 of 4

Thread: Usage of the SPLIT Keyword

  1. #1
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Usage of the SPLIT Keyword

    [code=thinbasic]
    ' Usage of the SPLIT Keyword example
    '
    ' Return Number the number of tokens found.

    '
    ' Written by Abraxas

    DIM sMainString AS STRING VALUE "THIS,IS,MY,STRING" '
    DIM ArrayName() AS DWORD value 0
    DIM Delimiter AS STRING VALUE "," ' Character used to seperate
    dim n as DWORD Value 0
    DIm sMsg AS STRING

    sMsg = "SMainString = " & sMainString & $CRLF & $CRLF
    sMsg += "Delimiter = " & Delimiter & $CRLF & $CRLF
    sMsg += "Tokens found = " & SPLIT(sMainString, Delimiter, ArrayName)

    MSGBOX 0, sMsg
    [/code]
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Usage of the SPLIT Keyword

    Modified to:

    [code=thinbasic]
    Dim sMainString As String VALUE "THIS,IS,MY,STRING" '
    Dim ArrayName() As String
    Dim Delimiter As String VALUE "," ' Character used to seperate
    DIM nTokens As DWord
    Dim Counter As DWord
    Dim sMsg As String

    sMsg = "SMainString = " & sMainString & $CRLF & $CRLF
    sMsg += "Delimiter = " & Delimiter & $CRLF & $CRLF
    nTokens = SPLIT(sMainString, Delimiter, ArrayName)
    sMsg += "Tokens found = " & nTokens & $CRLF & $CRLF

    sMsg += "Tokens are the following:" & $CRLF
    For Counter = 1 to nTokens
    sMsg += format$(Counter, "000") & $TAB & ArrayName(Counter) & $CRLF
    next

    MSGBOX 0, sMsg
    [/code]
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Usage of the SPLIT Keyword

    just to make it easier to read. What do you think?

    [code=thinbasic]
    nTokens = SPLIT(sMainString, Delimiter, ArrayName)

    sMsg = "SMainString = " & sMainString & $CRLF & $CRLF
    sMsg += "Delimiter = " & Delimiter & $CRLF & $CRLF
    sMsg += "Tokens found = " & nTokens & $CRLF & $CRLF
    [/code]

    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Usage of the SPLIT Keyword

    Agree. Thanks
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. Usage of the CHR$ Keyword
    By Michael Clease in forum Samples for help file
    Replies: 1
    Last Post: 28-05-2007, 07:40
  2. Usage of the HEX$ Keyword
    By Michael Clease in forum Samples for help file
    Replies: 1
    Last Post: 28-05-2007, 07:39

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •