:Revision=7
:HTML
<<
128.115
File-Object|File
$NoSort
--
The IP-Object File provides methods for accessing files by reading and writing.

To enable the access to the content of the files (read and/or write access), these files must be assigned to one of the 5 data buffers. The access itself is then possible by using the buffer number. At the moment files are opened always for reading and writing access and always exclusively.

To access of the files as a whole, the file name can be used starting with Rev.2 (see below)

New in Revision2:
<ul indent=12>
<li>
<b>extended file operations:</b><br>
Rename, Copy</li>

<li>
<b>file access without number, but by file name</b><br>
File operations, which can be done without the file being open, e.g. deletion, rename, check existance, can be called now via the file name, without having the file previously assigned to a number.
The old syntax is maintained, only that in case of these operations, instead of the file number, the file name can be specified directly.

The errror codes of these operations are determined with <!RW>File.Error - without file number.

Example:
<!CODE>
//old:
File.SetFileName (1, 'Test.ini');
File.Delete (1);

//new:
File.Delete ('Test.ini');
<!TXT>
</li>
</ul>
>>

<<
128.115.1
Functions of the File-Object|Functions
--
>>
<<
128.115.1.1
File.Read|Read
--
<!DEF>
function <!TW>File.Read (rFileNr : real; sSeparator : string; rMaximum : real) : string;
<!TXT>
Reads characters from the file <!PW>rFileNr into a string until the first character is read that is present in <!PW>sSeparator; a maximum number of <!PW>rMaximum charcaters is read. The separator character is not returned.

If <!PW>rMaximum&lt;=0 the command may read up to the end of the file.

If <!PW>sSeparator='' the command will always read <!PW>rMaximum characters or until the end of the file is reached.

The file must be open.
>>
<<
128.115.1.2
File.ReadLn|ReadLn
--
<!DEF>
function <!TW>File.ReadLn (rFileNr : real) : string;
<!TXT>
Reads characters from the <!PW>rFileNr file into a string until the end of the line (CR/LF) (or the end of the file) is reached. The CR/LF characters are removed.

The file must be open.
>>
<<
128.115.1.3
File.Get|Get
--
<!DEF>
function <!TW>File.Get (rFileNr, rCount : real) : vector;
<!TXT>
Reads <!PW>rCount bytes from the file <!PW>rFileNr or until the end of the file is reached.

The file must be open.
>>
<<
128.115.1.4
File.Size|Size
--
<!DEF>
function <!TW>File.Size (rFileNr : real) : real;
<!TXT>
Returns the size of the file <!PW>rFileNr in bytes.

If the rFileNr file is not open, -1 will be returned.

<!DEF>
function <!TW>File.Size (sFileName : string) : real;
<!TXT>
Returns the size of the file <!PW>sFileName in bytes.

If the file <!PW>sFileName is not found, -1 will be returned.
>>
<<
128.115.1.5
File.Pos|Pos
--
<!DEF>
function <!TW>File.Pos (rFileNr : real) : real;
<!TXT>
Returns the current position of the file pointer for file <!PW>rFileNr.

If the file is not open, -1 will be returned.
>>
<<
128.115.1.6
File.EOF|EOF
--
<!DEF>
function <!TW>File.EOF (rFileNr : real) : real;
<!TXT>
Returns <!RW>TRUE, if the file pointer has reached the end of the file <!PW>rFileNr.

If the file is not open, <!RW>TRUE will be returned.
>>
<<
128.115.1.7
File.Exists|Exists
--
<!DEF>
function <!TW>File.Exists (rFileNr : real) : real;
<!TXT>
Returns <!RW>TRUE, if the file <!PW>rFileNr exists.

<!DEF>
function <!TW>File.Exists (sFileName : string) : real;
<!TXT>
Returns <!RW>TRUE, if the file <!PW>sFileName file exists.
>>
<<
128.115.1.8
File.Error|Error
!128.115.204 - Error codes
!128.115.5.1 - Example write file
--
<!DEF>
function <!TW>File.Error (rFileNr : real) : real;
<!TXT>
Returns the result of the last file-action for the file <!PW>rFileNr.

