version 11 (Modified)
WR SAVE DOCUMENT (area; document{; type})
Parameter | Type | Description | |
area | Longint | 4D Write area | |
document | String | Pathname of the document to be saved | |
Pathname of the saved document | |||
type | String | Type of document to be saved (4 characters) | |
Type of saved document (4 characters) |
Description
The WR SAVE DOCUMENT command saves the document located in the 4D Write area referenced by area, using the pathname passed in document.
document is the name or the complete pathname of the document file. On Windows, you must include the file extension, in order to determine the file type.
Examples:
On Windows or for crossplatform compliance, you must include the "\" character between directories: "D:\directory1\directory2\file.4W7".
On Mac OS, you must include the ":" character between folders: "MacintoshHD:Folder:Document".
If document contains only the name of the file, WR SAVE DOCUMENT will save the document in the folder of the database's structure file.
If document is an empty string, WR SAVE DOCUMENT displays the standard Save file dialog box.
When the Save (Mac OS) or OK (Windows) button of the Save file dialog box is clicked, the OK system variable is set to 1, and the document variable will be assigned the complete pathname of the file the user selects.
In this case, the type parameter returns the type selected by the user in the type drop-down list, or the document type if no type was selected by the user.
If the user clicks the Cancel button, document returns an empty string and the OK system variable is set to 0.
File formats can be selected from the Type drop-down list (on Windows) or from the type pop-up menu in the Save file dialog box.
By default, the document is saved in 4D Write format. If you want to specify a different type, you need to pass the desired file type in the type parameter. A type consists of a 4-character string. You can use one of the following constants, found in the "WR Document types" theme:
Constants (value) | Description |
wr 4D Write document (4WR7) | 4D Write current version format document |
wr 4D Write template (4WT7) | 4D Write template format document |
wr RTF document (RTF ) | RTF format document (*) |
wr Windows text document (ASCW) | Windows format text |
wr Macintosh text document (ASCM) | Mac OS format text |
wr unicode document UTF16 (ASCU) | Unicode 16-byte format text |
wr unicode document UTF8 (ASC8) | Unicode 8-byte format text |
wr HTML 3 document (HTM3) | HTML 3.2 format text (**) |
wr HTML 4 document (HTM4) | HTML 4.0 format text |
(*) Add a space after "RTF" in order to obtain the 4 characters required.
(**) You must use the HTML 3.2 export if you want to be able to display the document as HTML in 4D Write (only HTML 3 is supported for importing into 4D Write).
Compatibility note: To retain compatibility with previous versions, the DOC6 (Word 6 Document) type is also supported.
The type parameter is used for the document encoding only. It corresponds neither to a Mac OS file type, nor to a Windows extension.
However, the parameter is used by 4D Write to determine the appropriate value for the Windows file extension or the Mac OS file creator/type:
Windows
4D Write format | Extension |
4D Write document | .4W7 |
4D Write template | .4WT |
RTF | .RTF |
HTML 3.2 or 4 | .HTM |
ASCII PC/Mac | .TXT |
ASCII unicode 8 or 16 bytes | .TXT |
Word | .DOC |
The file extension is defined according to the type parameter value, even if the name already has an extension. For example, if you pass "Report.RTF" in the document parameter and "HTML" in type, the file will be named "Report.HTM".
Mac OS
4D Write format | Creator | Type |
4D Write document | 4DW7 | 4WR7 |
4D Write template | 4DW7 | 4WT7 |
RTF | 4DW7 | RTF |
HTML 3.2 or 4 | MOSS | TEXT |
ASCII PC/Mac | 4DW7 | TEXT |
ASCII unicode 8 or 16 bytes | 4DW7 | TEXT |
Word | MSWD | W8BN |
Examples
1. You want to save the document named 'LetterClient' in the 4D Write file format. This document will be saved into the "WriteDocuments" folder located at the same level as the database's structure file:
`Getting the full pathname to the database structure file $Doc:=Structure file Doc:=$Doc $long:=0 `Getting position of the last separator to remove structure name from full pathname While((Position(":";$Doc)#0) $Doc:=Substring($Doc;1+Position(":";$Doc);Length($Doc)) $Long:=Length($Doc) End while `Concatenating names to build the full pathname of the document `Adding an extension to the document allows cross-platform document management Doc:=Substring(Doc;1;Length(Doc)-$Long)+"WriteDocuments:LetterClient.4W7" WR SAVE DOCUMENT(Area;doc;wr 4D Write document)
2. You want to give the user the ability to choose both the name and type of the document to save. Then, you want to retrieve the chosen values:
DocName:="" DocType:="" WR SAVE DOCUMENT (Area;DocName;DocType) If (OK=1) ... `Using the DocName and DocType values End if
See Also