ACF Library

OpenOutputFile

Back to List

Description: Opens a given file and return a file-handle.

FileMaker Prototype:

Set Variable [$res; ACFU_OpenOutputFile( string_path)]

Category: BOOTSTRAP

NOTE: The bootstrap library comes preloaded in the plugin. Read more

Function source:

function OpenOutputFile ( string path ) 
   FunctionID 210; 
   int x = open ( path, "w" ); 
   return x; 
end

OpenOutputFile Opens a file for write access and returns a number reference to the open file table in the plugin. The reference can be used in subsequent write operations and then finally close the file.

This technique is more efficient than opening a file for append access for each line in a loop.

Example:

Set Variable [$fileNo ; Value: ACFU_OpenOutputFile( "~/Desktop/MyReportFile.csv" ) ]
Show All Records
Go to Record/Request/Page [ First ]

Loop
    Set Variable [$res ; Value: ACFU_WriteOutputMacFileUTF8( $fileNo; Orders::reportLineCalc & ¶ ) ]
    Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop

Set Variable [$res ; Value: ACFU_CloseFile( $fileNo ) ]

OpenOutputFile can be used with the WriteOutputMacFileUTF8, WriteOutputWinFileIso8859_1, WriteOutputWinFileUTF8 and CloseFile

Back to List