4D Pack v15.1

_o_AP fopen

Home

 
4D Pack v15.1
_o_AP fopen

_o_AP fopen 


 

_o_AP fopen ( toOpen ; mode ) -> Function result 
Parameter Type   Description
toOpen  String in Name of the file or port to be opened
mode  Integer in Opening mode 0 = write only 1 = read only
Function result  Longint in Value to be used with AP FPRINT, or 0 if the file or port cannot be open

The _o_AP fopen command calls the fopen ANSI C command, which enables the opening of serial or parallel ports (on Windows) or the direct creation of files.

The value returned by this function is then used with the _o_AP FPRINT command to write through the port, or to write the file. The opened port or file can then be closed using the command _o_AP FCLOSE.

Note: On Mac OS, this function works only with the direct creation of files.

Writing "hello world" on the parallel port:

 port:=_o_AP fopen("LPT1";0)
 _o_AP FPRINT(port;"hello world")
 _o_AP FCLOSE(port)

Writing "hello world" on the serial port:

 port:=_o_AP fopen("COM1";0)
 _o_AP FPRINT(port;"hello world")
 _o_AP FCLOSE(port)

Writing "hello world" in a file:

 port:=_o_AP fopen("C:\MyDoc.txt";0)
 _o_AP FPRINT(port;"hello world")
 _o_AP FCLOSE(port)

Reading a file:

 port:=_o_AP fopen("C:\MyDoc.txt";1)
 MyVar:=_o_AP fread(port)
 _o_AP FCLOSE(port)



See also 

_o_AP FPRINT

 
PROPERTIES 

Product: 4D Pack
Theme: 4D_Pack : ANSI Streams
Number: 61979

This command is deprecated and should not be used anymore

 
HISTORY 

Created: 4D Pack 6
Renamed: 4D Pack v14 R5

 
ARTICLE USAGE

4D Pack ( 4D Pack v15.1)
4D Pack ( 4D Pack v15)