×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Browse2File

Browse2File

Browse2File

(OP)
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

RE: Browse2File

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close