Supercard vs. Rev
Ken Ray
kray at sonsothunder.com
Fri Mar 14 17:53:01 EST 2003
> Show me another language family that has chunk expressions
> and I'll show you as few lines of code as we xTalkers enjoy
> every day.
Quite true, and here's an example:
Revolution:
-----------
answer (item 4 of "Chunk,Expressions,Are,Cool")
Visual Basic:
-------------
MsgBox GetItem("Chunk,Expressions,Are,Cool",4)
Public Function GetItem(ByVal tData As Variant, ByVal tItemNum As
Integer)
startChar = 1
countitem = 0
Done = False
tDelim = ","
tData = tData & tDelim
While Done = False
charOff = InStr(startChar, tData, tDelim)
If charOff = 0 Then
'Encountered end of data before hitting line tLineNum
GetItem = "-1"
Done = True
Else
countitem = countitem + 1
If countitem = tItemNum Then
If charOff = startChar Then
'Empty item
GetItem = ""
Done = True
Else
GetItem = Mid$(tData, startChar, (charOff -
startChar))
Done = True
End If
Else
startChar = charOff + 1 'Deals with the crlf
End If
End If
Wend
tData = Left$(tData, Len(tData) - 1)
End Function
The VB function above was one of a library of "xTalk" functions I wrote
back in the late 90's in order to attempt to even get *close* to xTalk
chunking capability in VB. Arguably it can be tightened up a bit, but
you get the idea...
Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode
mailing list