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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

save .txt file

Status
Not open for further replies.

JeanLuckPicard

Programmer
May 25, 2011
5
0
0
HR
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
 
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

 
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
 
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.
 
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



 
Hi!

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

Regards
 
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
 
Send me a Email to ecarchano@gmail.com and I send you, no problem
Eduardo
 
Hi, help please, I need

NOVA template - LINEPRINT

Can any one send it to me?

Thanks thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top