On Feb 4, 2009, at 5:03 AM, KOENIG Yvan wrote: Here is an enhanced version of the handler doYourDuty()
--=====
on doYourDuty(r, c, t, s) local tName, newTable, errMsg, errNum, sheetName, flag tell application "Numbers09" to tell document 1 if value of cell r of column c of table t of sheet s is not 0.0 then set flag to false else tell sheet 1 set tName to "temporary_yraropmet" set newTable to make new table with properties {name:tName} try newTable as text on error errMsg number errNum set sheetName to item 4 of my decoupe(errMsg, quote) end try end tell -- sheet 1 tell sheet sheetName tell table tName (* assuming that r,c points cell H12, inserts the localized formula =ISBLANK(H12) *) set value of cell 1 of row 1 to "=" & ISBLANK_loc & "(" & s & " :: " & t & " :: " & my refEnLettres(r, c) & ")" (* grabs the returned value *) set flag to value of cell 1 of row 1 end tell -- tName delete table tName (* removes the temporary table *) end tell -- sheet sheetName end if end tell -- document 1 of application return flag end doYourDuty
--=====
No need to create the auxiliary table if the grabbed cell value is not 0.0.
Yvan KOENIG (from FRANCE mercredi 4 février 2009 11:02:12) _______________________________________________
Yvan, if I am creating the table I use 1E-5, for instance, as the value for a *0* cell. Then when I look for a cell that it is empty, my zero will not be flagged. The problem is, what if the table exists already? Then I think your idea of creating a new table and using isblank is excellent.
I wrote the following script to check if it is empty using your idea. Notice that the repeat is only on the "0" valued cells of a range.
---------- tell application "Numbers" to tell document 1 to tell sheet 1 set nom to name of table 1 tell table nom set l to row 2 -- use column for column ranges set ecell to name of every cell of l whose value is 0 end tell return my emptycells(nom, ecell) end tell
on emptycells(nome, lcell) tell application "Numbers" to tell document 1 to tell sheet 1 set nutable to make new table at front with properties {name:"temp", column count:2, row count:2} set torf to {} repeat with r in lcell set r to contents of r tell table "temp" set value of cell "B2" to "=ISBLANK(" & nome & " :: " & r & ")" if (get value of cell "B2") = true then set end of torf to r end tell end repeat delete table "temp" return torf end tell end emptycells
------------ Thank you!
|