• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: nil in AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nil in AppleScript


  • Subject: Re: nil in AppleScript
  • From: Takaaki Naganoya <email@hidden>
  • Date: Fri, 04 Nov 2016 14:14:23 +0900

2016/11/04 10:50、Shane Stanley <email@hidden>のメール:
On 4 Nov. 2016, at 12:38 pm, Takaaki Naganoya <email@hidden> wrote:
We use "missing value" as the equivalent of “nil" in AppleScriptObjC.
But an Apple support engineer wrote me “missing value is not the equivalent of nil. Your program has a bug”.
I wrote a lot of AppleScriptObjC programs and “missing value” works as the equivalent of “nil” (with some warning messages. it was the issue in this case!).
(1) There is an another nil equivalent keyword presents which we does not know.
(2) There is a bug in Cocoa-bridging system
(3) Apple employs a support monkey or a broken AI
You are correct: "missing value" *is* the equivalent of "nil”.

I hope so :-)

The only complication is that Objective-C doesn't allow nil in collections like arrays and dictionaries, but uses objects of the NSNull class there instead. The bridge converts these values to "missing value" as well, which can pose problems when going the other way.

Can you post a snippet of code that shows the problem? What was the bug number?

Bug Number:2373415

Description (in Japanese) :
http://piyocast.com/as/archives/4268

Code:
<AppleScript>
#!/usr/bin/osascript
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
--Caution!! This Script must be a "Script Bundle" !

on run paramList
set aClass to class of paramList
if paramList = {} or aClass = script then --No parameter or executed with Script Editor
return retMyComment() of me
else --With parameter with osascript command from Terminal
set p1 to (contents of item 1 of paramList)
if p1 is not equal to missing value then
display notification p1
end if
end if
end run


--Return "Description" data within its Script bundle
on retMyComment()
set myPath to (path to me) as string
set docPath to myPath & "Contents:Resources:description.rtfd:TXT.rtf"
set aRes to retTextFromRTF(docPath) of me
return aRes
end retMyComment

on retTextFromRTF(aFile)
set aFilePath to current application's NSString's stringWithString:(POSIX path of aFile)
set aData to current application's NSData's dataWithContentsOfFile:aFilePath options:0 |error|:(missing value)
set theStyledText to current application's NSMutableAttributedString's alloc()'s initWithData:aData options:(missing value) documentAttributes:(null) |error|:(missing value)
if theStyledText is not equal to missing value then
return (theStyledText's |string|()) as string
else
return false --Not RTF file
end if
end retTextFromRTF
</AppleScript>

--
Takaaki Naganoya
email@hidden
http://piyocast.com/as/

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: nil in AppleScript
      • From: Shane Stanley <email@hidden>
References: 
 >nil in AppleScript (From: Takaaki Naganoya <email@hidden>)
 >Re: nil in AppleScript (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: nil in AppleScript
  • Next by Date: Re: nil in AppleScript
  • Previous by thread: Re: nil in AppleScript
  • Next by thread: Re: nil in AppleScript
  • Index(es):
    • Date
    • Thread