Skip to main content
InSource KnowledgeCenter

Application Server script to write CSV data to a file

Overview

A simple example of writing csv (any string) data to a file to a folder path specified in the parent object.

Resolution

UDAs for this Object

DataForFile

String

ErrorMsg

String

FileWriteCsv

Boolean

Script Configuration:

Script Name:

"FileWrite"

Execute Type:

"Execute"

Expression:

"me.FileWriteCsv == 1"

Trigger Type:

"OnTrue"

Script:
me.FileWriteCsv = 0;

me.ErrorMsg = "Error message ... ";

Dim sw AS System.IO.StreamWriter;
Dim csvIASFile AS String;

csvIASFile = MyContainer.MfgFilePath + Me.Tagname + ".csv";

if (System.IO.File.Exists( csvIASFile ) == False) Then
   sw = System.IO.File.CreateText( csvIASFile );
else
   sw = System.IO.File.AppendText( csvIASFile );
endif;

sw.WriteLine(me.DataForFile);

sw.Dispose();

 

J.B.T.