PDA

View Full Version : An Interesting Situation



gungadout
26-11-2010, 10:53
Hi Folks,

I have long held that dogs and computers look upon me with malevolence.



Dim GetReply As Long ' a global definition
.
.
.
CallBack Function cbDialogScreen()

GetReply = 0
.
.
.
Select Case ButtonText
Case "Exit"
.
.
.
Case "File"
.
.
.
Case "Delete"
.
.
.
Case Else
.
.
.
GetReply = 1
Control Set Text hDlgCurrentScreen, lblStatusLine, "Sending ButtonResponse = <" + ButtonResponse + "> GetReply = <" + GetReply + ">"
Sleep 3000
SendResult = TCP_Send(TCPFreeFile, "@(BR@" + ButtonResponse + "@BR)@" + $CR)
Control Set Text hDlgCurrentScreen, lblStatusLine, "After sending ButtonResponse = <" + ButtonResponse + "> GetReply = <" + Getreply + ">"
Sleep 3000

End Select

The first Control Set Text displays "Sending ButtonResponse = <Display> GetReply = <1>".

The second Control Set Text displays "After sending ButtonResponse = <Display> GetReply = <0>".

I could find no reference to GetReply in the online help. (I checked in case I was somehow misusing a dedicated variable.)

I'm using version 1.8.0.0.

Have I stumbled across a known problem (unknown to me)?

Regards,

Peter H.

danbaron
28-11-2010, 08:48
I know absolutely nothing about user interfaces, and, I don't want to know anything. I guess I am closed-minded.

But, dogs like me, and, I like dogs. Cats too. However, I don't think that computers like anyone.

Tan me hide when I'm dead, Fred
Tan me hide when I'm dead
So we tanned his hide when he died, Clyde
And that's it hanging on the shed

All together now
Tie me kangaroo down, sport
Tie me kangaroo down
Tie me kangaroo down, sport
Tie me kangaroo down..

:p
Dan

gungadout
29-11-2010, 02:11
Hi Folks,

I'm sure this must be reproducible, under the right conditions.

The setting is as shown before, in a Callback Function.


Dim GetReply As Long
Dim GetReplyB As Long
Dim GetReplyC As String
Dim GetReplyD As Long
.
.
.
Console_ShowWindow(%CONSOLE_SW_SHOW)
Console_WriteLine "Starting Console Display"
Console_WriteLine ""

GetReply = 1
GetReplyB = 1
GetReplyC = "Y"
GetReplyD = 0
Console_WriteLine "Sending ButtonResponse #1 = <" + ButtonResponse + "> GetReply = <" + GetReply + "><" + GetReplyB + "><" + GetReplyC + "><" + GetReplyD + ">"

Control Set Text hDlgCurrentScreen, lblStatusLine, "Sending ButtonResponse = <" + ButtonResponse + "> GetReply = <" + GetReply + "><" + GetReplyB + "><" + GetReplyC + "><" + GetReplyD + ">"
Sleep 3000

GetReplyD = 1

Console_WriteLine "Sending ButtonResponse #2 = <" + ButtonResponse + "> GetReply = <" + GetReply + "><" + GetReplyB + "><" + GetReplyC + "><" + GetReplyD + ">"

Control Set Text hDlgCurrentScreen, lblStatusLine, "After sending ButtonResponse = <" + ButtonResponse + "> GetReply = <" + GetReply + "><" + GetReplyB + "><" + GetReplyC + "><" + GetReplyD + ">"
Sleep 3000
Console_WriteLine "After sending ButtonResponse = <" + ButtonResponse + "> GetReply = <" + GetReply + "><" + GetReplyB + "><" + GetReplyC + "><" + GetReplyD + ">"

End Select

Control Set Text hDlgCurrentScreen, lblStatusLine, "Before test of GetReply = 1. GetReply = <" + GetReply + "><" + GetReplyB + "><" + GetReplyC + "><" + GetReplyD + ">"
Sleep 3000
Console_WriteLine "Before test of GetReply = 1. GetReply = <" + GetReply + "><" + GetReplyB + "><" + GetReplyC + "><" + GetReplyD + ">"

If GetReply = 1 Then
.
.
.
End If

Control Set Text hDlgCurrentScreen, lblStatusLine, "After test of GetReply = 1. GetReply = <" + Getreply + "><" + GetReplyB + "><" + GetReplyC + "><" + GetReplyD + ">"
Sleep 3000
Console_WriteLine "After test of GetReply = 1. GetReply = <" + Getreply + "><" + GetReplyB + "><" + GetReplyC + "><" + GetReplyD + ">"

The console display is attached.

