×
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

save .txt file

save .txt file

save .txt file

(OP)
Hi,

I'm new around and I hope you can help me with my problem.
The question is:

How can I make in Browse procedure a button that will when pressed save records (later I will add condition which will tell which records will be saved) to .txt file in some folder in windows.

I'm open to any suggestion. Any way to save text file ?
Please, I'm running out of time.

Thanks in advance and kind regards,
JLP

RE: save .txt file

Hi!

You can use the ASCII (plain text) or BASIC (comma/tab delimited) driver to define a table in the dictionary or in the data section of the procedure.

The generic process would be ::

- assign file path/name
- create/open file
- add records
- close file

If you give me more specifics, I can give you a more helpful reply. Also, what version of Clarion are you using?

Regards

 

RE: save .txt file

(OP)
Thanks for quick response ShankarJ (You RoCk). I'm using Clarion 6.3

The thing is I'm working on program for tourist agency that has evidention about guests, accomodation, owners of houses etc.

In this case I whona save guest registrations made that day.
Something like:

IF RegistrationDate = Today()
   SaveGuestRecordsToTextFile
ELSE
   Nothing

Can you please give me some more information (Code examples maybe and where to put exactly the code)

I would be very thankful, kind regards
JLP
 

RE: save .txt file

Hi I use the free template of NOVA, funtion LINEPRINT, its transparent and no need tables:

THEFILE='C:\EXPORTAR\ARCHIVO.TXT'   !name file with path
IF EXITST(THEFILE) THEN REMOVE(THEFILE) !if not remove, add
                                        !data in the same file!!
LOOP
  IF CONDITION
     LINEPRINT(TABLE:RECORD1&','&....&','&LOC:VAR , THEFILE)
  END
END

And ready!! the archivo.txt is created very fast!
I Hope help you!
Regards
Eduardo.
 

RE: save .txt file

Hi!

As Eduardo says, you can use the LINEPRINT template to print to a file instead of a device or port but using an ASCII/BASIC driver is a cleaner and better approach.

I need some more info before I can give you useful code ::

1. What are the Guest Information details that you plan to save?
2. Are these going to be saved in a particular format (fixed record) OR separated with a comma/tab (delimited data)?

Using an ASCII or BASIC driver file is similar to using a Topspeed or any other file. Assuming that you want to save the information separated with a TAB, the code would be ::

Data Section

CODE

CSVFile                    FILE,DRIVER('BASIC','/COMMA=9'),PRE(CSV),CREATE
Record                       RECORD
GuestID                        STRING(8)
FirstName                      STRING(20)
LastName                       STRING(20)
Address                        STRING(60)
                             END
                           END

Code

CODE

CLOSE(CSVFile)

CSVFile{PROP:Name} = '<DestinationFileAndPath>'

CREATE(CSVFile)
IF ERRORCODE()
   ... handle error
ELSE
   OPEN(CSVFile, 12h)
   IF ERRORCODE()
      ... handle error
   ELSE
      CLEAR(GuestFile)
      Guest:RegDate = TODAY()
      SET(KeyByRegDate, KeyByRegDate) ! assuming Guest:RegDate is the first column
      LOOP
         NEXT(GuestFile)

         IF ERRORCODE() OR Guest:RegDate <> TODAY() THEN BREAK.

         CLEAR(CSV:Record)
         CSV:GuestID   = Guest:GuestID
         CSV:FirstName = Guest:FirstName
         CSV:LastName  = Guest:LastName
         CSV:Address   = Guest:Address

         ADD(CSVFile)
         IF ERRORCODE()
            ... handle error
         END
      END
      CLOSE(CSVFile)
   END
END

Regards



 

RE: save .txt file

Hi!

Don't forget to add the ASCII or BASIC driver to the project.

Regards
 

RE: save .txt file

(OP)
Hi again and thank you guys for your time.

I heard about NOVA template - LINEPRINT function but I can't find it on internet to download it. Any link maybe?

Ok, here's more info:
So far I was always using TopSpeed tables and in this case too so this is my first interaction with ASCII/BASIC tables.

The story in program goes like this:
By the end of the day someone on reception desk must click on the buton "Save" to save informations about reigstreted guests of that day in text document. That's because all registrations must be proced to tourist community and police. So it would be great if it's possible to create new text document for each day named with date of that day.

Thanks for the code but i need some time to implement it :)  
Huh, wish me luck :)
JLP
 

RE: save .txt file

Send me a Email to ecarchano@gmail.com and I send you, no problem
Eduardo

RE: save .txt file

Hi, help please, I need

NOVA template - LINEPRINT

Can any one send it to me?

Thanks thanks  

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