Approach User Support homepage Approach User Support
Answers to Frequently Asked Questions about Lotus Approach
Examples LotusScripts
Example databases
Links to other Lotus Approach support services

[Return to contents]

Example LotusScript: Named Find Event with selection sort

Last updated: before December, 1998

This is another version of Paul Bent's Named Find Event script with a selection sort routine added by John Brown

Sub Switchto(Source As Form, View As VIEW)
        
        Dim aFinds As Variant, UB As Integer, aFStr() As String, C As Integer, Temp As String, Lowest As Integer, Start As Integer
        
'We need an array of variants to get the named finds then a string array to set the list from
        aFinds = CurrentDocument.NamedFindSorts
        UB = Ubound(aFinds)
        
'Now we know how many so resize an array of strings. We need
'data type string to use the SetList method.
        Redim aFStr(UB)
        
'Load the strings into the array
        For C = 0 To UB
                aFStr(C) = aFinds(C)
        Next C
        
' Selection Sort routine
        For Start = 0 To (UB -1)
                Lowest = Start
                For C = (Start + 1) To UB
                        If aFStr(C) < aFStr(Lowest) Then
                                Lowest = C
                        End If
                Next C
                If Lowest <> Start Then
                        Temp = aFStr(Start)
                        aFStr(Start) = aFStr(Lowest)
                        aFStr(Lowest) = Temp
                End If
        Next Start
        
'Populate a dropdown box list with the string array.
'The dropdown box is named FList and is unbound. When I created it I
'had to type z as the first list item because an empty list is not allowed at creation.
        CurrentView.Body.FList.SetList(aFStr)
        
End Sub

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.