Friday, January 25, 2013

E-Prime 2 RESP hidden characters. Bug or Gotcha?

I have just wasted some time tracking down a weird bug/feature/gotcha in E-Prime 2.

For example the code below is trying to detect a press of the space bar.

Debug.Print "Response is " & GetResponse.RESP

if GetResponse.RESP = "SPACE" then
    Debug.Print "Space bar pressed"

    Debug.Print "Something else pressed"
End if

In the debug window you can see:

Response is SPACE
Something else pressed

Why is this so? 

Because the Debug output window HIDES SOME CHARACTERS OF THE OUTPUT. 

The actual RESP text is "{SPACE}", but the Debug window silently cleans it up to "SPACE" which means that any text comparison you do based on the information you have from the Debug window will be wrong.

If you want to test this try:

Debug.Print "Length of RESP is " & Len(GetResponse.RESP)
Debug.Print "Response is " & GetResponse.RESP

You will see that the length of the string is two characters longer than the string that is output. I.e

Length of RESP is 7
Response is SPACE

Is this a bug, feature or gotcha? You decide.  Really depends how much of your valuable time you waste trying to figure it out.

How I have missed being able to set breakpoints or inspect the stack or any basic debugging tools in Eprime....

No comments:

Post a Comment