I'm converting what was originally a HC stack, then an SC stack into what I would like to be a Revolution project.
Basically, it creates a series of files containing HTML code, using data stored in cards.
I end up with a dozen or so pages of HTML, each page saved as a separate disk file for FTP-ing to a server. It's worked this way for 15 years or so.
Now with the conversion to Revolution well on its way, I notice that the disk files do not get rewritten when I run the relevant script. Instead, if the new page is shorter, then part of the old page is left tagged on at the end, creating all sorts of HTML errors, of course.
The files are closed correctly in the scripts, so I assume that Revolution handles files differently to HC and SC (where the files have always reflected only the current situation and all previous information is "overwritten"). It looks as if, if the new data is shorter than that in the previous file, the EOF is left at the end of the old data, instead of being positioned at the end of the new data. Does this mean that I must somehow delete the files completely before writing to them?
I'm using RevMedia 4.0.
Any help would be appreciated.
Writing to files
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Writing to files
This is from the dictionary. Note the last line, thats most likely whats up.
Use the for write form to open the file for writing. If the file is opened for writing, the write to file command replaces the file's contents from the starting point to the end of the file.
Important: before opening any file for writing to, remember to back up the file contents as Revolution will erase them even if you don't write to the file after opening it.
Use the for update form to open the file for both reading and writing. If the file is opened for update, you can use both the read from file and write to file commands to examine or change it, and writing to the file places the data at the specified position without replacing other characters beyond the written data.
Use the for append form to open the file for writing. If the file is opened for append, the write to file command adds its data to the end of the file without replacing its current contents.
If you don't specify a form, the file is opened for update.
Re: Writing to files
Thank you very, very much Sturgis!
Re: Writing to files
Hi exheusden,
you should also get used to a slightly different syntax to access files in Rev, one liners, which will save a lot of typing
...
## For text:
put "This is text, but could also be avariable" into url("file:" & place2storeTheFile)
## For binary stuff:
put Variable_with_binary_data into url("BINfile:" & place2storeTheFile)
...
This syntax will also work with "before" (write stuff at the beginning of the file) "after" and all combinations just like text operations in a field!
...
put "DDDDDD" after char 5 of line 3 of url("file:" & place2storeTheFile)
...
You get the picture
Best
Klaus
you should also get used to a slightly different syntax to access files in Rev, one liners, which will save a lot of typing

...
## For text:
put "This is text, but could also be avariable" into url("file:" & place2storeTheFile)
## For binary stuff:
put Variable_with_binary_data into url("BINfile:" & place2storeTheFile)
...
This syntax will also work with "before" (write stuff at the beginning of the file) "after" and all combinations just like text operations in a field!
...
put "DDDDDD" after char 5 of line 3 of url("file:" & place2storeTheFile)
...
You get the picture

Best
Klaus