VS:Append: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
m (1 revision)
 
(fix missing backslashes)
 
(One intermediate revision by one other user not shown)
Line 7: Line 7:
<desc>
<desc>
Procedure Append opens the specified file for writing and appends the data to the end of the file. Existing data in the file is NOT overwritten.
Procedure Append opens the specified file for writing and appends the data to the end of the file. Existing data in the file is NOT overwritten.


If the filename includes a fully qualified path, the path has to use the appropriate notation for the local operating system:
If the filename includes a fully qualified path, the path has to use the appropriate notation for the local operating system:
: <code>Macintosh HD:Applications:VectorWorks:Plug-Ins:Data:Notes.txt</code>
<dir>Macintosh HD:Applications:VectorWorks:Plug-Ins:Data:Notes.txt</dir>
: <code>C:\Program Files\VectorWorks\Plug-Ins\Data\Notes.txt</code>
<dir>C:Program FilesVectorWorksPlug-InsDataNotes.txt</dir>
 
 
If the filename includes a path relative to the location of the VectorWorks executable, the subfolder delimiters have to be backslashes:
If the filename includes a path relative to the location of the VectorWorks executable, the subfolder delimiters have to be backslashes:
: <code>Plug-Ins\Data\Notes.txt</code>


<dir>Plug-InsDataNotes.txt</dir>
If the filename does not include a path, the file is assumed to exist in the same folder as the VectorWorks executable.</desc>
If the filename does not include a path, the file is assumed to exist in the same folder as the VectorWorks executable.</desc>



Latest revision as of 09:49, 25 December 2017

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Procedure Append opens the specified file for writing and appends the data to the end of the file. Existing data in the file is NOT overwritten.


If the filename includes a fully qualified path, the path has to use the appropriate notation for the local operating system:

Macintosh HD:Applications:VectorWorks:Plug-Ins:Data:Notes.txt
C:\Program Files\VectorWorks\Plug-Ins\Data\Notes.txt


If the filename includes a path relative to the location of the VectorWorks executable, the subfolder delimiters have to be backslashes:

Plug-Ins\Data\Notes.txt


If the filename does not include a path, the file is assumed to exist in the same folder as the VectorWorks executable.

PROCEDURE Append(
fileName :STRING);
def vs.Append(fileName):
    return None

Parameters

fileName STRING Name of file to open for writing.

Example

VectorScript

PROCEDURE Example;
VAR
  fileName :STRING; 
  major, minor, maintenance, platform :INTEGER;
BEGIN
  GetVersion(major, minor, maintenance, platform);
  IF platform = 1 THEN BEGIN
    fileName := 'Macintosh HD:Example.txt';
  END ELSE BEGIN
    fileName := 'C:\Example.txt';
  END;
  Append(fileName);
  WriteLn('example text');
  Close(fileName);
END;
RUN(Example);


Writing binary data:

Write of ARRAY OF INTEGER with write two bytes per INTEGER. So, 10 bytes will be written for 'arr'.
This code will produce file with the following bytes(hex): 01 02 FF FE 00 00 00 00 00 00
  arr : ARRAY [1..5] OF INTEGER;
	
  FUNCTION MixBytes(b1, b2: INTEGER) : INTEGER;
  BEGIN
    MixBytes := b1 + b2 * 256;
  END;
BEGIN
  arr[1] := MixBytes( 1, 2 );
  arr[2] := MixBytes( 255, 254 );
  Write(arr);

Python

def Example():
	major, minor, maintenance, platform = vs.GetVersion()
	if platform == 1:
		fileName = 'Macintosh HD:Example.txt'
	else:
		fileName := 'D:\\Example.txt'
	vs.Append(fileName)
	vs.WriteLn('example text')
	vs.Close(fileName)
Example()

Version

Availability: from All Versions