<!DEF>
function <!TW>File.Error : real;
<!TXT>
Returns the result of the last file-action referring to a file specified by a file name.
The code is a Windows (DOS) error code!
>>
<<
128.115.1.9
File.Extract|Extract
--
<!DEF>
function <!TW>File.Extract (sFileName : string; rWhat : real) : string;
<!TXT>
Returns a part of the (path template translated) file name. 

 <!PW>rWhat decides what:
<!STBL>
<!+>rWhat<!+>Result<!>
<!c>0<!>drive<!>
<!c>1<!>path<!>
<!c>2<!>file name<!>
<!c>3<!>file extension<!>
<!c>4<!>file name without extension<!>
<!c>5<!>everything (just translate the path template)<!>
<!ETBL>

Path templates will be translated.

Example:
<!CODE>
s:='%IPS%\TEST.IPS';      // EXE in 'D:\MCD_WIN\'
File.Extract (s, 0) -> 'D:\'
File.Extract (s, 1) -> 'D:\MCD_WIN\TYPEDATA\IPSTEPS\'
File.Extract (s, 2) -> 'TEST.IPS'
File.Extract (s, 3) -> '.IPS'
File.Extract (s, 4) -> 'TEST'
File.Extract (s, 5) -> 'D:\MCD_WIN\TYPEDATA\IPSTEPS\TEST.IPS'
<!TXT>
>>

<<
128.115.1.10
File.Execute|Execute
--
<!DEF>
function <!TW>File.Execute (sFile : string; [ sParameter : string; [ rTimeout : real; [ rShowHow : real]]]);
<!TXT>
Executes the file <!PW>sFile. <!PW>sFile should be an EXE-file. The optional command line parameters are specified in <!PW>sParameter.

 <!PW>rTimeout specifies, how long the system waits for the end of the started application.
<!STBL>
<!+>Value<!+>Result</b><!>
<!c>-1<!>forever (Default)<!>
<!c>0<!>doesn't wait at all, <!RW>File.Execute reverts immediately<!>
<!c>&gt;0<!>timeout in seconds<!>
<!ETBL>

 <!PW>rShowHow specifies the way the application should be displayed.
<!STBL>
<!+>Value<!+>Result<!>
<!c>0<!>hidden<!>
<!c>1<!>normal (Default)<!>
<!c>2<!>minimized (Icon)<!>
<!c>3<!>maximized (Fullscreen)<!>
<!ETBL>
The application must not necessarily respect this wish!

While the application is being executed, the test programm cannot process any windows messages and therefore it seems to be frozen. This is normal and it is not a program crash! If this behaviour has to be avoided, then <!RW>File.Process.Start should be used.

<!STBL>
<tr bgcolor=#f0f0f0 align=center><TD colspan=2><b>Return values</b><!>
<TR><TD colspan=2><b>Exceptional case:</b><!>
<TR><TD Align=Center width=20>0<!>The application has been started. (<!PW>rTimeout=0)<!>
<!c>-1<!>The application could not be started. Get the windows error code with <!RW>File.Error<!>
<!c>-2<!>The application has been started, but it has not been ended after the specified timeout period. So it is still running!<!>
<TR><TD colspan=2><b>Normal case:</b><br>
The return value of the application (ProcessExitCode). This can be, of course, also 0, -1 or -2.<!>
<!ETBL>
>>

<<
128.115.2
Procedures of the File-Object|Procedures
--
>>

<<
128.115.2.1
File.Write|Write
!128.115.5.1 - Example write file
---
<!DEF>
procedure <!TW>File.Write (rFileNr : real; sValue : string);
<!TXT>
Writes the value <!PW>sValue to the file <!PW>rFileNr.

The file must be open.
>>

<<
128.115.2.2
File.WriteLn|WriteLn
!128.115.5.1 - Example write file
--
<!DEF>
procedure <!TW>File.WriteLn (rFileNr : real; sValue : string);
<!TXT>
Writes the value <!PW>sValue to the file <!PW>rFileNr and adds a CR/LF.

The file must be open.
>>
<<
128.115.2.3
File.Put|Put
--
<!DEF>
procedure <!TW>File.Put (rFileNr : real; vData : vector);
<!TXT>
Writes the content of the byte-vector <!PW>vData to the file <!PW>rFileNr .

