{"identifier":51002,"topic":"Commands","name":"write","text":"<code><pre>write <i>text<\/i> to file <i>fileName<\/i> \u00ac\n  [at { eof|end|[-]<i>integer<\/i>]}<\/pre><\/code> <br><br>\n\n The<code> write <\/code>command copies text to a file. You must have already opened the file with the<code> open file <\/code>command, and you should close it when writing is completed with the<code> close file <\/code>command.   <br><br>\n\n The first<code> write <\/code>command after opening a file begins at the start of a file unless you use the <code>at <i>integer<\/i> <\/code>option, with <i><code>integer<\/i> <\/code>as the character position within the file where writing is to begin. <br>\n<br>\nThe<code> -<i>integer<\/i> <\/code> option begins writing at <code> <i>integer<\/i> <\/code>characters from the file's end. <br><br>\n\n <b>Warning: <\/b>HyperCard <b>does not ask<\/b> if you want to write over existing text. <br><br>\n\n Subsequent<code> write <\/code>commands append text to the file\u2019s contents after the last character written until you close the file. <br><br>\n\n Note: You must provide the full path name of the file if it\u2019s not at the same directory level as HyperCard. <br>\n","related":{"32483":"close","41996":"open file","44420":"print","45683":"read"},"examples":"write \"Hello\" to file \"My Data\"\n\nwrite field 1 & return & field 2 to file \"My Data\"\nwrite someStuff to file \"My File\" at -15\n\non writeData theData\n  ask file \"Write to what text file?\" with \"Untitled\"\n  if it is empty then exit writeData\n  put it into theFileName\n  open file theFileName\n  write theData to file theFileName\n  close file theFileName\nend writeData","demo":"","debug":{"9":["write text to file f"],"10":["The -integer  option"]}}