December 10th, 2004, 07:39 PM
Select Case to While
Tell me if this code will work. The following code is in Visual Basic, the code I need to know if it will work is the second code.
Select Case GetWORD(Mid(Data, 5, 2))
Now I'm not sure if this code will work, I need some help with it.
while GetWORD(data[5:2]) == 0x00:
I also have one mroe very quick question. Will msg[5:5] work?
December 10th, 2004, 08:33 PM
Guessing that data is just a stream of characters then something like this perhaps is the python equivalent of your case structure:
word = data[5:7] #get a slice of 2 characters (at position 5 and 6 in the string)
if word == 'ab':
#do ab stuff
elif word == 'cb':
#do cb stuff
elif word == 'zh':
# do ...
# do whatever
even if data was actaully read from a file of binary data it will still be treated as a big string of 8-bit characters on which you can apply slicing.
You can always use the interactive shell to test things like msg[5:5]
It works but produces nothing useful - the second index is the same as the first so the slice is zero length