Home THE HYPERCARD CENTER

HyperTalk Reference
Home » HyperTalk Reference » Commands

Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.

write

write text to file fileName ¬
  [at { eof|end|[-]integer]}


The write command copies text to a file. You must have already opened the file with the open file command, and you should close it when writing is completed with the close file command.

The first write command after opening a file begins at the start of a file unless you use the at integer option, with integer as the character position within the file where writing is to begin.

The -integer option begins writing at integer characters from the file's end.

Warning: HyperCard does not ask if you want to write over existing text.

Subsequent write commands append text to the file’s contents after the last character written until you close the file.

Note: You must provide the full path name of the file if it’s not at the same directory level as HyperCard.


Examples

write "Hello" to file "My Data"

write field 1 & return & field 2 to file "My Data"
write someStuff to file "My File" at -15

on writeData theData
  ask file "Write to what text file?" with "Untitled"
  if it is empty then exit writeData
  put it into theFileName
  open file theFileName
  write theData to file theFileName
  close file theFileName
end writeData

Placeholders

text
An expression that evaluates to a text string.

A text expression can be a literal string surrounded by quotation marks or the value of a container.

For example:

"Hello"
"The sum is:" && 3
card field 1
line 1 of bg fld "Address"
the Message box
the selection
myVar -- a variable
See also: background, bkgnd, button, card, field, menu, menuItem, and stack

fileName
An expression that evaluates to a text string that is also a valid Macintosh filename.

For example:

"my stack"
"HD20:Wally's Stacks:my stack"
"my file alias"


integer
An expression that evaluates to a positive or negative integer or to zero. For example:

3
18 - 100
-(3 * sum(1,3,4,5)) + 39
In AppleScript, integer is a value class.

Related Topics

« wait | HyperTalk Reference


Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Modern View

Home
The HyperCard Center
HyperTalk Reference
Home » HyperTalk Reference » Commands

Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.

write

write text to file fileName ¬
  [at { eof|end|[-]integer]}


The write command copies text to a file. You must have already opened the file with the open file command, and you should close it when writing is completed with the close file command.

The first write command after opening a file begins at the start of a file unless you use the at integer option, with integer as the character position within the file where writing is to begin.

The -integer option begins writing at integer characters from the file's end.

Warning: HyperCard does not ask if you want to write over existing text.

Subsequent write commands append text to the file’s contents after the last character written until you close the file.

Note: You must provide the full path name of the file if it’s not at the same directory level as HyperCard.


Examples

write "Hello" to file "My Data"

write field 1 & return & field 2 to file "My Data"
write someStuff to file "My File" at -15

on writeData theData
  ask file "Write to what text file?" with "Untitled"
  if it is empty then exit writeData
  put it into theFileName
  open file theFileName
  write theData to file theFileName
  close file theFileName
end writeData

Placeholders

text
An expression that evaluates to a text string.

A text expression can be a literal string surrounded by quotation marks or the value of a container.

For example:

"Hello"
"The sum is:" && 3
card field 1
line 1 of bg fld "Address"
the Message box
the selection
myVar -- a variable
See also: background, bkgnd, button, card, field, menu, menuItem, and stack

fileName
An expression that evaluates to a text string that is also a valid Macintosh filename.

For example:

"my stack"
"HD20:Wally's Stacks:my stack"
"my file alias"


integer
An expression that evaluates to a positive or negative integer or to zero. For example:

3
18 - 100
-(3 * sum(1,3,4,5)) + 39
In AppleScript, integer is a value class.

Related Topics

« wait | HyperTalk Reference

Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Retro View