Writing text files 
Author Message
 Writing text files

Hello:

Does any body know how to write a text file from Clarion?

I need to write a text file with information from a Clarion database .tps
here is a sample of what I need:

I have to create a text file with the ".pol" extension with data from two
Clarion's tables ".tps", and  before creating it, I should be able to get a
new file name from the user.

The following is a short sample of what should the text file should have,
this is a two record file,
there are two carriage returns in one record, because that's how we know
that we are talking
about income or expense, two carriage returns means that is a expense and
one means income.
The headers are variables that might be taken from a different table that
the detail.

NOTE:  I will use the "!" for placing comments to you, there should be
carriage returns after each
value in the text file.

                TEST.POL
**************************************************************************
Dr                              !This is the beggining of the header (Variable)
 25                             !This is part of the header there is a space before # 25 (Variable)
Incomes and Expenses    !This is part of the header (Variable)
                                !This is the end of the header (Fixed)
5000-001-002   0                !This is the beggining of one record (Data from the
detail table)
Income sample                           !This is the concept (Data from the detail table)
6396.32                         !This is the end of the record (Data from the detail table)
5011-001-001   0                !This is the beggining of one record
Expense sample                            

413230.88                       !This is the end of the record
FIN                             !This is the end of the file
**************************************************************************
This is exactly how my text file should look, obviously without the
Comments, keep in mind that this text file is not for use with Clarion,
it's just a regular text file.
I hope this can be done using Clarion, otherwise I will need your advise in
order to write a foxpro database
from a Clarion table so I can create the text file using Foxpro.

I thank you in advance for all the help that you could give regarding this
matter.

Regards,

Rafael M. Queb Galicia
Infotech



Tue, 23 May 2000 03:00:00 GMT  
 Writing text files

Quote:
>I have to create a text file with the ".pol" extension with data from two
>Clarion's tables ".tps", and  before creating it, I should be able to get a
>new file name from the user.

Perhaps this will be a little clearer ...  I get my programming languages
mixed up at times...

PrintFile             FILE,DRIVER('ASCII'),NAME('test.pol'),PRE(PRT),CREATE
Record                   RECORD,PRE()
LineInfo                    STRING(80)
                         END
                       END

  OPEN(PrintFile)
  Do PrintHeader
  LineInfo=Variable3 !5000-001-002   0
  ADD(PrintFile)
  ... Etcetera.
  LineInfo='FIN'
  ADD(PrintFile)
  CLOSE(PrintFile)

PrintHeader  ROUTINE
  LineInfo='Dr ' & Variable
  ADD(PrintFile)

  ADD(PrintFile)
  LineInfo='Incomes and Expenses'
  ADD(PrintFile)

Is this what you are looking for?  Each ADD that you execute adds an extra
line to the data file.

Rob



Tue, 23 May 2000 03:00:00 GMT  
 Writing text files

It seems to me that the simplest way would be to set up an ASCII file in
your dictionary with the fields defined for the data that you are writing
since it is a fixed format.  Simply fill the fields from your .TPS file and
ADD each record.  This should create a nicely formatted file.

If your file does not use a fixed format, then just define one field that is
as long as your longest line, then set the field = to the data you want to
present and ADD the lines one at a time.  If I recall correctly, ASCII files
are always appended with the ADD command.

Good luck!

Rob


Quote:
>Hello:

>Does any body know how to write a text file from Clarion?

>I need to write a text file with information from a Clarion database .tps
>here is a sample of what I need:

>I have to create a text file with the ".pol" extension with data from two
>Clarion's tables ".tps", and  before creating it, I should be able to get a
>new file name from the user.

>The following is a short sample of what should the text file should have,
>this is a two record file,
>there are two carriage returns in one record, because that's how we know
>that we are talking
>about income or expense, two carriage returns means that is a expense and
>one means income.
>The headers are variables that might be taken from a different table that
>the detail.

>NOTE:  I will use the "!" for placing comments to you, there should be
>carriage returns after each
>value in the text file.

