Manage Learn to apply best practices and optimize your operations.

"Field" function

A function in LotusScript that provides the equivalent functionality of the @WORD @Function.

A function in LotusScript that provides the equivalent functionality of the @WORD @Function.

 Function Field(InputStr As String, DelimChr As String, PosNo As Integer) 'The DelimChr must be a single character or else function will return an error 'InputStr is a text string of any length that contains delimiters 'DelimChr must be a single text character used to delimit substrings (values) 'PosNo is a integer that indicates which value is to be returned MaxLen = Len(InputStr) ErrMsg = "" 'Check for various types of errors If PosNo < 1 Then ErrMsg = "Starting position < 1" Elseif DelimChr = "" Then ErrMsg = "Delimeter is null" Elseif Len(DelimChr) > 1 Then ErrMsg = "Delimeter is > 1 character" Elseif MaxLen < 1 Then Field = "" Exit Function 'No input string passed to function - just return an empty string - not considered an error End If If ErrMsg <> "" Then 'If there was error detected - display message and exit Msgbox "Error: Invalid parameter!" + Chr(13) + Chr(13) + ErrMsg,16,"Field Function" Field = "" Exit Function End If DelimCnt = 0 'Keeps track of how many delimiters were found StartSrchPos = 1 'Initialize where to start looking in the string StartDelimPos = 0 'Will hold the physical postion where the desired delimiter was found EndDelimPos = 0 'Will hold the physical position where the next delimiter was found For J = 1 To PosNo DelimPos = Instr(StartSrchPos,InputStr,DelimChr) If DelimPos > 0 Then 'Delimiter found in the sub- string DelimCnt = DelimCnt + 1 'Keep track of what number of delimiter this is If DelimCnt = PosNo - 1 Then StartDelimPos = DelimPos 'Keep going - not the right delimiter position Elseif DelimCnt = PosNo Then EndDelimPos = DelimPos Exit For 'Exit loop - the right delimiter position has been found End If StartSrchPos = DelimPos + 1 'The next search will begin just after the last delimiter was found Else Exit For 'Exit loop - no more delimiters found End If Next J If StartDelimPos > 0 And EndDelimPos > 0 Then If StartDelimPos+1 = EndDelimPos Then Field = "" Exit Function 'There is no gap between the two delimiter positions - return nothing End If End If If StartDelimPos > 0 Or EndDelimPos > 0 Then If EndDelimPos > 0 Then Field = Mid$(InputStr,StartDelimPos+1,EndDelimPos- (StartDelimPos+1)) 'Return those bytes between the 2 delimiter positions Else Field = Mid$(InputStr,StartDelimPos+1,MaxLen) 'No subsequent delimiter was found - return the remainder of the string End If Else 'If the input string doesn't contain a delimiter and the 1st occurrance was requested, just return the entire string else return nothing If PosNo = 1 And DelimCnt = 0 Then Field = InputStr Else Field = "" End If End Function

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...