You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old November 14th, 2006, 05:25 AM   #1
perikooo
Member
Sri Lanka

perikooo is offline
 
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:-)
  Reply With Quote
Old November 6th, 2009, 02:37 AM   #2
agrade
Member
Australia

agrade is offline
 
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
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 12:18 AM.


.