Hst2Txt

Hst2Txt is a built-in function that exports Trend historical data from InduSoft Web Studio‘s proprietary binary format to a text file.

Function Group Execution Windows Embedded Thin Client Mobile Access
Hst2Txt File Asynchronous Supported Supported Supported (see “Notes” below) Not supported

Syntax

  Hst2Txt(strStartDate,strStartTime,numDuration,numGroup,strTargetFile,optStrSeparator,optNumMilliseconds,optStrFormat,optNumInterval)  
Web Studio Help pics2ffunctions file hst2txt.xml d407370e138 Hst2Txt

strStartDate
The start date (e.g., 04/14/2002) of the data to be exported.
strStartTime
The start time (e.g., 06:30:00) of the data to be exported.
numDuration
The duration (in hours) of the data to be exported, starting from the specified start date and time.
numGroup
The trend group or worksheet number. For more information, see Trend worksheet.
strTargetFile
The name of the text file to which the data will be exported.

By default, the file must be located in your project folder (i.e., the folder that contains the file projectname.APP), on the computer that host the project runtime server. If the file is or should be located in another folder, specify the complete file path.

optStrSeparator
The character that will be used to separate the values, a.k.a. the delimiter.

This parameter is optional; if no value is specified, a TAB character (t) will be used, making the file a tab-delimited text file.

optNumMilliseconds
A numerical flag indicating whether to show millisecond-precision in the timestamp on each entry:
Value Description
0 Do not show milliseconds.
1 Show milliseconds.

This parameter is optional; if no value is specified, the default value is 0.

optStrFormat
The date format that will be used in the timestamp on each entry:
Value Description
DMY Day, Month, Year
MDY Month, Day, Year
YMD Year, Month, Day

This parameter is optional; if no value is specified, the default value is DMY.

optNumInterval
The interval between entries to be exported. Only entries at this interval are exported to the specified file. For example, if optNumInterval is 10, only every tenth entry is exported.

This parameter is optional; if no value is specified, every entry is exported.

Returned value

This function returns one of the following possible values:
Value Description
1 Error. Previous execution of the HST2TXT has not yet been completed.
0 Function executed successfully.
-1 InStudiot.dll not found in the program folder.
-2 DLL functions not found.
-3 Invalid number of parameters.

Notes

If this function is called in a project screen on a thin client, it will still write to the specified file in the project folder on the computer that hosts the project runtime server. You cannot use this function to write to a file on the thin client.

To export to a comma-separated values (CSV) file that can be easily imported into Microsoft Excel and other spreadsheet applications, specify a file name with the CSV suffix (e.g., data.csv) and a comma separator.

Examples

Export 0.1 hour (i.e., six minutes) of historical data from Trend group/worksheet 3 to a slash-delimited text file:
  Hst2Txt("04/14/2002","06:30:00",0.1,3,"data.txt","")  
Export 0.1 hour (i.e., six minutes) of historical data from Trend group/worksheet 3 to a CSV file using the MDY date format:
  Hst2Txt("04/14/2002","06:30:00",0.1,3,"data.csv",",",0,"MDY")  
Export every tenth entry in 0.1 hour (i.e., six minutes) of historical data from Trend group/worksheet 3 to a CSV file using the MDY date format:
  Hst2Txt("04/14/2002","06:30:00",0.1,3,"data.csv",",",0,"MDY",10)  

Hst2Txt