[futurebasic] Re: [FB] Problem of AppleEvent in Leopard

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2007 : Group Archive : Group : All Groups

From: Yoshiyuki Hasegawa <hase44@...>
Date: Fri, 30 Nov 2007 05:05:38 +0900
  Robert Purves wrote:

>
> Yoshiyuki Hasegawa wrote:
>
>> The following symptoms happened to the FB program for AppleEvent.
>> Environment: OSX 10.5.1 Intel MacBook Pro 2.33GHz 2GB.
>> Because Leopard is not installed in PowerPC, it is unconfirmed.
>>
>> Codes who seem that problems it:
>>
>> on AppleEvent( _"Boxd", _"TEXT" ) fn doAppleEvent
>> masg$ = AppleEventMessage$
>> SendAppleEvent _"Boxd", _"TEXT", @masg$ + 1, len( masg$ ) : Maybe,  
>> this is a problem.
>>
>> Symptom:
>>
>> The spinning ball turns when the program executes any code and it  
>> stops (For about five minutes).
>> It is not 100% though the symptom appears at the probability from  
>> about 80 to 90%.
>
> Please post a short complete runnable program that demonstrates  
> your bug. Then others can try to reproduce it on OS X 10.4.
>

It is a post as follows as for the demonstration program.

Test method:

1. Two code Alpha and Beta are separately compiled.
2. Two programs are booted.
3. "Send" button is alternately clicked.

As for the demonstration program, the occurrence of the bug is fewer  
than an original program.
The bug might not occur in the first boot. They are quit and it boots  
it again at that time.
OS is restarted to reproduce the bug or it might have to be recompile  
as for the programs.

Yoshiyuki

' Test program Alpha.
'---------------------------------------
output file "Test Program Alpha"

begin enum 1
_cBtn
_cEdit
_c1Edit
end enum

#define FMFontFamily as SInt16
toolbox fn FMGetFontFamilyFromName(Str255 iName) = FMFontFamily

local fn BuildUntitled1Wnd
dim as Str255              s
dim as ControlFontStyleRec tfs
dim as Rect                r
'~'<
SetRect(r, 138, 396, 438, 546)
appearance window -1, "Alpha", @r, _kDocumentWindowClass
'~'<
SetRect(r, 210, 110, 280, 130)
appearance button _cBtn, _activeBtn,,,,"Send", @r,  
_kControlPushButtonProc

SetRect(r, 23, 23, 277, 39)
appearance button _cEdit, _activeBtn,,,,, @r, _kControlEditTextProc
tfs.flags =  
_kControlUseFontMask_kControlUseSizeMask_kControlUseFaceMask_kControlUse 
JustMask
tfs.font = fn FMGetFontFamilyFromName("Lucida Grande")
tfs.size = 13
tfs.style = 0
tfs.just = _teJustLeft
def SetButtonFontStyle(_cEdit, tfs)
s = ""
def SetButtonTextString(_cEdit, s)

SetRect(r, 23, 67, 277, 83)
appearance button _c1Edit, _activeBtn,,,,, @r, _kControlEditTextProc
def SetButtonFontStyle(_c1Edit, tfs)
s = "Enter Message"
def SetButtonTextString(_c1Edit, s)

appearance window 1
end fn

local fn doAppleEvent
dim as Str255  s
'~'1
s = AppleEventMessage$
beep
def SetButtonTextString(_cEdit, s)
end fn

local fn sndAppleEvent( clas as long )
dim as Str255  s
'~'1
s = fn ButtonTextString$(_c1Edit)
SendAppleEvent clas, _"TEXT", @s + 1, len(s)
beep
end fn

local fn DoDialog
dim as long ev, id
dim as Str255  s
'~'<
ev = dialog(0)
id = dialog(ev)
select ev
case _wndClick
window id
case _btnClick
select window(_outputWnd)
case 1
select id
case _cBtn
fn sndAppleEvent( _"Beta" )
end select
end select
end select
end fn

fn BuildUntitled1Wnd

on dialog fn DoDialog
on AppleEvent( _"Alph", _"TEXT") fn doAppleEvent

do
HandleEvents
until gFBQuit
'=================================================================

' Test program Beta.
'---------------------------------
output file "Test Program Beta"

begin enum 1
_cBtn
_cEdit
_c1Edit
end enum

#define FMFontFamily as SInt16
toolbox fn FMGetFontFamilyFromName(Str255 iName) = FMFontFamily

local fn BuildUntitled1Wnd
dim as Str255              s
dim as ControlFontStyleRec tfs
dim as Rect                r
'~'<
SetRect(r, 138+400, 396, 438+400, 546)
appearance window -1, "Beta", @r, _kDocumentWindowClass
'~'<
SetRect(r, 210, 110, 280, 130)
appearance button _cBtn, _activeBtn,,,,"Send", @r,  
_kControlPushButtonProc

SetRect(r, 23, 23, 277, 39)
appearance button _cEdit, _activeBtn,,,,, @r, _kControlEditTextProc
tfs.flags =  
_kControlUseFontMask_kControlUseSizeMask_kControlUseFaceMask_kControlUse 
JustMask
tfs.font = fn FMGetFontFamilyFromName("Lucida Grande")
tfs.size = 13
tfs.style = 0
tfs.just = _teJustLeft
def SetButtonFontStyle(_cEdit, tfs)
s = ""
def SetButtonTextString(_cEdit, s)

SetRect(r, 23, 67, 277, 83)
appearance button _c1Edit, _activeBtn,,,,, @r, _kControlEditTextProc
def SetButtonFontStyle(_c1Edit, tfs)
s = "Enter Message"
def SetButtonTextString(_c1Edit, s)

appearance window 1
end fn

local fn doAppleEvent
dim as Str255  s
'~'1
s = AppleEventMessage$
beep
def SetButtonTextString(_cEdit, s)
end fn

local fn sndAppleEvent( clas as long )
dim as Str255  s
'~'1
s = fn ButtonTextString$(_c1Edit)
SendAppleEvent clas, _"TEXT", @s + 1, len(s)
beep
end fn

local fn DoDialog
dim as long ev, id
'~'<
ev = dialog(0)
id = dialog(ev)
select ev
case _wndClick
window id
case _btnClick
select window(_outputWnd)
case 1
select id
case _cBtn
fn sndAppleEvent( _"Alph" )
end select
end select
end select
end fn

fn BuildUntitled1Wnd

on dialog fn DoDialog
on AppleEvent( _"Beta", _"TEXT") fn doAppleEvent

do
HandleEvents
until gFBQuit
'---------------------------------