Re: "first element whose" in Javascript for Automation
Re: "first element whose" in Javascript for Automation
- Subject: Re: "first element whose" in Javascript for Automation
- From: Deivy Petrescu <email@hidden>
- Date: Tue, 27 Jan 2015 13:38:18 -0500
Actually David, I have another question.
Another difference that I forgot to mention but you probably noticed, I don’t use “var”.
I’ve tried some examples and did not notice any difference between using it or not.
Is there any difference?
I tried the following script
<script>
x=Array();
y=15;
for (i=0; i<11;i++){
x[i]=lcm(i,y);
}
x
function lcm(x,y){
return x*y/gcd(x,y)
}
function gcd(x,y){
while (y > 1){
[x,y]= [y, x% y];
}
if (x >y && y == 0){
return x;
} else{
return y;
}
}
</script>
and got what i expected:
—>[0, 15, 30, 15, 60, 15, 30, 105, 120, 45, 30]
> On Jan 26, 2015, at 14:35 , David Steinberg <email@hidden> wrote:
>
> Hi Deivy,
>
> Perhaps there was an issue with how the AllrowCells array was set up. This example works:
>
> var Numbers = Application("Numbers")
>
> var doc = Numbers.documents[0]
> var sheet = doc.sheets[0]
> var table = sheet.tables[0]
> var row = table.rows[0]
>
> var nullCells = row.cells.whose({ value: null })
> var firstNullCell = nullCells[0]
>
> firstNullCell.properties()
>
> I hope this helps!
>
> - David
>
>> On Jan 24, 2015, at 08:16, Deivy Petrescu <email@hidden> wrote:
>>
>> I am writing this question to the list, but this is certainly a question for David! ;-}
>> I don’t mind if someone else can answer, though!
>>
>> I am working on a JSA script for Numbers, replicating a working script in AS.
>> I am able to get an array of cells of a certain row.
>> Now I want to get the address of the first row whose values is null (missing value in AS)
>>
>> Say the array name is AllrowCells.
>>
>> AllrowCells.whose({value:null)} does not seem to work.
>> —> TypeError: undefined is not a function (evaluating 'Allrowcells.whose({value:null})')
>>
>> I changed “value” and used other properties, still no go.
>> Also use other methods suggested in the JSA RN and, I then tried the literal copy of the JSA RN and use both someElementAllrowCells.whose() and firstElementAllrowCells.whose() (yep, I know, but when you are desperate reason goes down the drain)
>>
>> Here are the properties of a particular cell:
>>
>> {"verticalAlignment":"top", "row":Application("Numbers").documents.byId("BA596B39-A416-410C-9E8E-B065DF650640").sheets.at(0).tables.at(0).rows.byName(" John"), "pcls":"cell", "fontName":"HelveticaNeue", "formattedValue":null, "backgroundColor":{"red":0.7529411911964417, "green":0.9293965101242065, "blue":0.9960784316062927}, "formula":null, "name":"K2", "textWrap":false, "textColor":{"red":0, "green":0, "blue":0}, "alignment":"auto align", "column":Application("Numbers").documents.byId("BA596B39-A416-410C-9E8E-B065DF650640").sheets.at(0).tables.at(0).columns.byName("1/30"), "format":"automatic", "fontSize":10, "value":null}
>>
>>
>> Deivy Petrescu
>> email@hidden
>>
>>
>>
>>
>> _______________________________________________
>> 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
>
Deivy Petrescu
email@hidden
_______________________________________________
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