Simplicty and flexibility!


Function::File

WriteToFile
WriteToFile(StringToWrite,FileToWriteTo,Mode)
WriteToFile("This is a test","C:\temp\testfile.txt",1) -- will create/overwrite testfile.txt.
retval := WriteToFile(MyTextField,MyFileName,MyMode) .


To create, overwrite or append to any type of text file (including HTML) with the content of a field or string(255). You can use this function to write the content of any DataEase field except Memo to a text file.

in DFD we had Output etc, to create "advanced" export files, but in DFW export has been challenging. With WriteToFile() and MemoWriteToFIle() we have a solution that can make and modify any Text file on the fly.

Parameters


StringToWrite: String

The text/number/date etc. we want to write to the file up to 255 characters a go.

File to write to: String

The full path to the "export file". if you omit the path it will be created in the Applicaiton catalogue. Use GetCurrent("AppPath") to place it relative to the application.

Mode: Integer 

The mode for the write. i.e if you want to overwrite, delete, append or insert the string with or without line feed.

0=Append value to memo field.
1=Overwrite memo field with new value.
2=Delete/Blank Content of memo field.
3=Insert value at beginning of memo field.
4=Append value to Memo with CR in front (Start on new line)
5=Insert value at beginning of memo with CR after.

Returns/Result


Nothing

Examples


Reference

It is implemented to allow users to write a string to a text file.

So why would we want to do that?

With the new Memo manipulation class, memos can be manipulated in any way one like, they are containers for export data, import data, documents, webpages etc etc.

Wouldn't it be neat if one could save or share the content of these fields with oneself or the rest of the world? It is not so easy to send a memo field to someone, but we can all attach a field as a document.

One test users actually created a full website in a DataEase 8 application, and then export all the dynamically generated pages to a webserver with MemoWriteToFile once a day...

The neat thing with MemoWriteToFile is that it is not limited to writing to a file, it can also append to a file, overwrite a file or simply delete a file.

int MemoWriteToFile(MemoToWrite,Filename,Mode)

Mode:
0=Append value to memo field.
1=Overwrite memo field with new value.
2=Delete/Blank Content of memo field.
3=Insert value at beginning of memo field.
4=Append value to Memo with CR in front (Start on new line)
5=Insert value at beginning of memo with CR after.

Again....use your imagination!

See Also


On the forum about WriteToFile

[@EOF@]...

Product: . Written by alembagheri tahmas 07/12/13 at 13:37:32

Hi there,I am trying to use an external MySQL DB in dataease. I have successfully create the ODBC link and added the DB to dataease. I can also access the DB from dataease. Now, just for testing purposes, I am trying to create a simple report b...

Product: DataEase for Windows 7.x. Written by George Washington 11/04/14 at 08:26:17

no se pude exportar ahora archivos a pdf, ni a excel o otros cosa mala. en verdad creo que hace faltaen las versiones anteriores me funcionaba mas o menos bien. le hace falta a los aplicativos que se desarrollan en Dataeasegr...

Product: DataEase 8 Reporter. Written by eduardo paez 02/05/14 at 14:40:11

Thanks. Anyway I'm trying to use this fuction but it seems to me that it doesn't work on 8.2. I tried also in a DQL.There's something wrong?<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9IAAAJ3CAYAAAB4NWk3AAAAAXNSR0IArs4...

Product: . Written by Marco Marchesi 15/02/16 at 14:50:46

[@EOF@]...

Product: Dataease [{8}]FIVE. Written by Chamil Rajindra 21/02/19 at 10:17:46

Thanks for the very good explanation!AS...

Product: . Written by afonso santos 28/10/19 at 00:50:14

I am pleased to see that the migration from Dos 4.53 is then sa 5.5 works. A really useful thing would be a compiler of SQL languages. Will you get there?Original Text:Mi compiaccio a vedere che la migrazione da Dos 4.53 รจ poi sa 5.5 funzio...

Product: . Written by Grossi Gioacchino 18/11/19 at 14:33:44

On the blog about WriteToFile


dg3_HelpView