Re: Value of an empty cell in Numbers
Re: Value of an empty cell in Numbers
- Subject: Re: Value of an empty cell in Numbers
- From: KOENIG Yvan <email@hidden>
- Date: Wed, 4 Feb 2009 16:50:37 +0100
On 4 févr. 2009, at 16:24:39, Deivy Marck Petrescu wrote:
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
The problem with your handler is that it works only when Numbers is
used in English.
In my script, an important chunck of code is dedicated to grab the
localized version of the function's name.
I know, it's ugly.
This is why I asked Apple to add one entry in the localizable.strings
file.
My proposal is:
lprojName whose value would be:
da
Dutch
English
fi
French
German
Italian
Japanese
ko
no
pl
pt
pt_PT
ru
Spanish
sv
zh_CN
zh_TW
given the language used to display the program's GUI. *)
Grabbing it would be easy
and knowing it,
it would be easy to reach the localized function's names.
CAUTION, as the string lProjName is unavailable at this time you
can't run the script.
I may do because I added the strings for see.
--[SCRIPT]
property theApp : "Pages"
--=====
on run
set p2lproj to my getLproj(theApp)
set ISBLANK_loc to my getLocalizedFuncName(p2lproj, "ISBLANK")
set DURATION_loc to my getLocalizedFuncName(p2lproj, "DURATION")
end run
--=====
on getLproj(aa)
local lprojName
set lprojName to my getlprojName(aa) & ".lproj"
return (path to application support as text) & "iWork
'09:Frameworks:SFTabular.framework:Versions:A:Resources:" & lprojName
end getLproj
--=====
on getLocalizedFuncName(f, x)
return localized string x from table "Localizable" in bundle file f
end getLocalizedFuncName
--=====
on getlprojName(aa)
local z
try
tell application aa to set z to localized string "lprojName"
on error
set z to "English"
end try
return z (* returning
da
Dutch
English
fi
French
German
Italian
Japanese
ko
no
pl
pt
pt_PT
ru
Spanish
sv
zh_CN
zh_TW
given the language used to display the program's GUI. *)
end getlprojName
--=====
on parleFrancais()
return (get lprojName of application theApp) = "French"
end parleFrancais
--=====
--[/SCRIPT]
Yvan KOENIG (from FRANCE mercredi 4 février 2009 16:50:35) _______________________________________________
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