![]() |
||
|
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
| ||
New Here? Please read this important info!!!
|
|
#1 |
|
Member
![]() Join Date: Aug 2006
Location: Mi Casa
Posts: 1
|
Vbs code to get IP address on Siemens HMI MP277
Hello:
I have a proyect with 5 siemens MP277 screens over ethernet. The problem is that those screens have to show different datas depending of their physical location. One solution is to have 5 different proyects so each screen has to be loaded with the right one. I donīt like it because i want to have only one proyect. The idea is that this proyect has some code (visual basic script) that reads the IP address of the screen and depending of it, shows the correct data for that screen. So, anyone knot if is it posible? Any other solution? Thanks in advance PS: Sorry for my bad english O:-) |
|
|
|
#2 |
|
Member
![]() Join Date: Oct 2009
Location: Sydney
Posts: 4
|
Because I couldn't find an answer:-
vIP,vMask, vMac, vHostname are internal string variables to receive the results. Code:
' 20090518 Get the Ip Address and store it in Local Variables (From Siemens AG)
' Modified to work on Windows CE V5.0 on the MP277
Dim fso,f,temp,erg,t
Set fso = CreateObject("FileCtl.FileSystem")
Set f = CreateObject("FileCtl.File")
'writes the ipconfig in to a text file
'Help says hmiShowMinimizedAndInactive, but program only accepts hmiShowMaximizedAndInactive
'Command for WinCCflexible/CE 5.0
StartProgram "CMD", "/C ipconfig /all >\Flash\ip.txt", hmiShowMinimized, hmiNo
'wait until the output is ready
Do Until fso.Dir("\Flash\ip.txt") = "ip.txt"
Loop
'open the text file
f.open "\Flash\ip.txt",1,1 'fsModeInput,fsAccessReadWrite
Do
temp = f.LineInputString 'read out line by line
erg = InStr(temp, "IP Address ........ : ") 'wenn / if Zeile = IPAdresse
If erg Then
SmartTags("vIP") = Right(temp,Len(temp)-erg-21)
End If
erg = InStr(temp, "Subnet Mask........ : ") 'wenn / if Zeile = SubnetMask
If erg Then SmartTags("vMask") = Right(temp,Len(temp)-erg-21)
erg = InStr(temp, "Address............ : ") 'wenn / if Zeile = MAC-Adresse
If erg Then SmartTags("vMac") = Right(temp,Len(temp)-erg-21)
erg = InStr(temp, "Host name.......... : ") 'wenn / if Zeile = HostName
If erg Then SmartTags("vHostName") = Right(temp,Len(temp)-erg-21)
Loop While f.EOF = False
f.Close 'close the text file
Set f = Nothing
Set fso = Nothing
Last edited by agrade; November 6th, 2009 at 02:45 AM. Reason: Extra code removed |
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Topics
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ASCII Code in a Siemens program. | kea | LIVE PLC Questions And Answers | 14 | August 6th, 2010 05:02 AM |
| Siemens STL Code | charmer | LIVE PLC Questions And Answers | 9 | January 10th, 2008 02:09 AM |
| Reading Panelview Plus 1000 IP address from RSLogix 5000 code | Unregistered | LIVE PLC Questions And Answers | 0 | July 14th, 2005 01:12 PM |
| Siemens S5 115U Does this code have a purpose? | 2bezak | LIVE PLC Questions And Answers | 3 | June 29th, 2005 02:35 PM |
| Simulator, Simulation, Shadow Code | Terry Woods | LIVE PLC Questions And Answers | 1 | January 2nd, 2005 01:40 PM |