> TEST.POL
>**************************************************************************
>Dr !This is the beggining of the header (Variable)
> 25 !This is part of the header there is a space before # 25 (Variable)
>Incomes and Expenses  !This is part of the header (Variable)
> !This is the end of the header (Fixed)
>5000-001-002   0 !This is the beggining of one record (Data from the
>detail table)
>Income sample           !This is the concept (Data from the detail table)
>6396.32 !This is the end of the record (Data from the detail table)
>5011-001-001   0 !This is the beggining of one record
>Expense sample

>413230.88 !This is the end of the record
>FIN !This is the end of the file
>**************************************************************************
>This is exactly how my text file should look, obviously without the
>Comments, keep in mind that this text file is not for use with Clarion,
>it's just a regular text file.
>I hope this can be done using Clarion, otherwise I will need your advise in
>order to write a foxpro database
>from a Clarion table so I can create the text file using Foxpro.

>I thank you in advance for all the help that you could give regarding this
>matter.

>Regards,

>Rafael M. Queb Galicia
>Infotech




Tue, 23 May 2000 03:00:00 GMT  
 Writing text files

Hi Rafael,



Quote:
>I have to create a text file with the ".pol" extension with data from two
>Clarion's tables ".tps", and  before creating it, I should be able to get a
>new file name from the user.

Easy:)  You need to declare the ascii file and the file name variable
as well as a bit of code:

Loc:FileName   STRING(255),STATIC
POLFile        FILE,DRIVER('ASCII'),CREATE,NAME(Loc:FileName),PRE(POL)
Record           RECORD
TextLine           STRING(255)
                 END
               END

 Code
 IF FileDialog('Name for new file',Loc:FileName,'POL files|*.pol',1)
   Do WriteFile
 END

WriteFile   ROUTINE
  Create(POLFile)
  Open(POLFile)

Quote:
>**************************************************************************

 POL:TextLine = ALL('*',80)
 Add(PolFile)

Quote:
>Dr                          !This is the beggining of the header (Variable)

 POL:TextFile = 'Dr'
 Add(PolFile)

Quote:
> 25                         !This is part of the header there is a space before # 25

 Pol:TextLine = ' 25'
 Add(PolFile)

(Variable)

 Pol:TextLine = Clip(Variable)
 Add(PolFile)

Quote:
>Incomes and Expenses        !This is part of the header (Variable)

 Pol:TextLine = 'Incomes and Expenses'
 Add(PolFile)

Now you need to loop through your datafiles.  Don't know what you need
here, but something like:

 Set(MyDataFile)
 Loop
   Next(MyDataFile)
   If ErrorCode()
     Break
   End

Quote:
>5000-001-002   0            !This is the beggining of one record (Data from the

   Clear(Pol:TextLine)
   Pol:TextLine[1  : 12] = CLA:Data1
   Pol:TextLine[13 : 17] = Cla:Data2
   Add(PolFile)

Quote:
>Income sample                       !This is the concept (Data from the detail table)

   Pol:TexLine = Clip(CLA:Header)
   Add(PolFile)

Quote:
>6396.32                             !This is the end of the record (Data from the detail

   Pol:TextLine = CLA:Value
   Add(PolFile)
 End  ! Looping through the datafiles

Quote:
>FIN                         !This is the end of the file

 Pol:TextLine = 'FIN'
 Add(PolFile)

Quote:
>**************************************************************************

 Pol:TextLine = ALL('*',80)
 Add(PolFile)

 Close(PolFile)

Hope this helps you along:)

Best regards,

Arnor Baldvinsson
Allerup Edb
Tel: +45 4675 7122
Fax: +45 4675 7144
Denmark


http://www.icetips.com
UIN nr.: 2428601



Wed, 24 May 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Please help Visual Basic Programer with simple read/write text file routine---Real Basic 2.1

2. Writing Text File on a LIFO Basis - How ?

3. How to write text files in UTF8?

4. Write 2D Text Array in a text file

5. Writing to Text file

6. Writing text to file with font

7. writing to an existing text file HELP!

8. Print to file writes Unix text only?

9. Help on Reading & Writing to Text File

10. Write text to excel file

11. Write\append multiple times to a text file

12. Writing float numbers as text in a file?

 

 
Powered by phpBB® Forum Software