Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Shorter and simpler macro code (work in my LO 4.0.2-or-better on Ubuntu) for word function:

Function Wordf(SourceString, Posisi, Optional Delimiter As String) as String
    Dim sx() As String
    if Posisi <= 0 then Goto SALAH
    If IsMissing(Delimiter) then Delimiter = " "
    sx = Split(SourceString, Delimiter)
    if Ubound(sx) < (Posisi - 1) then Goto SALAH
    If Lbound(sx) >= Ubound(sx) then Goto SALAH
    Wordf = sx(Posisi - 1)
    Exit Function

    SALAH:
    Wordf = "#- Error: No Result"
End Function

>

Shorter and simpler macro code (work in my LO 4.0.2-or-better on Ubuntu) for word function:

Function Wordf(SourceString, MY_Wordf(SourceString, Posisi, Optional Delimiter As String) as String
    Dim sx() As String
    if Posisi <= 0 then Goto SALAH
    If IsMissing(Delimiter) then Delimiter = " "
    sx = Split(SourceString, Delimiter)
    if Ubound(sx) < (Posisi - 1) then Goto SALAH
    If Lbound(sx) >= Ubound(sx) then Goto SALAH
    Wordf MY_Wordf = sx(Posisi - 1)
    Exit Function

    SALAH:
    Wordf MY_Wordf = "#- Error: No Result"
End Function

>