Re: AS/FMP: a list of fewer than two records
Re: AS/FMP: a list of fewer than two records
- Subject: Re: AS/FMP: a list of fewer than two records
- From: Gary Lists <email@hidden>
- Date: Fri, 27 Feb 2004 00:32:51 -0500
Chap Harrison wrote [2/26/04 11:39 PM]:
>
Please tell me I'm just doing something stupid.
Oooohhh, Chap. I'm itching to do it, but I won't.
>
Everything was working great with a database of 21 test records. Then
>
I tried it with 1 record.
>
>
The following suddenly broke -
>
>
set myLI_IDList to ID of (every record whose cell "Price" is not "*")
>
repeat with myLI_ID in myLI_IDList
>
>
Apparently, when only one record meets the criteria, "ID of (every
>
record whose...)" returns a scalar value, not a list. So the repeat
>
statement failed - I was not iterating over a list.
>
>
Okay... So I add "as list" -
That's right. Single item needs to be made into a list for your upcoming
loop-de-loop.
>
set myLI_IDList to ID of (every record whose cell "Price" is not "*")
>
as list
>
repeat with myLI_ID in myLI_IDList
>
>
That fixed it!
>
>
Next I try it with *zero* qualifying records.
;) I see it coming!
>
The 'set myLI_IDList...' statement dies with an "object not found".
>
It's only a wild guess, but I'm guessing that an empty set of records
>
is not an object?
Well, it's just empty. It's this: {}
If you leave your house, are you suggesting it is no longer a house?
Is Steven Wright your cousin?
>
Is it time to go to bed, or does AS (or FMP) sometimes really treat "a
>
list of zero items" and "a list of one item" as something other than a
>
list? (That would be... "English-like")
>
>
Please, tell me I'm just doing something stupid.
Now you've done it. I gave way at the beginning, but since you _insist_!
While not 'stupid', it's pretty obvious, right? Before you enter the loop,
make sure you've got something to loop with!!
...
if thisThing is not {} then -- ride the loop
repeat with this in that
...
end repeat
else
display dialog "You're doing something stupid." buttons {";-)",":-)"}
end if
...
>
Thank you,
>
Chap
You're welcome. And stop calling me Chap.
--
Gary
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.