siemens MP277 create textfile with a script

italo2008

Member
Join Date
Feb 2009
Location
Padova
Posts
95
hi everybody


I'm trying to create a Textfile in a USB pendrive connected to SIEMENS MP277, using a script in winCCflexible 2008.

In the winCC user manual, I found this code:

Code:
  Dim fso, MyFile
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set MyFile = fso.CreateTextFile("\Storage Card USB\testfile.txt", True)
  MyFile.WriteLine("This is a test.")
  MyFile.Close

This is exactly the code I found in the user manual, I've only changed the file path, using the one I see in the control panel of the MP277 when I open the USB key in Filemanager.

Can someone explain me why I don't find any file in the USB key after pressing the button the script is associated to?
 
Your code lacks several steps.
Here is an example:
Code:
Dim f, fs, filename
 
Set f= CreateObject("filectl.file")
Set fs = CreateObject("filectl.filesystem")
 
filename="storage card2\logvalues.csv"
 
If fs.dir(filename) = "" Then 
    f.open filename, 2
    f.LinePrint "Start of new file."
    f.Close
End If
 
f.open filename, 8
    f.LinePrint "append to existing file."
f.Close
Notice that the storage location (here "storage card 2") may vary depending on which panel type and what slot.
 
debug

Add this before you MyFile line:

If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If


And, add an alarmview, check the system messages on, then you can see why the file wasn't created.

Kind regards,
Combo



hi everybody


I'm trying to create a Textfile in a USB pendrive connected to SIEMENS MP277, using a script in winCCflexible 2008.

In the winCC user manual, I found this code:

Code:
  Dim fso, MyFile
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set MyFile = fso.CreateTextFile("\Storage Card USB\testfile.txt", True)
  MyFile.WriteLine("This is a test.")
  MyFile.Close

This is exactly the code I found in the user manual, I've only changed the file path, using the one I see in the control panel of the MP277 when I open the USB key in Filemanager.

Can someone explain me why I don't find any file in the USB key after pressing the button the script is associated to?
 
Add this before you MyFile line:

If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Very good idea.

But you forgot that he has to add this line just after the "dim" line:
ON ERROR RESUME NEXT

otherwise, the script terminates and never gets to the debug code.
 

Similar Topics

Good day, May I ask, what do I need to perform MIGRATION of HMI program from Siemens MP277 10" Touch hmi to TP1200. I already have WinCC Flexible...
Replies
0
Views
171
Hi All, I currently have an damaged MP277-8" Touch panel (6AV6 643-OCB01-1AX1) which I am able to backup (.psb) via ProSave. We are in the...
Replies
1
Views
2,858
I need some clarification about uploading the HMI file from a Siemens MP277 to edit it in WinCC. Although the machine manufacturer is no longer in...
Replies
1
Views
1,361
First off, I am not a Siemens guy. I am trying to help a customer who bought an older machine with Siemens equipment in it. So far I have had no...
Replies
8
Views
3,649
I currently have 4 siemens mp277 10 inch touch screens I deal with. Lately 2 of them have been giving erratic touch screen results. To specify...
Replies
7
Views
1,795
Back
Top Bottom