The file must be open.
>>
<<
128.115.2.4
File.Delete|Delete
!128.115.5.1 - Example write file
--
<!DEF>
procedure <!TW>File.Delete (rFileNr : real);
<!TXT>
Deletes the file <!PW>rFileNr. If the file was open, it will be closed.

<!DEF>
procedure <!TW>File.Delete (sFileName : string);
<!TXT>
Deletes the file <!PW>sFileName. <!SW>must be specified with the complete path; path templates are allowed.
>>
<<
128.115.2.5
File.Seek|Seek
--
<!DEF>
procedure <!TW>File.Seek (rFileNr, rPosition : real);
<!TXT>
Sets the file pointer for input-/output- operations in the file <!PW>rFileNr to the position <!PW>rPosition - number of bytes from start of file.

The file must be open.
>>
<<
128.115.2.6
File.SetFileName|SetFileName
!128.115.5.1 - Example write file
--
<!DEF>
procedure <!TW>File.SetFileName (rFileNr : real; sFileName : string);
<!TXT>
Assignes the file <!PW>rFileNr to the file name <!PW>sFileName.

The file must not be open.
>>
<<
128.115.2.7
File.Open|Open
!128.115.5.1 - Example write file
--
<!DEF>
procedure <!TW>File.Open (rFileNr : real);
<!TXT>
Opens the file <!PW>rFileNr. If the file does not exist, it will be created.

The file must not be open yet.
>>
<<
128.115.2.8
File.Close|Close
!128.115.5.1 - Example write file
--
<!DEF>
procedure <!TW>File.Close (rFileNr);
<!TXT>
Closes the file <!PW>rFileNr. If the file is already closed, the call will be ignored.
>>
<<
128.115.2.9
File.Move|Move
--
<!DEF>
procedure <!TW>File.Move (sOld, sNew : string; [ rDoReplace : real]);
<!TXT>
Renames the file or the directory <!PW>sOld with <!PW>sNew. The file resp. the directory <!PW>sOld must exist. For <!PW>sOld and <!PW>sNew, the entire paths must be specified; path templates are allowed.

The target of a file may be on a different drive.
The target for a directory must be on the same dive.

If <!PW>rDoReplace is <!RW>TRUE (default is <!RW>FALSE), then an already existing target file will be overwritten with the name <!PW>sNew.
This is not possible for directories.

(Attention: different default value from <!RW>File.Copy!)
>>
<<
128.115.2.10
File.Copy|Copy
--
<!DEF>
procedure <!TW>File.Copy (sOld, sNew : string; [ rDoReplace : real]);
<!TXT>
Copies the file <!PW>sOld to <!PW>sNew. The file <!PW>sOld must exist. For <!PW>sOld and <!PW>sNew the entire paths must be specified; path templates are allowed.

If <!PW>rDoReplace is <!RW>FALSE (default is <!RW>TRUE), then a already existing target file will not be overwritten with the name <!PW>sNew.

(Attention: different default value from <!RW>File.Move!)
>>

<<
128.115.3
File.List|List
--
The List-Sub-object enables the search of files in a directory.

The search is started with <!RW>File.List.Find and continued with <!RW>File.List.Next.

The found files can be analysed with other <!RW>File.List-Functions.
It is not possible to embed one search into another.

Example:
Lists all *.BAK files in the IP-Step directory:
<!CODE>
var
  rFile : real;
step
  rFile := File.List.Find ('%IPS%\*.BAK', 0);
  while (rFile=0) do begin
    Debug.Show (1, str(File.List.Size,6,0,'0'), File.List.Name);
    rFile:=File.List.next;
  end;
  File.List.Close;
end.
<!TXT>
>>
<<
128.115.3.1
File.List.Find|Find
!128.115.3.6 - Attributes
!128.115.3.2
--
<!DEF>
function <!TW>File.List.Find (sPathAndMask : string; rAttribute : real) : real;
<!TXT>
 <!PW>sPathAndMask indicates a file path and a file mask which is used to search for the first matching file. The path can contain a file template. The mask may contain Wildcards (*, ?).

 <!PW>rAttribute specifies special attributes which the searched file <b>may</b>, not necessarily <b>must</b> have!

When a file is found, the return value is 0, otherwise an error code is returned.

