• 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: compactness of expression question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compactness of expression question


  • Subject: Re: compactness of expression question
  • From: Steven Angier <email@hidden>
  • Date: Fri, 18 Jan 2002 08:29:22 +1100
  • Organization: Macscript.com

billp wrote:

> Is there a more compact way I can express the following?:

Several:

1. using else if:

----

if ItemKind = "Characters" then
global CharacterCount
set CharacterCount to ItemCount
else if ItemKind = "Words" then
global WordCount
set WordCount to ItemCount
else if ItemKind = "Lines" then
global LineCount
set LineCount to ItemCount as integer
else if ItemKind = "Paragraphs" then
global ParagraphCount
set ParagraphCount to ItemCount as integer
else if ItemKind = "Tables" then
global TableCount
set TableCount to ItemCount
end if

----


2. adding one global line:

----

global CharacterCount, WordCount, LineCount, ParagraphCount, TableCount

if ItemKind = "Characters" then
set CharacterCount to ItemCount
else if ItemKind = "Words" then
set WordCount to ItemCount
else if ItemKind = "Lines" then
set LineCount to ItemCount as integer
else if ItemKind = "Paragraphs" then
set ParagraphCount to ItemCount as integer
else if ItemKind = "Tables" then
set TableCount to ItemCount
end if

----


3. using the Macscript.com Library's GetOffsetInList() function (demo available from
http://www.macscript.com):

----

property kItemKindList : {"Characters", "Words", "Lines", "Paragraphs", "Tables"}
property gCounts : {0, 0, 0, 0, 0}

set theOffset to GetOffsetInList(ItemKind, kItemKindList)
if theOffset > 0 then set item theOffset of gCounts to ItemCount

----


Steven Angier
Macscript.com


References: 
 >compactness of expression question (From: billp <email@hidden>)

  • Prev by Date: Re: text and paragraph properties in QX 4.11
  • Next by Date: Re: compactness of expression question
  • Previous by thread: compactness of expression question
  • Next by thread: Re: compactness of expression question
  • Index(es):
    • Date
    • Thread