Re: Get text from a string


[ Follow Ups ] [ BasicCard User Forum ]

Posted by zeitcontrol (145.254.160.252) on May 21, 2003 at 05:56:29:

In Reply to: Get text from a string posted by niklas on May 19, 2003 at 19:18:42:

Hello,

We do not have a special command for doing this but basically your idea is correct. You can use some sort of this code :

------8<------
    dim indexStart as integer = 0
    dim indexEnd as integer = 0
    dim i as integer
    dim result as string = ""

    dim searchStart as string = "chosen-"
    dim searchEnd as string = "C is"
 
    for i = 1 to len(data) - len(searchStart)
        if (mid$(data, i, len(searchStart)) = searchStart) then
            indexStart = i + len(searchStart)
            exit for
        end if 
    next i

    if indexStart <> 0 then
        for i = indexStart to len(data) - len(searchEnd)
            if (mid$(data, i, len(searchEnd)) = searchEnd) then
                indexEnd = i
                exit for
            end if 
        next i
        
        if (indexEnd <> 0) then
            result = mid$(data, indexStart, indexEnd - indexStart)
        end if
    end if

------>8------

Note,
it is possible to write this on the card itself but for execution speed propose you should do as much as possible on the host computer. (eg. extract these kinds of substrings)

greetings juergen mengeling



Follow Ups:


[ Follow Ups ] [ BasicCard User Forum ]