The values in <!PW>rAttribute can be:
<!STBL>
<!+>Value<!+>Description<!>
<!c>1<!>Write-protected files<!>
<!c>2<!>Hidden files<!>
<!c>4<!>System files<!>
<!c>8<!>Drive identifiers<!>
<!c>16<!>Directories<!>
<!c>32<!>Archive files<!>
<!ETBL>
The flag values can be added.

Archive files and write-protected files are part of the search result without any special requests.
So really effective values, i.e. the ones extending the search result, are therefore only 2, 4, 8 and 16.

If another search has been previously started without being ended with <!RW>Find.List.Close, then a <!RW>Find.List.Close is carried out implicitly!

Example:
<!CODE>
File.List.Find ('%IPS%\*.BAK', 0);
<!TXT>
- finds all the normal *.BAK files in the IPStep directory

<!CODE>
File.List.Find ('%IPS%\*.BAK', 2);
<!TXT>
- as above, but including hidden files

<!CODE>
File.List.Find ('%IPS%\*.*', 16);
<!TXT>
- finds all the directories, but also all the other files!
- for info about other filters see <!RW>File.List.Attribute

Example in <a href="128.115.3">File.List</a>
>>
<<
128.115.3.2
File.List.Next|Next
!128.115.3.1
--
<!DEF>
function <!TW>File.List.Next : real;
<!TXT>
Continues the last search which has been started before with <!RW>File.List.Find. The path, the filemask and the attributes are still valid.

If another file is found, the return value is 0, otherwise an error code is returned.

Example in <a href="128.115.3">File.List</a>

>>
<<
128.115.3.3
File.List.Close|Close
--
<!DEF>
procedure <!TW>File.List.Close;
<!TXT>
Terminates the search initiated with <!RW>File.List.Find.

After the end of the test and in case of a reset, the <!RW>File.List.Close is called automatically.

The search is also automatically closed in case of a <!RW>File.List.Find or <!RW>File.List.Next with a negative result (i.e. no file is found).

After a <!RW>File.List.Close the result of an access to the file data (e.g. <!RW>File.List.Name) is not defined.
>>
<<
128.115.3.4
File.List.Name|Name
--
<!DEF>
function <!TW>File.List.Name : string;
<!TXT>
Returns the file name of the last file found with <!RW>Find.List.Find or <!RW>Find.List.Next.

Valid only if a file has been found previously.
>>
<<
128.115.3.5
File.List.Path|Path
--
<!DEF>
function <!TW>File.List.Path : string;
<!TXT>
Returns the file path of the last file found with <!RW>Find.List.Find or <!RW>Find.List.Next.

Valid only if a file has been found previously.
>>
<<
128.115.3.6
File.List.Attributes|Attributes
!128.115.3.1 - Find
--
<!DEF>
function <!TW>File.List.Attributes : real;
<!TXT>
Returns the file attributes of the last file found with <!RW>Find.List.Find or <!RW>Find.List.Next.
The value is a combination of the values listed by <!RW>File.List.Find.

Valid only if a file has been found previously.

Example: Search for all directories:
<!CODE>
var
  rFile : real;
step
  rFile := File.List.Find ('%IPS%\*.BAK', 16);
  // Attention mask 16 means: WITH directories
  // it does NOT mean       : only directories

  while (rFile=0) do begin
    // a file or a directory can now be found!
    // filter for the attributes-value
    if (File.List.Attributes & 16)>0 then begin
      // in each directory there are two pseudo-directories:
      // '.' - the current directory
      // '..' - the higher-level directory
      // do not use these two
      if (File.List.Name<>'.') and (File.List.Name<>'..') then begin
        Debug.Show (1, File.List.Name);
        // or do something else with it
      end;
    end;
    rFile:=File.List.next;
  end;
  File.List.Close;
end.
<!TXT>
>>
<<
128.115.3.7
File.List.Size|Size
--
<!DEF>
function <!TW>File.List.Size : real;
<!TXT>
Returns the size of the last file found with <!RW>Find.List.Find or <!RW>Find.List.Next.