I started checking with the Control Set Text status displays (and now the console displays so you can see the result straight from the horse's mouth) because the "If GetReply = 1" Then statement was always failing, even though I knew that that was impossible.

As you can see, the values in the variables are being modified in some way by thinBasic without my help. In the code above, it would seem that the Control Set Text statements are causing the problem, but the problem was initially occurring before I put them in.


GetReply = 1

End Select

If GetReply = 1 Then

There seems to be some combination of source code that is getting the interpreter mixed up . Maybe assumptions are being made about how the structure of source logic within a Callback Function will always be presented.

Just in case, I have included the logic hierarchy as it is so far.


CallBack Function cbDialogScreen()
Select Case Callback_Message ' Callback_Message = CBMSG
Case %WM_INITDIALOG
Case %WM_COMMAND ' PEH this checks if it is an ordinary command, like a button press.
If FieldType = "B" Then ' was a button clicked?
If CBCTLMSG = %EN_SETFOCUS Then
End If
Select Case ButtonText
Case "Exit"
Case "File"
Case "Delete"
Case Else
' GetReply etc. are evaluated in here
End Select
If GetReply = 1 Then
End If
End If
If FieldType = "T" Then ' was a text field accessed?
Select Case CBCTLMSG ' = ScreenFieldMessage - holds status feedback about the field
Case %EN_SETFOCUS 'control has just received focus
End Select
End If
Case %WM_CLOSE
End Select
End Function

What do people reckon?

Dan, Good quote. Something is wobbly. (For those who do not have the background, Rolf Harris, the singer of the song, used a wobble board [a broad, thin sheet of wood] to make sound effects.) I've been in the IT industry a long time and done most things, including assembly-level programming. I seem to have a proclivity for probing limits and testing things to destruction. I guess you could say, "I've been everywhere, man." (Another Australian song, for Dan.)

Regards,

Peter H.

danbaron
29-11-2010, 02:50
(When I'm worried about the reliability of a particular thing, I have a tendency to stress test it until it breaks. It doesn't seem to make sense, does it? On the other hand, how can I determine how close a thing is to breaking, if, I don't break it? And, once I break it, the suspense is over, so, I no longer have to worry. (People are strange, yes?) :p)

Who can it be knocking at my door?
Go 'way, don't come 'round here no more.
Can't you see that it's late at night?
I'm very tired, and I'm not feeling right.
All I wish is to be alone;
Stay away, don't you invade my home.
Best off if you hang outside,
Don't come in - I'll only run and hide.

Who can it be now?
Who can it be now?
Who can it be now?
Who can it be now?

Who can it be knocking at my door?
Make no sound, tip-toe across the floor.
If he hears, he'll knock all day,
I'll be trapped, and here I'll have to stay.
I've done no harm, I keep to myself;
There's nothing wrong with my state of mental health.
I like it here with my childhood friend;
Here they come, those feelings again!

Who can it be now?
Who can it be now?
Who can it be now?
Who can it be now?

Is it the man come to take me away?
Why do they follow me?
It's not the future that I can see,
It's just my fantasy

Who can it be now?
Who can it be now?
Who can it be now?
Who can it be now?

Oh...Who can it be now?
Oh...Who can it...Who can it...
Oh...Who can it be now?
Oh...yeah yeah yeah....

gungadout
29-11-2010, 07:58
Hi Folks,

I've found I was using "If CBCTLMSG = %EN_SETFOCUS" instead of "If CBCTLMSG = %BN_SETFOCUS" when processing button responses.

I'll see what difference that makes.

Regards,

Peter H. (Gungadout)

Michael Clease
29-11-2010, 23:52
This might help


' Edit Control Notification Codes
%EN_SETFOCUS = &H100
%EN_KILLFOCUS = &H200
%EN_CHANGE = &H300
%EN_UPDATE = &H400
%EN_ERRSPACE = &H500
%EN_MAXTEXT = &H501
%EN_HSCROLL = &H601
%EN_VSCROLL = &H602


' User Button Notification Codes
%BN_CLICKED = 0
%BN_PAINT = 1
%BN_HILITE = 2
%BN_UNHILITE = 3
%BN_DISABLE = 4
%BN_DOUBLECLICKED = 5
%BN_SETFOCUS = 6
%BN_KILLFOCUS = 7
%BN_DBLCLK = %BN_DOUBLECLICKED

gungadout
30-11-2010, 05:03
Thanks, Michael.

That is a handy list. I have saved it in a text document for easy reference.

I have discovered what was causing the automatic GetReply etc. re-initialization problem. (But I still don't understand why.)

I had some redundant (but I thought harmless) code at the start of the Callback Function.


CallBack Function cbDialogScreen()

ScreenExitFlag = 0
GetReply = 0
GetReplyB = 0
GetReplyC = "N"
GetReplyD = 0

Select Case Callback_Message ' Callback_Message = CBMSG

Suppressing that code solved the problem.


CallBack Function cbDialogScreen()

ScreenExitFlag = 0
'' GetReply = 0
'' GetReplyB = 0
'' GetReplyC = "N"
'' GetReplyD = 0

Select Case Callback_Message ' Callback_Message = CBMSG

Why that code in that position should affect the variables that were being re-evaluated in the logic segment where they were, I cannot yet comprehend.


' See logic in former posts

However, it works now, so I am happy.

I have also overcome a problem with TCP_Recv timing which meant that the standard example logic I had been using elsewhere

Do
InBuffer = TCP_RECV(TCPFreeFile, 10) ' (My InBuffer is actually larger)
Buffer += InBuffer
Loop While ((Len(InBuffer) > 0) And (ERR = 0))
was not picking up the transmission.

Many moons ago, I said I was about to concentrate on grids. The time has finally come. I think.

Regards,

Peter H.