• 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
Checking a Record for a Field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking a Record for a Field


  • Subject: Checking a Record for a Field
  • From: "S. J. Cunningham" <email@hidden>
  • Date: Mon, 16 Nov 2015 09:17:25 -0500

I have a handler  to which I would like to pass a variable number of arguments.  I am using a record to pass the arguments and then checking in the handler whether or not a specific field exists so I can skip it if it doesn't. Here is how I am doing the check:

on myCoolHandler(someRecord)
display dialog Field_1 of someRecord
display dialog Field_2 of someRecord
if checkForField_3(someRecord) then
display dialog Field_3 of someRecord
else
display dialog "There ain't no Field 3"
end if
end myCoolHandler

on checkForField_3(theRecord)
set returnValue to true
try
get Field_3 of theRecord
on error
set returnValue to false
end try
return returnValue
end checkForField_3

set theRecord to {Field_1:"Field 1", Field_2:"Field 2"}
myCoolHandler(theRecord)
"

Is there an easier way to accomplish this?  In particular, is there a way to parameterize the check?  As it is, I need a separate "check handler" for each field I want to check.


Steve
------------------
OS X 10.6.8, AppleScript 2.1.2

 _______________________________________________
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: Checking a Record for a Field
      • From: "S. J. Cunningham" <email@hidden>
    • Re: Checking a Record for a Field
      • From: Axel Luttgens <email@hidden>
    • Re: Checking a Record for a Field
      • From: Christopher Stone <email@hidden>
    • Re: Checking a Record for a Field
      • From: Yvan KOENIG <email@hidden>
  • Prev by Date: Re: Another Weird AppleScript-ObjC Problem
  • Next by Date: Re: Checking a Record for a Field
  • Previous by thread: Re: Found It!! Another Weird AppleScript-ObjC Problem
  • Next by thread: Re: Checking a Record for a Field
  • Index(es):
    • Date
    • Thread