Valid only if a file has been found previously.
>>
<<
128.115.4
File.Process|Process
--
The File.Process commands can start an external programm.
<!RW>File.Process is in fact a little bit more difficult to use than <!RW>File.Execute, but while the external programm is running, the interpreter will still get computing time an continue it's operation.

Application example:
<!CODE>
var
  rTimeout,
  rFinished,
  rTimedOut,
  rPID : real;

step
  rPID:=File.Process.Start ('Programmer.exe /COM=1 /File=Atmel.bin');
  if rPID<>0 then begin
    rTimeout:=DateTime.ReadTimer+120*1000;      // 120 Seconds run time max
    repeat
      rTimedOut:=DateTime.ReadTimer>rTimeout;
      rFinished:=File.Process.WaitFor (rPID, 500);      // wait 500ms for the end
    until rTimedOut or rFinished or SingleStepContinue;
    if File.Process.IsActive then begin
      File.Process.Kill (rPID);
      // Error process is not ready
    end
    else begin
      SetValue (File.Process.GetValue (rPID));  // get result
      File.Process.Release (rPID);              // ID release
  end
  else begin
    // Error - Start not possible
  end;
end.
<!TXT>
>>
<<
128.115.4.1
File.Process.Start|Process.Start
--
<!DEF>
function <!TW>File.Process.Start (sFile : string; [sPara : string; [rShowHow : real; [sWorkDir : string]]) : real;
<!TXT>
Starts the file <!PW>sFile. <!PW>sFile should be an EXE-file. The optional command line parameters are specified in <!PW>sPara.

 <!PW>rShowHow determines the way the application should be displayed.
<!STBL>
<!+>Value<!+><b>Meaning<!>
<!c>0<!>hidden<!>
<!c>1<!>normal (default)<!>
<!c>2<!>minimized (icon)<!>
<!c>3<!>maximized (fullscreen)<!>
<!ETBL>
The application must not necessarily respect this wish!

 <!PW>sWorkDir selects the working directory for the process.

Return values:
<!STBL>
<!>successful:<!>the processID of the application. The processID will be later necessary for the status enquiry. Therefore it should be stored in a variable<!>
<!><b>un</b>successful:<!>0, enquiry of the Windows-error code with <!RW>File.Error<!>
<!ETBL>
>>
<<
128.115.4.2
File.Process.IsActive|Process.IsActive
--
<!DEF>
function <!TW>File.Process.IsActive (rPID : real) : real;
<!TXT>
Returns <!RW>true, if the application with the processID <!PW>rPID is still running . 
Only processes which were started via <!RW>File.Process.Start can be enquired.

<!STBL>
<tr bgcolor=#f0f0f0 align=center><TD colspan=3><b>Return value</b><!>
<!><!RW>false</TD><TD colspan=2>the process was established and is now ended<!>
<TR><TD rowspan=4><!RW>true</TD><TD colspan=2>the ID is either unknbown or the process is still active<br>Differentiation with<!RW>File.Error:<!>
<!><!RW>File.Error =-1<!>Process ID is unknown<!>
<!><!RW>File.Error = 0<!>Process is still active<!>
<!><!RW>File.Error &gt; 0<!>Windows error code<!>
<!ETBL>

The call 
<!CODE>
File.Process.IsActive (rPID)
<!TXT>
is equivalent to 
<!CODE>
not File.Process.WaitFor (rPID, 0)
<!TXT>
>>
<<
128.115.4.3
File.Process.WaitFor|Process.WaitFor
--
<!DEF>
function <!TW>File.Process.WaitFor (rPID, rWaitTime : real) : real;
<!TXT>
Waites maximum <!PW>rWaitTime milliseconds, until the application with the process ID <!PW>rPID is ended. Only those processes can be enquired which were started with <!RW>File.Process.Start.
This is a passive wait, i.e. without processor load.

<!STBL>
<tr bgcolor=#f0f0f0 align=center><TD colspan=3><b>Return value</b><!>
<!><!RW>true</TD><TD colspan=2>the process was established and is now ended<!>
<TR><TD rowspan=4><!RW>false</TD><TD colspan=2>the ID is either unknown or the process is still active<br>Differentiation with<!RW>File.Error:<!>
<!><!RW>File.Error =-1<!>Process ID is unknown<!>
<!><!RW>File.Error = 0<!>Process is still active<!>
<!><!RW>File.Error &gt; 0<!>Windows error code<!>
<!ETBL>

The call 
<!CODE>
File.Process.WaitFor (rPID, 0)
<!TXT>
is equivalent to 
<!CODE>
not File.Process.IsActive (rPID)
<!TXT>
>>
<<
128.115.4.4
File.Process.Release|Process.Release
--
<!DEF>
procedure <!TW>File.Process.Release (rPID : real);
<!TXT>
Returns to Windows the processID-handle for the process <!PW>rPID. This does not influence the status of the application itself! Afterwards, the process is no longer known and can no longer be enquired. If a process is ended, or no more information is required, then <!RW>File.Process.Release MUST be called under all circumstances with the process ID.
A call which is made with an unknown <!PW>rPID has no effect.

<!CODE>
File.Process.Release (0);
<!TXT>
Releases all the process handles which are known by the programm.
Can be used e.g. in an end step or in the leave resp. reset step.
>>
<<
128.115.4.5
File.Process.Kill|Process.Kill
--
<!DEF>
function <!TW>File.Process.Kill (rPID : real) : real;
<!TXT>
Terminates the application with the processID <!PW>rPID by force. It should be applied only in seriously exceptional cases, since resources can be blocked. It is not necessary to call <!RW>File.Process.Release with the <!PW>rPID. If the <!PW>rPID is not known, the call has no effect.

Returns:
 <!RW>TRUE, if the application could be ended.

<!CODE>
rKilledAll:=File.Process.Kill (0);
<!TXT>
Ends all the applications started with <!RW>File.Process.Start.
Can be used e.g. in an end step or in the leave resp. reset step.

Returns:
 <!RW>TRUE, if all the application could be ended.
>>
<<
128.115.4.6
File.Process.GetValue|Process.GetValue
--
<!DEF>
function <!TW>File.Process.GetValue (rPID : real) : real;
<!TXT>
Returns the return code left behind by the programm (error code).

Return value:
<!STBL>
<!+>Value<!+>Meaning<!>
<!c>-1<!><!RW>rPID is unknown<!>
<!c>-2<!>Error code could not be retrieved. (Check with <!RW>File.Error)<!>
<!c>else<!>the return code of the programm (could be -1 or -2 too, of course)<!>
<!ETBL>
>>
<<
128.115.3.8
File.List.Time|Time
--
<!DEF>
function <!TW>File.List.Time : real;
<!TXT>
Returns the time of the last write access to the last file found with <!RW>Find.List.Find or <!RW>Find.List.Next.

Standard format according to ISO8601, without specification of the time zone:
<pre>
'2002-10-14T17.45.56' = 
         14. October 2002, 17 hours, 45 minutes 56 seconds 
</pre>
The capital T is the separator between the date and the time.
The specified time is the time returned by the operation system. Special attention should be payed to the fact that FAT does the saving only with a precision of 2 seconds and Windos NT / 2000 returns the time based on UTC while Windows 95/98 returns the time as local time.

Only valid if a file has been found previously.
>>
<<
128.115.204
Error Codes
--
<h3>Error codes for the work with file buffers (access by numbers)</h3>
<!STBL>
<!+>Value<!+>Meaning<!>
<!c>0<!>no error, everything ok<!>
<!c>1<!>the file was not open<!>
<!c>2<!>the file was open<!>
<!c>3<!>no name was assigned<!>
<!c>4<!>the file could not be opened<!>
<!c>5<!>the file could not be deleted<!>
<!c>6<!>invalid position in the file<!>
<!c>7<!>general stream-error<!>
<!ETBL>

<h3>Error codes for the work with file names (direct access)</h3>
(The error codes correspond to the Windows error codes)
<!STBL>
<!+>Value<!+>Meaning<!>
<!c>0<!>SUCCESS<!>
<!c>1<!>ERROR_INVALID_FUNCTION<!>
<!c>2<!>ERROR_FILE_NOT_FOUND<!>
<!c>3<!>ERROR_PATH_NOT_FOUND<!>
<!c>4<!>ERROR_TOO_MANY_OPEN_FILES<!>
<!c>5<!>ERROR_ACCESS_DENIED<!>
<!c>6<!>ERROR_INVALID_HANDLE<!>
<!c>8<!>ERROR_NOT_ENOUGH_MEMORY<!>
<!c>9<!>ERROR_INVALID_BLOCK<!>
<!c>10<!>ERROR_BAD_ENVIRONMENT<!>
<!c>11<!>ERROR_BAD_FORMAT<!>
<!c>12<!>ERROR_INVALID_ACCESS<!>
<!c>13<!>ERROR_INVALID_DATA<!>
<!c>14<!>ERROR_OUTOFMEMORY<!>
<!c>15<!>ERROR_INVALID_DRIVE<!>
<!c>16<!>ERROR_CURRENT_DIRECTORY<!>
<!c>17<!>ERROR_NOT_SAME_DEVICE<!>
<!c>18<!>ERROR_NO_MORE_FILES<!>
<!c>19<!>ERROR_WRITE_PROTECT<!>
<!c>20<!>ERROR_BAD_UNIT<!>
<!c>21<!>ERROR_NOT_READY<!>
<!c>22<!>ERROR_BAD_COMMAND<!>
<!c>23<!>ERROR_CRC<!>
<!c>24<!>ERROR_BAD_LENGTH<!>
<!c>25<!>ERROR_SEEK<!>
<!c>26<!>ERROR_NOT_DOS_DISK<!>
<!c>27<!>ERROR_SECTOR_NOT_FOUND<!>
<!c>28<!>ERROR_OUT_OF_PAPER<!>
<!c>29<!>ERROR_WRITE_FAULT<!>
<!c>30<!>ERROR_READ_FAULT<!>
<!c>31<!>ERROR_GEN_FAILURE<!>
<!c>32<!>ERROR_SHARING_VIOLATION<!>
<!c>33<!>ERROR_LOCK_VIOLATION<!>
<!c>34<!>ERROR_WRONG_DISK<!>
<!c>36<!>ERROR_SHARING_BUFFER_EXCEEDED<!>
<!c>38<!>ERROR_HANDLE_EOF<!>
<!c>39<!>ERROR_HANDLE_DISK_FULL<!>
<!c>50<!>ERROR_NOT_SUPPORTED<!>
<!c>52<!>ERROR_DUP_NAME<!>
<!c>53<!>ERROR_BAD_NETPATH<!>
<!c>54<!>ERROR_NETWORK_BUSY<!>
<!c>55<!>ERROR_DEV_NOT_EXIST<!>
<!c>56<!>ERROR_TOO_MANY_CMDS<!>
<!c>80<!>ERROR_FILE_EXISTS<!>
<!c>107<!>ERROR_DISK_CHANGE<!>
<!c>108<!>ERROR_DRIVE_LOCKED<!>
<!c>110<!>ERROR_OPEN_FAILED<!>
<!c>111<!>ERROR_BUFFER_OVERFLOW<!>
<!c>112<!>ERROR_DISK_FULL<!>
<!c>113<!>ERROR_NO_MORE_SEARCH_HANDLES<!>
<!c>117<!>ERROR_INVALID_CATEGORY<!>
<!c>123<!>ERRROR_INVALID_NAME<!>
<!c>183<!>ERROR_ALREADY_EXISTS<!>
<!c>191<!>ERROR_INVALID_EXE_SIGNATURE<!>
<!c>192<!>ERROR_EXE_MARKED_INVALID<!>
<!c>193<!>ERROR_BAD_EXE_FORMAT<!>
<!ETBL>
>>


<<
128.115.205
Path templates
--
This are the defined path templates:
<!STBL>
<!+>Value<!+>Meaning<!>
<!> <!CW>%TYP%\ <!>current type data directory (of the current type)<!>
<!> <!CW>%LOG%\ <!>directory with the logbooks<!>
<!> <!CW>%TDR%\ <!>type data directory (with the type list)<!>
<!> <!CW>%PRG%\ <!>path of the program EXE<!>
<!> <!CW>%SYS%\ <!>Programm Setup-Data<!>
<!> <!CW>%IPS%\ <!>Interpreter steps<!>
<!> <!CW>%LNG%\ <!>current language<!>
<!ETBL>

The path templates are working only if they are used exactly as specified above, at the beginning of a file name!

The list of path templates may be expanded in the future.
>>

<<
128.115.5
Examples with IP object File|Examples
--
>>

<<
128.115.5.1
Example write file| Write file
!128.115.2.6 - Procedure SetFileName
!128.115.2.4 - Procedure Delete
!128.115.2.7 - Procedure Open
!128.115.2.2 - Procedure WriteLn
!128.115.2.1 - Procedure Write
!128.115.2.8 - Procedure Close
!128.115.1.8 - Function Error
--

The following example shows how to delete a file if it exist and create a new file, insert
some lines and a string (without ne line char).

If a error occurs this example returns the error code and show the error in the debugging display.

<!TXT>

Beispiel:
<!CODE>
var
  vrLines        : real;     // Contains the count of lines, which should be written.
  vrLine         : real;     // Contains the number of the actual line.
  vrErrorCode    : real;     // Contains the error code of the last IP File object call.
  vrLastOperaion : string;   // Contains the name of the last IP File object call.
Step
  vrLines := 7;   // Set the count of lines, which should be written.
  vrLine  := 1;   // Initialize the value to line 1.
  // Set the file name of the file, which should be written and set a ID for the file.
  File.SetFileName( 1, '%PRG%\IPHelpExample.txt' );
  // Delete the file with the ID 1, if the file doesn't exist the function do nothing.
  File.Delete(1);
  vrLastOperaion := 'File.Delete';  // Set the name of the last File object call.
  vrErrorCode := File.Error;        // Reads the Error code of the last File object call.
  // Shows the result of the last IP File object call.
  Debug.SHOW(1, 'Executed: ', vrLastOperaion, ' ErrorCode: ', vrErrorCode);
  // if Errorcode = 0 (no error) the content of the if statement would be executed.
  if vrErrorCode = 0 then
  begin
    // Open the file with the ID 1, if the file doesn't exist the file would be created.
    File.Open(1);
    vrLastOperaion := 'File.Open';  // Set the name of the last File object call.
    vrErrorCode := File.Error;      // Reads the Error code of the last File object call.
    // Shows the result of the last IP File object call.
    Debug.SHOW(1, 'Executed: ', vrLastOperaion, ' ErrorCode: ', vrErrorCode);
    // if Errorcode = 0 (no error) the content of the if statement would be executed.
    if vrErrorCode = 0 then
    begin
      // The while loop would be executed until all lines are written or an error occures.
      while ((vrLines >= vrLine) and (vrErrorCode = 0)) do
      begin
        Inc(vrLine);  // Increment the line counter
        // Writes a line into the file with the ID 1.
        File.WriteLn(1,'This is line ' + Str(vrLine) + '.' );
        vrLastOperaion := 'File.WriteLn';  // Set the name of the last File object call.
        vrErrorCode := File.Error;         // Reads the Error code of the last File object call.
        // Shows the result of the last IP File object call.
        Debug.SHOW(1, 'Executed: ', vrLastOperaion, ' ErrorCode: ', vrErrorCode);
      end;
      // if Errorcode = 0 (no error) the content of the if statement would be executed.
      if vrErrorCode = 0 then
      begin
        // Writes a string into the file with the ID 1.
        File.Write(1,'This line is without a new line.' );
        vrLastOperaion := 'File.WriteLn';  // Set the name of the last File object call.
        vrErrorCode := File.Error;         // Reads the Error code of the last File object call.
        // Shows the result of the last IP File object call.
        Debug.SHOW(1, 'Executed: ', vrLastOperaion, ' ErrorCode: ', vrErrorCode);
        // if Errorcode = 0 (no error) the content of the if statement would be executed.
        if vrErrorCode = 0 then
        begin
          // Closed the file with the ID 1.
          File.Close(1);
          vrLastOperaion := 'File.Close';  // Set the name of the last File object call.
          vrErrorCode := File.Error;       // Reads the Error code of the last File object call.
          // Shows the result of the last IP File object call.
          Debug.SHOW(1, 'Executed: ', vrLastOperaion, ' ErrorCode: ', vrErrorCode);
        end;
      end;
    end;
  end;
  // Returns the error code of the last IP File object call.
  System.SetValue(vrErrorCode, vrLastOperaion);
end.
<!TXT>

>>