Scripting in TP700 Comfort Panel

akky

Member
Join Date
Apr 2020
Location
Mumbai
Posts
29
Hey guys,
I am new to vb scripting in TIA and had a small query. I need to view certain data from HMI in excel. After running a certain script I am able to view the said data.
But i need it in such a format that my headers should occupy First row
and below that its respective data in different cells.
Instead, I am stuck with getting the data in a single cell.
Does anyone know the syntax through which i can display data in individual cells?

Any help would be highly appreciated.
 
You need to format it as perhaps a CSV file i.e. comma delimited
Header 1,Header 2
Data 1,Data 2
Data 3,Data 4
Above is a 2 column 3 row format note: at the end there needs to be a carriage return & line feed i.e.

Header 1,Header 2 (CRLF)
Data 1, Data 2 (CRLF)
Data 3, Data 4 (CRLF)
The CRLF will not be displayed as it would be non printable chars i.e. 13 10
So you need to add CHR(13) + CHR(10) to the end of each row.
Here is a CSV with a little more formatting

,,,Title
Column 1,Column 2,,
Row 1,Row 2,,
Row 3,Row 4,,
Here is the Excel picture, note: you will need to format the title etc. but if you create a template to import it into.
Note the ",,,," this is where the unused cells are for the title i.e. if you format your top row as a title wherever the title resides just put commas in to space it out.

CSV Excel.png
 
Check if the file exists.
If the file does not exist, open the file with 'for writing', write the header line, and write the 1st data line.
If the file does exist, open the file with 'for appending' and only write the 1st data line.

You probably have a code line that creates the data line with a CStr intrsuction.
You can create a line of values separeted by commas (or whichever separater character you want) like this:

datastring = CStr(smarttags("tag1")) & " , " CStr(smarttags("tag2")) & " , " CStr(smarttags("tag3")) & " , " [...]
etc.
 
Forgot to add:
Formatting in VB for the title could be My string = ",,,," + "Title" + CHR(13) + CHR(13)
The rows the same
As Jesper posted (I have never done TP scripting) just remember to add CRLF to the end of each row.
 
Last edited:
Forgot to add:
Formatting in VB for the title could be My string = ",,,," + "Title" + CHR(13) + CHR(13)
The rows the same
As Jesper posted (I have never done TP scripting) just remember to add CRLF to the end of each row.
You dont have to add a CRLF if the script is called each time a new line is to be written to the file.
Opening the file with the 'for appending' attribute will cause it to append a single text line to the file each time the script is called.
 
You need to format it as perhaps a CSV file i.e. comma delimited
Header 1,Header 2
Data 1,Data 2
Data 3,Data 4
Above is a 2 column 3 row format note: at the end there needs to be a carriage return & line feed i.e.

Header 1,Header 2 (CRLF)
Data 1, Data 2 (CRLF)
Data 3, Data 4 (CRLF)
The CRLF will not be displayed as it would be non printable chars i.e. 13 10
So you need to add CHR(13) + CHR(10) to the end of each row.
Here is a CSV with a little more formatting

,,,Title
Column 1,Column 2,,
Row 1,Row 2,,
Row 3,Row 4,,
Here is the Excel picture, note: you will need to format the title etc. but if you create a template to import it into.
Note the ",,,," this is where the unused cells are for the title i.e. if you format your top row as a title wherever the title resides just put commas in to space it out.

Thanks a ton, this solved my problem!!!
 
Hi,
So now I am facing another dilemma.
I have certain Floating type numbers that I have taken as Real.
But while displaying the values in excel, the integer part is shown in one cell (say A1) and the decimal part goes to the next cell (say A2). Any idea how can I view it in the same cell?

Eg: The value is 20.54
So the 20 is moved into A1
and 54 is in A2.
I want to show it in A1 as 20.54

Please help!!!
 
It is because the list separator and decimal character are the same, i.e. the comma.
Try to use the ";" as the list separator.
Use the ";" instead of "," in the script, and set the list separator accordingly in the Windows Control Panel .. regional settings.
 
Hi,
Ok now got one step closer. It is displaying as 20,54. Have tried all possible combinations for getting the right decimal.
Any suggestions how to move further?
 
I missed that we are talking about a comfort panel and not a PC RT.
But I dont think it changes anything.

I assume that the file is exported from the panel to a PC, and then opened with Excel on the PC.
It is the same thing that applies. You have to decide what is the list separator and make sure you use this in the VBS script as well as on the PC's regional settings.
The decimal point is the same story, that you may get differing results if comma is used on the panel and the period on the PC, or vice-versa. Also, when you change language, or user, these settings change on the PC automatically.
 
Normally when you open a csv file, it asks you how you want it done with what region language, I don't have excel on this PC & I do not have my other one handy that has excel on it, however, I did some scripting on a Beijers HMI using the comma as the separator & open office opened it perfectly. the data was not written as a float but the ASCII representation of a float i.e. 1234.56 If needed, you could create a VBA script in an excel template that on opening the file format the data as required, did this on another system for reports.
 

Similar Topics

I work for an OEM. I am trying to develop a generic HMI program that will display an overview screen displaying between 2 and 6 "widgets"...
Replies
1
Views
1,308
I need to make a navigation to 1 of 2 pages based on the value of a DINT in the PLC. I need a statement in the script that basically says when...
Replies
18
Views
6,171
Is there any way to script driver configuration instead of using the rslinx gui? It would be nice to just have scripts i can run for whatever...
Replies
2
Views
1,605
Hello all. I have a Danish program that has a lot of AOI's that were created using structured text. There are a few arguments that I am not...
Replies
3
Views
1,413
Brief: We're working on a project for a client who operates a gas field upstream of a LNG plant and needs to orchestrate some actions on its...
Replies
2
Views
1,509
Back
Top Bottom