4D Pack v14

AP fopen

Home

 
4D Pack v14
AP fopen

AP fopen 


 

AP fopen ( ; mode ) -> Function result 
Parameter Type   Description
  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 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 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 AP FCLOSE.

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

Writing "hello world" on the parallel port:

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

Writing "hello world" on the serial port:

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

Writing "hello world" in a file:

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

Reading a file:

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

 
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

 
SEE ALSO 

AP FPRINT

 
ARTICLE USAGE

4D Pack ( 4D Pack v11.4)
4D Pack ( 4D Pack v13.2)
4D Pack ( 4D Pack v12)
4D Pack ( 4D Pack v14 R2)
4D Pack ( 4D Pack v14)
4D Pack ( 4D Pack v14 R3)
4D Pack ( 4D Pack v14 R4)