Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse2File

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to fill a file (or better the clipboard) with the contence of a browse (with query) using a button. Who can help me?

Aad Mess
Netherlands
aadmess@wishmail.net
 
This is an example of streaming a source table to a comma,quote delimited ASCII file. You can use the same principles to create a local routine to accomplish the same from a browse procedure. I believe all of the syntax to be valid, I don't think I removed too much.
HTH

PROGRAM
MAP
CheckError(), LONG
END
INCLUDE('KEYCODES.CLW')

!!
!! SOURCE TABLE DEFINITIONS
!!

MySource FILE,DRIVER('MSSQL'),OWNER('cnt'),NAME('dbo.mySource'),PRE(mySource),BINDABLE
PK_MySource KEY(mySource:SystemID),NAME('PK_MySource'),NOCASE,PRIMARY
Record RECORD
SystemID DECIMAL(18)
FirstName CSTRING(51)
LastName CSTRING(51)
END

!!
!! TARGET TABLE DEFINITIONS
!!

MyExport FILE,DRIVER('ASCII','/CLIP=ON'),NAME('MyExport.ASC'),PRE(MyExport)
Record RECORD
RecLine STRING(65520)
END
END
CODE

OPEN(MySource) ! OPEN mySource SOURCE TABLE
IF CheckError() THEN ! TEST FOR ERROR
Message('Error opening: mySource') ! NOTIFY OPERATOR OF ERROR
Exit ! BAIL OUT OF THIS ROUTINE
END
SET(myExport) ! INIT SEQUENTIAL ACCESS
CREATE(myExport) ! CREATE myExport TARGET
IF CheckError() THEN ! TEST FOR ERROR
Message('Error creating: MyExport') ! NOTIFY OPERATOR OF ERROR
Exit ! BAIL OUT OF THIS ROUTINE
END
OPEN(myExport) ! OPEN MyExport
IF CheckError() THEN ! TEST FOR ERROR
MESSAGE('Error opening: MyExport') ! NOTIFY OPERATOR OF ERROR
EXIT ! BAIL OUT OF THIS ROUTINE
ELSE
STREAM(MySource) ! STREAM MySource
STREAM(MyExport) ! STREAM MyExport

CLEAR(MyExport:Record) ! CLEAR THE MyExport RECORD BUFFER
MyExport.RecLine = 'SystemID,FirstName,LastName'
APPEND(MyExport) ! ADD THE MyExport HEADER RECORD

SET(MySource) ! INIT MySource FOR PROCESSING
LOOP ! BEGIN THE PROCESSING LOOP
NEXT(MySource) ! MOVE TO THE NEXT MySource RECORD
IF ErrorCode() = 33 THEN BREAK. ! BAIL OUT OF THIS ROUTINE
CLEAR(MyExport:Record) ! CLEAR THE MyExport RECORD BUFFER
! ASSIGN THE MySource VALUES TO MyExport
! Make your assignements here
MyExport.RecLine = MySource.SystemID & ',"' & MySource.FirstName & '","' & MySource.LastName & '"'

APPEND(myExport) ! ADD THE myExport RECORD
IF CheckError() THEN ! TEST FOR ERROR
MESSAGE('Error appending: myExport') ! NOTIFY OPERATOR OF ERROR
EXIT ! BAIL OUT OF THIS ROUTINE
END
END
FLUSH(MySource) ! CLEAN UP THE MySource STREAM
FLUSH(MyExport) ! CLEAN UP THE MyExport STREAM
IF CheckError() THEN ! TEST FOR ERROR
MESSAGE('Error writing: MyExport') ! NOTIFY OPERATOR OF ERROR
END
CLOSE(MySource) ! CLOSE MySource
CLOSE(MyExport) ! CLOSE MyExport
END

EXIT

CheckError FUNCTION
CODE
IF ERRORCODE() THEN ! TEST FOR ERRORCODE
IF ERRORCODE() = 90 THEN ! TEST FOR ERRORCODE(90)
IF MESSAGE('Error: '& FILEERROR()) THEN ! NOTIFY OPERATOR OF ERROR
RETURN ERRORCODE() ! RETURN THE ERRORCODE
END
ELSE
IF MESSAGE('Error: '& ERROR()) THEN ! NOTIFY OPERATOR OF ERROR
RETURN ERRORCODE() ! RETURN THE ERRORCODE
END
END
END

RETURN 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top