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

MemoWriteToFile(),MemoReadFromFile(),MemoStringFrom(), MemoStringBetween() sample

Download Sample Seeing is believing, so please find attached a sample that showcase what you are looking for. In this sample we...

Product: Dataease [{8}]FIVE. Written by DataEase 20/03/15 at 10:34:53

Re:MemoWriteToFile(),MemoReadFromFile(),MemoStringFrom(), MemoStringBetween() sample

Got some time to sit down to look at this example.  Can't say much more than wow! ... Simple small scripts doing some clever stuff here, ans showing how to use functions to do the type of thing I'm looking for.Also showing off other things...

Product: Dataease [{8}]FIVE. Written by Simon B 23/03/15 at 12:13:11

Re:Re:MemoWriteToFile(),MemoReadFromFile(),MemoStringFrom(), MemoStringBetween() sample

We are glad that you are getting a glimpse &nbsp;of the sunny side of the DE8 coin.It is the biggest challenge for DE8 that it is deceptively similar to previous versions of DFW, when in reality it is a completely different beast altogether.<b...

Product: Dataease [{8}]FIVE. Written by DataEase 25/03/15 at 14:21:47

On the blog about WriteToFile

New function in 8 - MemoWriteToFile() - Write the content of a memo to a text file (Ver. 8.0.01053)

This function is part of a pair, where the opposite is MemoReadFromFile.It is implemented to allow users to export the content of a memo to a text file.So why would we want to do that?With the new Memo manipulation class, memos ca...

Product: Dataease [{8}]FIVE. Written by DataEase 22/02/12 at 09:48:32

New Function in 8 - WriteToFile() - Write/Append a string(256) to a file. (Ver. 8.0.0.1146)

This function is part of a triumvirate, where the other functions are MemoWriteToFile() and MemoReadFromFile(). This function is complimentary, as it will write the content of a "normal" DataEase field or function to a Text file. Ex. WriteToFil...

Product: Dataease [{8}]FIVE. Written by DataEase 16/10/12 at 16:41:16

MemoWriteToFile(),MemoReadFromFile(),MemoStringFrom(), MemoStringBetween() sample

Download Sample Seeing is believing, so please find attached a sample that showcase what you are looking for. In this sample we...

Product: Dataease [{8}]FIVE. Written by DataEase 20/03/15 at 10:47:00


dg3_HelpView