Forum Discussion

destruk's avatar
destruk
Streaming Star
13 years ago

Possible delay timing issue? - Roku2

I've noticed this a few times on various channel projects I've been working on.
For the roKeyboard Screen and roPinEntryDialog screen, when I call the screen and return the value to the calling function, if I don't print the returned value it sometimes fails the immediate check on the next line of code.


Function CaptureEmail() As String
screen=CreateObject("roKeyboardScreen")
port=CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetDisplayText("Enter your email address")
screen.SetMaxLength(100)
Screen.AddButton(1,"Done")
Screen.AddButton(2,"Back")
Screen.Show()
While TRUE
msg=Wait(0,port)
If Type(msg)="roKeyboardScreenEvent"
If msg.isButtonPressed()
Print"Button pressed: ";msg.GetIndex()
If msg.GetIndex()=1
entry=screen.GetText()
entry=entry.trim()
If len(entry)>0
Return lcase(entry)
End If
Else If msg.GetIndex()=2
Return "invalid"
End If
End If
End If
End While
End Function



email=CaptureEmail()
print email
If email<>"invalid"


Sample code --

Function CaptureCode() As String
screen=CreateObject("roPinEntryDialog")
port=CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetNumPinEntryFields(5)
screen.SetTitle("Enter Code")
Screen.AddButton(1,"Done")
Screen.AddButton(2,"Back")
Screen.Show()
While TRUE
msg=Wait(0,port)
If Type(msg)="roPinEntryDialogEvent"
If msg.isButtonPressed()
Print"Button pressed: ";msg.GetIndex()
If msg.GetIndex()=1
If len(screen.Pin())>0
Return screen.Pin()
End If
Else If msg.GetIndex()=2
Return "invalid"
End If
End If
End If
End While
End Function


The calling function has this

code=CaptureCode()
print code
If code<>"invalid"


Sometimes it works without printing the code, sometimes it fails without printing the code. By printing the code every time it appears to operate correctly.
I'm confused why it would do this, and printing it takes care of the issue, so I just thought it'd be good to report it here. Without printing the email after email=CaptureEmail() it just sits there when it is returned.
No RepliesBe the first to reply