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: Create a delimited text file from two fields

Last updated: before December, 1998

'The purpose of this script is to create an delimited text file from 2 fields
'in a database. Field_1 is a text value to output in every record. Field_2 is
'a grouping field. Many records with similiar attributes can be this value.
'The database is sorted by Field_2 prior to Script execution. This script is
'used to export invoice transactions to a mainframe Cost of Sales and Cost of
'Production application. The mainframe input format requires a batch header
'(Field_2) to preceed each group of detail records (Field_1).  In my App
'Field_1 and Field_2 are calculated fields. I'm testing another variety of
'this as an audit trail or event log on users activity.
Sub Click(Source As Button, X As Long, Y As Long, Flags As Long)
        Dim fileNum As Integer, I As Integer
        Dim N As Long
        Dim fileName As String, many_rec As String, few_rec As String, inv_test As String
        fileNum% = Freefile()
        fileName$ = Curdrive () +"\WINDOWS\TEMP\DATA.TXT"
' Field_1 is an Object name for detail text string to output
' Field_2 is an Object name for batch section text string to output
' Write out the data.
        Open fileName$ For Output As fileNum%
        Write #fileNum%, few_rec$
        Write #fileNum%, many_rec$
' Writes First records information
        Do While I%<= N
                If few_rec$<>batch_test$ Then Gosub ResetHeader
                Write #fileNum%, many_rec
        Close fileNum%
        Goto Skip
        Write #fileNum%, few_rec$
End Sub
'Written by Jerry Sikes <Unisource Converting>, 1996
'(C) Copyright 1996 by Jerry Sikes
'Permission is granted to freely copy this script in electronic form,
'or to print for personal use. It may be use in any Approach database,
'but may not be distributed for profit either by itself or as part of
'a collection or database.
'Disclaimer: This script is provided as is without any express or
'implied warranties. The author assumes no responsibility for errors or
'omissions, or for damages resulting from the use of the information contained
'herein, or your own version containing your desires for the usage of the

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.