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 December 5th, 2017, 11:17 AM   #1
babido10
Member
Morocco

babido10 is offline
 
Join Date: Nov 2017
Location: rabat
Posts: 28
script python error , help!!!

When I simulated the program it gives me an error

code python(part of main program):

if okLeft: #random.randrange(2):
resultLeft = "OK"
print("Result of writing MB0="+str(prosim.writeFlagValue(0, 1, True)))

else:
resultLeft = "NOK"
print("Result of writing MB0="+str(prosim.writeFlagValue(0, 1, False)))

if okRight: #random.randrange(2):
resultRight = "OK"
print("Result of writing MB0="+str(prosim.writeFlagValue(0, 2, True)))

else:
resultRight = "NOK"
print("Result of writing MB0="+str(prosim.writeFlagValue(0, 2, False)))

return resultLeft,resultRight, imagenesProcesadas

////

error:

else:
^
IdentificationError: unexpected indent

//

if u can help me to resolve this problem
  Reply With Quote
Old December 5th, 2017, 12:04 PM   #2
dmroeder
Lifetime Supporting Member
United States

dmroeder is offline
 
dmroeder's Avatar
 
Join Date: Apr 2006
Location: Vancouver, WA
Posts: 1,992
It's a little hard to tell because posting this way on the site doesn't preserve the indentation, which it very important in python.

Can you zip the python file and attach it to this thread? Or try to post it in a way that preserves the indents (maybe use the "code" tags when posting it).
  Reply With Quote
Old December 5th, 2017, 12:09 PM   #3
dmroeder
Lifetime Supporting Member
United States

dmroeder is offline
 
dmroeder's Avatar
 
Join Date: Apr 2006
Location: Vancouver, WA
Posts: 1,992
The problem could be with what follows that "else" statement. If you have no code as part of the "else", then it will give you that error because it is expecting something to be indented after it. For example, you'd get that error with something like this:

Code:
if True:
    print "stuff"
else:

print "some more stuff"
If you didn't intend on having anything to be done with the "else", simply remove it or add pass to it:

Code:
# this
if True:
    print "stuff"

# or this
if True:
    print "stuff"
else:
    pass

print "some more stuff"
  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
Reading Event codes into Wonderware Ones_Zeros LIVE PLC Questions And Answers 12 October 12th, 2017 04:59 AM
Batch script executed from InTouch doesn't generate output gardarog LIVE PLC Questions And Answers 5 May 13th, 2017 06:09 AM
Any idea how to access the Omron simulator? strantor LIVE PLC Questions And Answers 9 March 13th, 2015 06:01 PM
Wonderware Archestra Script Problem "could not resolve reference" douglasfcx LIVE PLC Questions And Answers 0 April 15th, 2014 12:59 PM
VB Script in WinCC Flexible for Data Logging erdemsvri LIVE PLC Questions And Answers 1 August 18th, 2009 03:27 PM


All times are GMT -5. The time now is 10:04 AM.


.