Discussion:
Why is this code working only in 32 bit?
Marnaud
2017-08-03 19:11:51 UTC
Permalink
Hello,

I have this code, which, for a given AppleEvent, retrieves its error code:

Public Function GetAEReplyError(theevent As AppleEvent) as Integer
#if TargetMacOS then
dim i,j,k As Integer
dim s As OSType

If theEvent Is Nil then Return 0

If theEvent.ReplyPtr=0 then Return 0

dim replyEvent as new MemoryBlock(4)
replyEvent.Long(0)=theEvent.ReplyPtr
replyEvent=replyEvent.Ptr(0)

If replyEvent.Size>-1 and StrComp(replyEvent.StringValue(0, 4), "null",0)=0 then Return 0

Soft Declare Function AESizeOfParam Lib "Carbon.framework" (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as Integer,dataSize as Integer) as Short

If AESizeOfParam(theEvent.ReplyPtr,"errn",0,0)<>0 then Return 0//because an error code has not been set

Soft Declare Function AEGetParamPtr Lib "Carbon.framework" (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as OSType,ByRef actualType as OSType,ByRef dataPtr as Integer,MaxSize As Integer,ByRef DataSize As Integer) as Short
k=AEGetParamPtr(theEvent.ReplyPtr,"errn","long",s,i,4,j)
Return i
#endif
End Function

In 32 bit, it works flawlessly, but in 64 bit, replyEvent has a size of -1 after the line “replyEvent=replyEvent.Ptr(0)” and I don’t understand why. May someone help, please?


To unsubscribe, email ***@xojo.com
Christian Schmitz
2017-08-03 19:46:00 UTC
Permalink
Post by Marnaud
Hello,
replyEvent.Long(0)=theEvent.ReplyPtr
replyEvent=replyEvent.Ptr(0)
Ptr size in 64-bit is 64-bit, so this won’t work well!


In general I would recommend using some high level API like NSAppleEvent* classes.

e.g. via MBS Plugin:
http://www.monkeybreadsoftware.net/pluginpart-nsapplescript.shtml

The plugins should work fine for 64-bit.

Sincerely
Christian
--
Read our blog about news on our plugins:

http://www.mbsplugins.de/




To unsubscribe, email ***@xojo.com
Marnaud
2017-08-04 08:57:52 UTC
Permalink
Post by Christian Schmitz
Post by Marnaud
Hello,
replyEvent.Long(0)=theEvent.ReplyPtr
replyEvent=replyEvent.Ptr(0)
Ptr size in 64-bit is 64-bit, so this won’t work well!
That’s somehow what I thought. No way to force it to be a 32 bit Ptr?
Post by Christian Schmitz
In general I would recommend using some high level API like NSAppleEvent* classes.
http://www.monkeybreadsoftware.net/pluginpart-nsapplescript.shtml
The plugins should work fine for 64-bit.
I have a lot of functions that send AppleEvents, and a function that gets the returned error code. I don’t want to rewrite all the functions that work fine. Can I use NSAppleEvent classes from an existing, passed as parameter, AppleEvent?
Thank you.


To unsubscribe, email ***@xojo.com
emile.a.schwarz
2017-08-04 09:25:05 UTC
Permalink
Is Carbon 64Bits ?

 

 

 

 
Message du 04/08/17 10:58
De : "Marnaud"
A : "Nug"
Objet : Re: Why is this code working only in 32 bit?
Post by Marnaud
Hello,
replyEvent.Long(0)=theEvent.ReplyPtr
replyEvent=replyEvent.Ptr(0)
Ptr size in 64-bit is 64-bit, so this won’t work well!
That’s somehow what I thought. No way to force it to be a 32 bit Ptr?
In general I would recommend using some high level API like NSAppleEvent* classes.
http://www.monkeybreadsoftware.net/pluginpart-nsapplescript.shtml
The plugins should work fine for 64-bit.
I have a lot of functions that send AppleEvents, and a function that gets the returned error code. I don’t want to rewrite all the functions that work fine. Can I use NSAppleEvent classes from an existing, passed as parameter, AppleEvent?
Thank you.
To unsubscribe, email ***@xojo.com
Christian Schmitz
2017-08-04 17:08:03 UTC
Permalink
Post by emile.a.schwarz
Is Carbon 64Bits ?
Partly.

The GUI is not, but CoreGraphics is available in 64-bit.

Sincerely
Christian
--
Read our blog about news on our plugins:

http://www.mbsplugins.de/




To unsubscribe, email ***@xojo.com
emile.a.schwarz
2017-08-04 18:50:34 UTC
Permalink
Post by Marnaud
Post by emile.a.schwarz
Is Carbon 64Bits ?
 
Post by Marnaud
Soft Declare Function AESizeOfParam Lib "Carbon.framework" (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as Integer,dataSize as Integer) as Short
Soft Declare Function AEGetParamPtr Lib "Carbon.framework" (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as OSType,ByRef actualType as OSType,ByRef dataPtr as Integer,MaxSize As Integer,ByRef DataSize As Integer) as Short
 

I restate my question:

is AppleEvent Carbon 64 Bits ?

 

If not, this is the reasn why the code does not works anymore


 

 
Post by Marnaud
Message du 04/08/17 19:08
De : "Christian Schmitz"
A : "Nug"
Objet : Re: Why is this code working only in 32 bit?
Post by emile.a.schwarz
Is Carbon 64Bits ?
Partly.
The GUI is not, but CoreGraphics is available in 64-bit.
Sincerely
Christian
--
http://www.mbsplugins.de/
To unsubscribe, email ***@xojo.com
Christian Schmitz
2017-08-04 20:02:49 UTC
Permalink
Post by emile.a.schwarz
Post by Marnaud
Post by emile.a.schwarz
Is Carbon 64Bits ?
Soft Declare Function AESizeOfParam Lib "Carbon.framework" (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as Integer,dataSize as Integer) as Short
Soft Declare Function AEGetParamPtr Lib "Carbon.framework" (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as OSType,ByRef actualType as OSType,ByRef dataPtr as Integer,MaxSize As Integer,ByRef DataSize As Integer) as Short
You need to recheck every parameter and return type for what size it has on 32bit vs. 64bit.
Post by emile.a.schwarz
is AppleEvent Carbon 64 Bits ?
As far as I know, it is.

Sincerely
Christian
--
Read our blog about news on our plugins:

http://www.mbsplugins.de/




To unsubscribe, email ***@xojo.com
Marnaud
2017-08-04 20:05:43 UTC
Permalink
Post by emile.a.schwarz
Post by Marnaud
Is Carbon 64Bits?
Soft Declare Function AESizeOfParam Lib "Carbon.framework" (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as Integer,dataSize as Integer) as Short
Soft Declare Function AEGetParamPtr Lib "Carbon.framework" (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as OSType,ByRef actualType as OSType,ByRef dataPtr as Integer,MaxSize As Integer,ByRef DataSize As Integer) as Short
is AppleEvent Carbon 64 Bits ?
If not, this is the reason why the code does not works anymore…
Thank you, Emile. However, I don’t think it’s the problem, because the “replyEvent=replyEvent.Ptr(0)” line, which gives different results (32 vs 64 bit) is before the Declare lines.


To unsubscribe, email ***@xojo.com

Continue reading on narkive:
Loading...