script python error , help!!!

babido10

Member
Join Date
Nov 2017
Location
rabat
Posts
28
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
 
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).
 
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"
 

Similar Topics

Hello I wanna do script python ( if detect color ==> Set memory bit ) WriteMemory(plc,0,1,S7WLBit,True) if 'orange': (0, 140, 255)==1 this...
Replies
5
Views
2,645
code python: import snap7 from time import sleep import struct import snap7.client as c plc = snap7.client.Client() plc.connect("192.168.0.1")...
Replies
0
Views
1,527
Hi all ; if someone here can help me to convert this code to python code: public static libnodave.daveOSserialType fds; public static...
Replies
11
Views
3,725
Hello, I am learning to create shapes and VB Scripts in HMIWeb Display Builder. I wanted to change color of my rounded rectangle by script. I...
Replies
0
Views
71
Hello, I have a quick question. I have been using scripts to change the color of buttons. The reason, I am usually using multiple hmiruntime.tags...
Replies
1
Views
81
Back
Top Bottom