[Tutor] reiterative programming

Stanfield, Vicki {D167~Indianapolis} VICKI.STANFIELD at ROCHE.COM
Mon Oct 27 10:34:27 EST 2003


I am trying to replace several calls to the same function with a loop, and for some reason I am not getting it right. The calls all read from a serial port and convert the received value like this:

	output=port.read()
            returnedval= hex(ord(output))

I want to loop through doing this until the returned value is a hex 4. I am using this:

	while returnedval != '\0x4':
                output=port.read()
                returnedval= hex(ord(output))

For some reason that I don't understand, when the returnedval is '0x4', it does the loop again and spits out an error for trying to convert a string of length 0 using the ord function. 

Do you see what I am doing wrong?

--vicki 

Best Regards,
--vicki stanfield




More information about the Tutor mailing list