4D v13

WR SAVE DOCUMENT

Home

 
4D Write v13
WR SAVE DOCUMENT

WR SAVE DOCUMENT 


 

WR SAVE DOCUMENT ( area ; document ; type ) 
Parameter Type   Description
area  Longint in 4D Write area
document  String in Pathname of the document to be saved
in Pathname of the saved document
type  String in Type of document to be saved (4 characters)
in Type of saved document (4 characters)

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:

Constant Type Value Comment
wr 4D Write document String 4WR7 4D Write current version format document
wr 4D Write template String 4WT7 4D Write template format document
wr HTML 3 document String HTM3 HTML 3.2 format text
wr HTML 4 document String HTML HTML 4.0 format text
wr Macintosh text document String ASCM Mac OS format text
wr RTF document String RTF RTF format document
wr unicode document UTF16 String ASCU Unicode 16-byte format text
wr unicode document UTF8 String ASC8 Unicode 8-byte format text
wr Windows text document String ASCW Windows format text

Notes:

  • 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 DOC8 (Word 8 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 formatExtension
    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 formatCreatorType
    4D Write document4DW74WR7
    4D Write template4DW74WT7
    RTF4DW7RTF
    HTML 3.2 or 4MOSSTEXT
    ASCII PC/Mac4DW7TEXT
    ASCII unicode 8 or 16 bytes4DW7TEXT
    WordMSWDW8BN

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)

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

 
PROPERTIES 

Product: 4D
Theme: WR Documents
Number: 89218

The OK variable is changed by the command

 
INDEX

Alphabetical list of commands

 
HISTORY 

Modified: 4D Write v11

 
SEE ALSO 

WR OPEN DOCUMENT