Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 71078, Entry date: 08/12/2002

How can you store process tags (process values) in the CSV format in a Text or ASCII file?

  • Entry
  • Associated product(s)

Use Global Script to incorporate the following script as project function and trigger it via a button, for example, or action.

void Tag_Prot()
#include <apdefap.h>
// File name for tag log
char FileName[255]="E:\\WCCPRJ30\\Project\\";

// File pointer
FILE *stream;

// Buffer for process tag
WORD Tag_1;

// Reading in of the file name by text tag "Filename_Prot"
// This name can be provided, for example, by manual input in an I/O field.
strcat(FileName, GetTagChar("Filename_Prot")); //Return type: char*

// Create/open the output file in which logging is to be done.
stream = fopen( FileName, "w" );

// Reading in the of the process tag
//Return type: WORD
Tag_1 = GetTagWord("DB80DW1");

// Test output in a Global Script diagnostics window
printf("Content file name: %s\r\n", FileName);

// Output of the tag value into a file
fprintf( stream, "Value of the tag DB80DW1, %d\r\n", Tag_1 );

//Close file
fclose( stream );


Information on how to read/write strings from/to a text file is available in FAQ 850338.

Archive, Log, fopen, fclose, fprintf

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit