Create a two-way link (using AppleScript?) in Numbers '09
We are migrating to iWork '09 for our business needs and seek an Applescript expert to advise us as follows.
Our team has successfully used VBA in Excel for Mac 2004 to "two-way link" two cells in differing spreadsheets such that anything entered in cell 1 shows up in cell 2 and vice versa. However, neither Excel for Mac 2008 (which most of our company uses) nor Numbers supports VBA, and Numbers seems like the best overall app to use IF we can get two cells to link as described. Typical formulas do not work as a cell cannot be both an input and an output cell.
Please advise or help!
Thank you,
Reos Partners
yuleth wrote:
Thank you Yvan. We are grateful for your lengthy response and your suggested script. There are a few things to clarify before we can take a next step with that script.
1. We are planning to have not just two documents, but many documents. When we share these Numbers documents on a network drive or Dropbox, the entire setup will become a project management tool. We will have a "master" document as well as "project-specific" documents in this setup, all linked together by the script or scripts in question and housed in different folders.
I really dislike working with documents stored on a network.
It's more safe to work with a local file and store it on the network when it's OK.
The "master" document will allow the general manager to see and enter data that shows up in "project-specific" documents. On the other hand, data entered in specific cells in the "project-specific" documents will show up in the manager's "master."
If I understand well,
rangeA of cells of the 'master' doc are shared with document A
rangeB of cells of the 'master' doc are shared with document B
rangeZ of cells of the 'master' doc are shared with document Z
as well as
rangeA of cells of document A are shared with the 'master' doc
rangeB of cells of the document B are shared with the 'master' doc
rangeZ of cells of the document Z are shared with the 'master' doc
It's important that this functionality operate not only with open documents; this should be able to function also when only one of the linked documents, master or otherwise, is in use. Is that possible?
It would require that the script is aware of the exact location of every document.
2. We understand the limitation you describe: either a predefined (hardcoded) cell in the script OR the same location in the target document.
3. Once we have a script that performs as described above, we actually don't know what to do with it: we're brand new to Applescript but have used Macs for many years. Given our unfamiliarity with the use of such scripts, please advise, or point us to a resource: then what? How is such a script applied to a Numbers document or a series of documents? Or do we set it up such that it always runs when Numbers runs, and if so, how? What is the procedure?
Using a script running in the background would not be safe to capture cells selection.
I thought that I was clear when I wrote:
+Given two open documents whose names are defined by the property theDocs,+
+enter a value in a cell on one of them.+
+With the cell selected, call the script.+
+It will copy the entered value in the same cell of the other document.+
In the original script, when one script is filled and selected,
it's your duty to call the script.
--[SCRIPT]
The embedded properties describe a master document
and several subscriber documents.
One describe the ranges of cells dedicated to each subscriber.
These ranges are of this format: {topRow, leftColumn, bottomRow, rightColumn}
In the open document, fill the range of cells dedicated to one document.
Select this range.
Call the script.
It will copy the selected range in the same range of the target document.
Yvan KOENIG (Vallauris, FRANCE)
2009/07/31
enhanced 2009/08/01
property masterName : "masterDoc.numbers"
property masterContainer : "Macintosh HD:Users:yvan_koenig:Desktop:"
property theNames : {"documentA.numbers", "documentB.numbers"}
property theContainers : {"Macintosh HD:Users:yvan_koenig:Desktop:", "Macintosh HD:Users:yvan_koenig:Desktop:"}
property theRanges : {{2, 2, 4, 3}, {5, 4, 8, 5}}
--=====
on run
set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
if (dName is not masterName) and (dName is not in theNames) then error "the source document is not an allowed one !"
if dName is masterName then (*
the selection is in the master document
we must define the target document *)
set theRange to {rowNum1, colNum1, rowNum2, colNum2}
set maybe to false
repeat with i from 1 to count of theRanges
if theRange is item i of theRanges then (*
the selected range is one of the predefined ones so we may define the parameters of the target document *)
set targetname to item i of theNames
set targetContainer to item i of theContainers
set maybe to true
exit repeat
end if
end repeat
if maybe is false then error "the selection in the document “" & dName & "” is not valid !"
else (*
the selection is in one of the subscriber documents.
So the target document is the master one. *)
set targetname to masterName
set targetContainer to masterContainer
(* now, we must grab the predefined range linked to the active document *)
repeat with i from 1 to count of theNames
if dName is item i of theNames then
set theRange to item i of theRanges
exit repeat
end if
end repeat
(* we check that the selected range is really the predefined one *)
if {rowNum1, colNum1, rowNum2, colNum2} is not theRange then error "the selection in the document “" & dName & "” is not valid !"
end if
(* Here we know the name of the target document
the container of the target document
the selected range
tell application "Numbers"
set isOpen to targetname is in (get name of documents)
if not isOpen then
open file (targetContainer & targetname)
repeat
if (get name of documents) contains targetname then exit repeat
end repeat
end if
repeat with r from item 1 of theRange to item 3 of theRange
repeat with c from item 2 of theRange to item 4 of theRange
tell document dName to tell sheet sName to tell table tName to set theValue to value of cell r of column c
tell document targetname to tell sheet sName to tell table tName to set value of cell r of column c to theValue
end repeat -- columns
end repeat -- rows
save document targetname
if not isOpen then close document targetname
end tell -- Numbers
end run
--=====
set { dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
on getSelParams()
local r_Name, t_Name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
set {d_Name, s_Name, t_Name, r_Name} to my getSelection()
if r_Name is missing value then
if my parleAnglais() then
error "No selected cells"
else
error "Il n'y a pas de cellule sélectionnée !"
end if
end if
set two_Names to my decoupe(r_Name, ":")
set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_Name)
if item 2 of two_Names = item 1 of two_Names then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_Name)
end if
return {d_Name, s_Name, t_Name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end getSelParams
--=====
set {rowNumber, columnNumber} to my decipher(cellRef,docName,sheetName,tableName)
apply to named row or named column !
on decipher(n, d, s, t)
tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
end decipher
--=====
set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
tell application "Numbers" to tell document 1
repeat with i from 1 to the count of sheets
tell sheet i
set x to the count of tables
if x > 0 then
repeat with y from 1 to x
try
(selection range of table y) as text
on error errMsg number errNum
set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
return {theDoc, theSheet, theTable, theRange}
end try
end repeat -- y
end if -- x>0
end tell -- sheet
end repeat -- i
end tell -- document
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on parleAnglais()
local z
try
tell application "Numbers09English" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
Yvan KOENIG (from FRANCE samedi 1 août 2009 17:57:05)
Similar Messages
-
I know how to use "navto" to jump to pages within the catalog created for our app.
We want to use the same article files to create a digital page turner using DPS but cannot figure out how to do it. Google searches lead to answers that say it isn't possible, but if i view a page turner I created in 3D Issue via Adobe's Content Viewer, the pages jump (via the links I made in 3D Issue).
I just can't believe that a huge company like Adobe has no way to do this in DPS.On pages you do not want to show-up delselect "include page in navigation menu" in the page inspector:
-
Clubbing together of Two serial link using Multilink!
Dear All,
I have two links of 2Mbps each from same service provider landing to two different serial port at my end.
What I am looking for is to club both the link as one single aggregate link of 4Mbps but the constrain is my IOS which is 12.0(25).
With 12.3 I am aware to configure Multilink PPP and clubbing two interface with this sinle multilik but please suggest how to go ahead with this clubbing with available IOS 12.0
Awaiting your response.
With best regards,
Mani
mail me : [email protected]
Show Version output
Cisco Internetwork Operating System Software
IOS (tm) 2500 Software (C2500-IS-L), Version 12.0(28c), RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2005 by cisco Systems, Inc.
Compiled Wed 30-Mar-05 16:33 by pwade
Image text-base: 0x0303E2D4, data-base: 0x00001000
ROM: System Bootstrap, Version 5.2(5), RELEASE SOFTWARE
BOOTFLASH: 3000 Bootstrap Software (IGS-RXBOOT), Version 10.2(5), RELEASE SOFTWA
RE (fc1)
uptime is 20 hours, 39 minutes
System restarted by power-on
System image file is "flash:c2500-is-l.120-28c.bin"
cisco 2500 (68030) processor (revision D) with 4096K/2048K bytes of memory.
Processor board ID 02039358, with hardware revision 00000000
Bridging software.
X.25 software, Version 3.0.0.
2 Ethernet/IEEE 802.3 interface(s)
2 Serial network interface(s)
32K bytes of non-volatile configuration memory.
16384K bytes of processor board System flash (Read ONLY)
Configuration register is 0x2102Hi Guys,
You should use the RAD IMAXI-E1. It works on the Bonding protocol and automatically clubb ur bandwidth.
u need to place 2 Imaxi -E1 in both side. It is basically inverse multiplexures. Cisco does the same.
It will combine ur 4 E1s to ethernet 10/100.
contact me at [email protected] for more information.
cheers!
additinally if u want to use the cisco feature called multilink PPP feature. use ppp encapsulation on ur all 4 or 2 E1's WAN /serial interface. Create one loopback address in each end. on ur wan put this ip (ip unnberred on loop0). and make this port to member of the multilink groiup. thats all
or
configure it as a bridge irb and use multilink. thats all. -
How do I create a "Reset Password Link" using apex for OracleExpress 10g?
I'd like to add a "Reset Password" link to my application, but am not sure how to implement this.
I see there is htmldb_util.reset_pw procedure, but this can only be called if the current user has admin privs. Clearly, an end user will not be able to logon as the administrator in order to reset their password!
I tried preceding the call to htmldb_util.reset_pw with a call to htmldm_custom_auth.set_user, and whilst the page showed the name of the admin user when it displayed, the call to htmldb_util.reset_pw still raised the exception that the current user must have admin privs.
Can anyone help please? Thanks Pete
Message was edited by:
pcarlisl
Message was edited by:
pcarlislYou can either "play" with permissions for each user or you collect the reset password requests into a table and use DBMS_SCHEDULER to run the reset procedure every few minutes - this of course makes only sense, if said reset procedure can be used on different users from one account.
C.
Message was edited by:
cd -
When I use the URL hypertext function and type in mailto:<email address> and save it as a pdf. When bringing the pdf up in a smart phone and tapping on the link, it will bring up email to that person. Is there a FrameMaker version that also does this for a phone number and what is the text that needs to be typed in? Any assistance would be greatly appreciated!!!
What happens when you use Marker Type: [Hypertext]
and a URI of form:
message URL tel:1234567890
In a quick test, this survives to PDF as hypertext, gets handed to my default browser, which (being a desktop machine) throws a dialog saying, in effect "Just what am I supposed to do with this? I'm not a phone you know." My phone, on the other hand has two PDF readers (Kindle and some shovelware office ap), neither of which appear to even notice the URL (which I take to be not FM's fault).
The hand-off to email is not something that FM (or Acrobat) does per se. As far as I know PDF readers merely hand the URI to the host operating system. If the host knows what a "tel:" scheme name is supposed to do, it gets done. For a more or less complete list of scheme names, see the wiki page.
Be sure to use fully qualified international dialing numbers.
And be sure to avoid mistake 0 of FM hypertext markers: in addition to inserting the marker, it has to be within the scope of a unique Character Format applied to the text string to be made active. This tag doesn't even have to apply any visible effects, but it does have to be there, as it's how FM determines the boundaries of the hyper region. A Character Format set to Family:Default ¶ Format (and all else blank or As-Is), named "URI", would suffice. -
Hi all! Is there a way to use pages and numbers to mail merge?
I'm a teacher and its the start of exam season admin - if anyone could help it would cut a workload down dramatically!
Hi
Please vist the below link:
http://www.thescarms.com/dotnet/XSDDatasource.aspx
Hope this helps!!!
Regards
Sourashree -
Call Applescript from Numbers 09
I am in the middle of switching over from PC to MAC. I used to use Excel but have switched to numbers. I can do everything I want but it is all manual. I used to use Macro's in Excel and I am looking for a way to use applescript from Numbers.
Is there a way to link a script to a shape or put a button in the menus?
I hope this question makes sense.
Thanks
SteveNot as far as I know but you can put the script into ~/user/Library/Scripts folder so it is accessible from the menu bar at top right of screen.
You might need to open application applescript editor and change pref to show "script menu in menu bar", (not sure if it is default or not). -
As the subject indicates, I'm wondering if anyone knows a way to use AppleScript or Automator to launch the Mac App Store and download any available updates on a set schedule.
I would advise against this. Updates sometimes reduce functionality or break programs. I would never get an update with working software unless there is a specific problem you are trying to solve.
I have read many desperate posts from people trying to go back to earlier versions for various reasons. This is easy to do with disk-based software, but with downloaded software, going backward can be more difficult. -
Using Applescript for uploading pictures on the Internet
Hello!
I was wondering if there was a way to use Applescript with Firefox (or another browser)...?
We have many many villas on our website, each one with lots of pictures. We are constantly adding new villas to our site and amending old ones.
To add pictures we go to a page in our cms for each villa, located there is a drop down menu - image 1, image 2, 3 etc etc etc
For each one we have to manually browse for and attach the photo. As you can guess this is a time consuming process, we have asked the web designer before for this but he is so busy and we have other more important stuff for him to be working on.
As Applescript is so nifty I was wondering if anybody had an idea on how to use it for this process - i.e. have a folder full of pictures on the desktop and Applescript can add them?
I have no idea if this is possible, any ideas?
Many thanks and regards.
SimonYeah I completely understand, I just wanted to see if anybody knew if it could be done.
Obviously for security reasons I can't let anybody into our CMS, so looks like it's a bit of an impossible task.
Although it would be awesome to simply change the script slightly for each villa and let it do it all, this would be stupidly complicated as there are many menus to navigate to get to the uploading picture area.
It would be great if I could do all that manually then once on that page (or given the page url to Applescript) set Applescript running to upload all the images for me.
This is what that page looks like, if this helps?!:
http://img535.imageshack.us/img535/241/screenshot20100415at141.png
The drop down menu contains:
Villa Plan
Small Location Map
Image Gallery 1
Image Gallery 2
etc
etc
I could arrange a folder with the pictures in order (i.e. Villa Plan first, then Small location Map, then the picture for 1 etc) so no worries about the Villa Plan and location map.
I've got a feeling I'm just going to have to do it manually (I shall forever be uploading pictures), but I thought I would give it to some of you geniuses to mull over!
For whoever creates a script I'll give you a discounted stay in Paradise... there's an incentive!!
Many thanks and regards,
Simon -
Two way WCF Service with default response
Hello All,
I have one schema that i need to expose as a WCF-Service. However, i want to send a response back to the caller (default response). This is just to acknowledge the caller.
Now how to create a two-way service that sends a default response always?
I can do this by creating a new response schema and defaut some value for that particualr field.
But without creating the response schema, is that possible to send response back to the caller?
Thanks
SKGuruHi
I was reading
this article.
As per my understanding ,I would try following
Create a request schema
Create a response schema ( any basic structure just a template to publish)
Use the Wizard to publish the schema
I would use my service operation method as "two way"
I will select the request schema as Request
It will select the response schema as response
It will generate a request response, two way receive port
I will write a custom pipeline to generate a blank response and try to configure it on the response. I think as per the notes we can configure the custom pipelines as notes says:
When using the wizard to create receive locations, the wizard creates the receive locations using the default values. The default value for the receive pipeline is the
Microsoft.BizTalk.DefaultPipelines.PassThruReceive pipeline. If messages received through the published WCF services require any special pipeline processing (for example, validation, correlation/property promotion, or inbound/outbound maps)
then you should set the receive pipeline to Microsoft.BizTalk.DefaultPipelines.XMLReceive, or to a custom pipeline by using the BizTalk Administration console.
I will try this and let you know.
HTH, Naushad (MCC/MCTS)
http://alamnaushad.wordpress.com, My New TechNet Wiki Article
“BizTalk Server: Performance Tuning & Optimization"
If this is
helpful or
answers your question -
please mark accordingly! Please
"Vote As Helpful" if this was useful while resolving your question! -
Create new IMAP & SMTP account with AppleScript
After reading a thread over here where some of you mentioned the problem creating a new mail account using AppleScript in fact there really seems to be a bug that doesn't allow to change authentication of a SMTP server to Password.
So I ended up going this way using PListbuddy. Of course this is no complete script and you have to adapt it to your needs. But in general "automatic" creation of new accounts works fine. We're using it to provide this to our customers as Apple Mail does not support automatic creation of mail accounts using autoconfig or autoresponder.xml.
set command1 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0 dict' ~/Library/Preferences/com.apple.mail.plist"
set command9 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:AccountName string " & theMail & "' ~/Library/Preferences/com.apple.mail.plist"
set command2 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:AccountType string SMTPAccount' ~/Library/Preferences/com.apple.mail.plist"
set command3 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:Hostname string " & servername & "' ~/Library/Preferences/com.apple.mail.plist"
set command4 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:SSLEnabled string YES' ~/Library/Preferences/com.apple.mail.plist"
set command5 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:ShouldUseAuthentication string YES' ~/Library/Preferences/com.apple.mail.plist"
set command6 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:Username string " & username & "' ~/Library/Preferences/com.apple.mail.plist"
set command7 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:uniqueId string " & myid & "' ~/Library/Preferences/com.apple.mail.plist"
set command8 to "/usr/libexec/PlistBuddy -c 'Add :DeliveryAccounts:0:AuthenticationScheme string PASSWORD' ~/Library/Preferences/com.apple.mail.plist"
do shell script command1
do shell script command2
do shell script command3
do shell script command4
do shell script command5
do shell script command6
do shell script command7
do shell script command8
do shell script command9
tell application "Mail"
set newimapac to make new imap account with properties {name:theDescription, user name:theUsername, uses ssl:true, server name:servername, port:"993", full name:theName, email addresses:{theMail}}
tell newimapac
set authentication to password
set user name to username
set password to thePassword
end tell
set mysmtp to smtp server (theDescription)
tell mysmtp
set password to mypass
end tell
set smtp server of newimapac to mysmtp
end tellThe following works exactly right, so far as I can tell (note that I made a copy of the Mail.app plist and renamed it
com.apple.mail_copy.plist). what are you doing differently?
set theMail to ""
set servername to ""
set myid to ""
set username to ""
set accountRecord to {AccountName:theMail, AccountType:"SMTPAccount", Hostname:servername, SSLEnabled:"YES", ShouldUseAuthentication:"YES", uniqueId:myid, |Username|:username, AuthenticationScheme:"PASSWORD"}
tell application "System Events"
set theMailPlist to property list file "~/Library/Preferences/com.apple.mail_copy.plist"
tell theMailPlist
tell property list item "DeliveryAccounts"
set newAccountItem to make new property list item at beginning with properties {kind:record, value:accountRecord}
tell newAccountItem
make new property list item with properties {kind:string, name:"Username", value:username}
end tell
end tell
end tell
end tell
to find a particular item in a list or directory, you use code like the following:
tell application "System Events"
set theMailPlist to property list file "~/Library/Preferences/com.apple.mail_copy.plist"
tell theMailPlist
tell property list item "DeliveryAccounts"
get every property list item whose (value of property list item "Username") contains "chump"
end tell
end tell
end tell -
Using AppleScript to automate frame grabs?
My friend has given me a list of frames from the new Dark Knight trailer that he wishes me to grab.
I know you can step through to the specific frame and Apple-C then past them into your favourite image editor, but for the number of frames he wants, this would be quite tedious.
So my question is: Is there a way to use AppleScript to jump to a specific frame/time and capture it?
Many thanks in advance.This is good information and a good example script. However that script keeps track of its own video status which could get out of sync with what is actually going on (via setting the status to "Serving Video"/"Standing By")
In my case the connection could drop and I can't depend on my own tracking of whether I was in a video chat or not.
Thanks for the link!
Matt -
ICal and subscribed calendars with MobileMe using AppleScript
I am having the same problem as many of you; I have a MobileMe account which does not sync the calendars I have in iCal that are subscriptions. I found this great script online which I'll post below. I don't know anything about AppleScript so I'm just copy-pasting. I want it to work, but I'm getting the error "The variable theOldEvent is not defined." right around the line "if similar_found is true then set theOldSummary to the summary of theOldEvent" kinda near the middle. Like I said, I don't know anything about AppleScript. So my question is; how can I fix this error and/or is there some better way of using AppleScript/Automator to do this same thing? Thanks!
Script to duplicate Calendar orgCalendar into target dupCalendar
E.H. 12.9.2008
property myCopies : 0
property myUpdates : 0
property myObsoletes : 0
property orgCalendar : "Sekretariat"
property dupCalendar : "Sekretariat copy"
property dupEvents : {}
property myDeletes : {}
set myCopies to 0
set myUpdates to 0
set myObsoletes to 0
set dupEvents to {}
tell application "iCal"
-- set theCalendars to every calendar
set theCalendarNames to title of every calendar
set theOrgCalendar to a reference to calendar orgCalendar
if theCalendarNames contains dupCalendar then
set theCalendar to a reference to calendar dupCalendar
else
set theCalendar to make new calendar with properties {title:dupCalendar}
--set theCalendar to make new calendar with properties {title:dupCalendar, color:"{65535, 0, 0}"}
end if
set the eventList to uid of every event of theOrgCalendar as list
set the eventCount to the count of the eventList
repeat with theUId in eventList
tell theOrgCalendar
set theEvent to (the first event whose uid is theUId)
-- set theProperties to the properties of theEvent as record
set theDate to the start date of theEvent
set theSummary to the summary of theEvent
set theStampDate to the stamp date of theEvent
end tell
tell theCalendar
try
set theOldEvent to (the first event of theCalendar whose (start date) is theDate as date)
set similar_found to true
on error
set similar_found to false
set theEndDate to the end date of theEvent
set theAllDay to the allday event of theEvent
set theLocation to the location of theEvent
-- Funny construction to work araund the fact that location may be missing a value
try
if theLocation is equal to "" then
end if
on error
set theLocation to ""
end try
set theDescription to the description of theEvent
try
if theDescription is equal to "" then
end if
on error
set theDescription to ""
end try
if theAllDay is true then -- work around a funny bug with all day events
set theDate to (theDate as date) + 2 * hours
set theEndDate to (theEndDate as date) + 2 * hours
end if
set newEvent to make new event at end with properties {summary:theSummary, location:theLocation, start date:theDate, end date:theEndDate, allday event:theAllDay, description:theDescription}
-- make new event at end with properties theProperties
set the end of dupEvents to (the uid of newEvent)
set myCopies to (myCopies + 1)
end try
end tell
set second_necessary to false
if similar_found is true then
set theOldSummary to the summary of theOldEvent
if theSummary is not equal to theOldSummary then
--is there a different one?
try
set theOldEvent1 to (the second event of theCalendar whose (start date) is theDate as date)
set theOldSummary to the summary of theOldEvent1
if theSummary is equal to theOldSummary then
set theOldEvent to theOldEvent1
set the end of dupEvents to (the uid of theOldEvent)
else
-- cycle repeat ?
end if
on error
-- beep
try
set theEvent1 to (the second event of theOrgCalendar whose (start date) is theDate as date)
set second_necessary to true
on error
set the end of dupEvents to (the uid of theOldEvent)
end try
end try
else
set the end of dupEvents to (the uid of theOldEvent)
end if
if second_necessary is true then
set theEndDate to the end date of theEvent
tell theCalendar
set theOldEvent to make new event at end with properties {summary:theSummary, start date:theDate, end date:theEndDate}
end tell
set the end of dupEvents to (the uid of theOldEvent)
end if
set theOldStampDate to the stamp date of theOldEvent
if theStampDate is greater than theOldStampDate then
-- update the event
set summary of theOldEvent to theSummary -- capitalization may have changed
set theAllDay to the allday event of theEvent
set allday event of theOldEvent to theAllDay
set theEndDate to the end date of theEvent
if theAllDay is true then -- work around a funny bug with all day events
set theEndDate to (theEndDate as date) + 2 * hours
end if
set end date of theOldEvent to theEndDate
set theDescription to the description of theEvent
try
if theDescription is equal to "" then
end if
on error
set theDescription to ""
end try
set description of theOldEvent to theDescription
set myUpdates to myUpdates + 1
end if
end if
end repeat
end tell
-- Delete obsolete events
set myObsoletes to 0
set myDeletes to {}
tell application "iCal"
set myUIDs to uid of events of theCalendar
end tell
repeat with myUID in myUIDs
if dupEvents does not contain myUID then
set the end of myDeletes to myUID
set myObsoletes to (myObsoletes + 1)
end if
end repeat
tell application "iCal"
repeat with myDel in myDeletes
delete (every event of theCalendar whose uid is myDel)
end repeat
end tell
-- delete duplicates
set myDeletes to {}
tell application "iCal"
set myStarts to start date of events of theCalendar
set mySummaries to summary of events of theCalendar
set myUIDs to uid of events of theCalendar
set myLength to length of myUIDs
end tell
repeat with i from 1 to (myLength - 1)
set thisStart to (item i of myStarts)
set thisSumm to (item i of mySummaries)
repeat with j from (i + 1) to myLength
set thatStart to (item j of myStarts)
set thatSumm to (item j of mySummaries)
if thisSumm is equal to thatSumm and thisStart is equal to thatStart then
set the end of myDeletes to (item j of myUIDs)
exit repeat
end if
end repeat
end repeat
set n to count of myDeletes
tell application "iCal"
repeat with myDel in myDeletes
delete (every event of theCalendar whose uid is myDel)
end repeat
-- set the visible of calendar theCalendar to false
end tell
display dialog (myCopies & " records duplicated, " & myUpdates & " records updated and " & myObsoletes & " obsolete ones deleted") as textNo longer an issue.
-
Use of applescript in numbers to automatically analyze data?
Hi all,
I am trying to figure out if it is possible to use applescript and numbers to achieve the following:
(1) Import a CSV file
(2) Work out an average and standard deviation for particular columns of data in that CSV file
(3) Copy and paste out those averages and standard deviations to a separate numbers file, along with the name of the original data file, so in the end I have a file that contains a number of rows, each one containing the results for each data file and the file name.
The files (from an analytical instrument) are all the same, so ideally I could use automator and/or applescript to automatically run through a directory of csv files to achieve this.
I know only a small amount of very basic programming. I don't want someone to write this for me, but if someone could offer some pointers or examples that would be very helpful. Or tell me that what I am trying to do is foolish, and use something else instead.
ThanksAs I got a sample file, I was able to build a script matching the full requirements.
Here is a revised version which may be useful for other users.
--[SCRIPT average&stdev_CSV]
Enregistrer le script en tant que Script : average&stdev_CSV.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
aller au menu Scripts , choisir Numbers puis choisir average&stdev_CSV
Sélectionner un dossier contenant des fichiers CSV.
Le script ouvre ces fichiers dans Numbers,
calcule les valeurs MOYENNE() et ECARTYPE()
écrit celles-ci avec le nom du document dans un fichier texte.
Après traitement de tous les fichiers le fichier texte et ouvert dans Numbers.
On peut également enregistrer le script en tant que progicile (application sou 10.6.x).
Il suffira alors de glisser/déposer l'icone du dossier à traiter sur celle du script_application.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
--=====
Save the script as a Script: average&stdev_CSV.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
go to the Scripts Menu, choose Numbers, then choose "average&stdev_CSV"
Select a folder containing CSV files.
The script open them in Numbers,
calculate the AVERAGE() and STDEV() values
write them with the file name in a text file.
When all files are treated, the text file is opened in Numbers.
You may also save the script as an application package (application under 10.6.x).
Then drag & drop the icon of the folder to treat on the scipt_application icon.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
--=====
Yvan KOENIG (VALLAURIS, France)
2010/06/10
2010/06/11 -- now read the csv file only once
--=====
property permis : {"public.comma-separated-values-text", "public.csv"}
property AVERAGE_loc : missing value
property STDEV_loc : missing value
property delim : missing value
property deci : missing value
property altDelim : missing value
property altDeci : missing value
property dossier_temporaire : missing value
property mon_Rapport : missing value
--=====
Entry point used when we double click the script's icon
or when we call it from the Scripts menu .
on run
if my parleAnglais() then
set le_prompt to "Choose a folder containing CSV file …"
else
set le_prompt to "Choisir un dossier contenant des fichiers CSV …"
end if -- parleAnglais
my main(choose folder with prompt le_prompt without invisibles)
end run
--=====
Entry point used when we drag & drop a folder icon on the application_script's icon
on open sel
my main(sel)
end open
--=====
on main(selected_item) -- it's an alias
local isFolder, nomdurapport, les_fichiers, type_ID, un_fichier, nombrededocuments, nomdutableur
the selected folder's pathname
set selected_item to selected_item as text
tell application "System Events"
set isFolder to class of disk item selected_item is folder
end tell -- System Events
if not isFolder then
if my parleAnglais() then
error "You must select a folder containing CSV file …"
else
error "Vous devez choisir un dossier contenant des fichiers CSV …"
end if -- parleAnglais
end if -- not isFolder
Init once variables which will be used later.
set dossier_temporaire to (path to temporary items) as text (* property *)
set AVERAGE_loc to my getLocalizedFunctionName("Numbers", "AVERAGE") & "(" (* property *)
set STDEV_loc to my getLocalizedFunctionName("Numbers", "STDEV") & "(" (* property *)
set {delim, deci, altDelim, altDeci} to my getLocalized_Delimiters() (* properties *)
set nomdurapport to "resume" & my dateTimeStamp() & ".txt" (* locale *)
set mon_Rapport to dossier_temporaire & nomdurapport (* property *)
Extract the list of items stored in the selected folder.
Create the resumeyyyymmddhhmmss.txt temporary file.
tell application "System Events"
set les_fichiers to every disk item of folder selected_item
make new file at end of folder dossier_temporaire with properties {name:nomdurapport}
end tell
Scan the items stored in the folder.
Skip the folders and documents which aren't csv ones.
repeat with un_fichier in les_fichiers
tell application "System Events"
if class of un_fichier is folder then
set type_ID to "Oops, I‘m a folder" (* so it will not be deciphered *)
else
set type_ID to type identifier of un_fichier
set un_fichier to path of un_fichier
end if
end tell -- System Events
if type_ID is in my permis then my traiteun_fichier(unfichier)
end repeat -- with un_fichier
The scan is done, open the resumeyyyymmddhhmmss.txt temporary file in Numbers.
tell application "Numbers"
set nombrededocuments to count of documents
open mon_Rapport
repeat while (count of documents) = nombrededocuments
delay 0.2
end repeat
set nomdutableur to name of document 1
Set cells format to the Scientific one but I can't define the number of decimals !
tell document 1 to tell sheet 1 to tell table 1
set format of range ("B1 : " & name of last cell) to scientific
end tell
save document 1 in (selected_item & nomdutableur)
end tell -- Numbers
Delete the temporary text file
tell application "System Events" to delete disk item mon_Rapport
Reset properties so there content will not be stored in the script
set AVERAGE_loc to missing value
set STDEV_loc to missing value
set delim to missing value
set altDelim to missing value
set deci to missing value
set altDeci to missing value
set dossier_temporaire to missing value
set mon_Rapport to missing value
end main
--=====
on traiteunfichier(unFichier) (* text item *)
local dossierdetravail, nomdu_csvtemporaire, csv_temporaire, utile, cnt, part2
local |dernière|, nombreDeDocuments, nomdutableur, laPlage
tell application "System Events"
tell disk item unFichier
set dossierdetravail to path of container -- of disk item unFichier
set nomdu_csvtemporaire to name -- of disk item unFichier
end tell -- unFichier
if nomdu_csvtemporaire does not end with ".csv" then set nomdu_csvtemporaire to nomdu_csvtemporaire & ".csv"
set csv_temporaire to (dossier_temporaire & nomdu_csvtemporaire)
if exists disk item csv_temporaire then delete disk item csv_temporaire
make new file at end of folder dossier_temporaire with properties {name:nomdu_csvtemporaire}
end tell -- System Events
Read the entire file
set utile to (read file unFichier)
Check that it's matching our requirements. I'm not sure that the second test is always valid.
if (utile contains "#=-=-=-=-=-=-=-=-=") and utile contains "#=-=-=-=-=-=-=-=-=End ./conf/ccia" then
set cnt to offset of "#=-=-=-=-=-=-=-=-=" in utile
Extract the second part which isn't formatted as the first one.
set part2 to text cnt thru -1 of utile
Extract the first part to decipher it.
set utile to (text 1 thru (cnt - 1) of utile) as text
Grabs the index of lower row
set |dernière| to count of (paragraphs of utile)
An ultimate test to be sure that the file is for us.
if (|dernière| > 0) and text -13 thru -2 of (paragraph 6 of utile) is "NFitsAvg'd" then
Normalize the datas according to the local settings
if not ((utile contains delim) and utile contains deci) then
if utile contains altDelim then set utile to my remplace(utile, altDelim, delim)
if utile contains altDeci then set utile to my remplace(utile, altDeci, deci)
end if
Write the normalized beginning and the untouched part2 in a temporary csv file.
write utile to file csv_temporaire
write part2 to file csv_temporaire starting at eof
Open the temporary csv in Numbers
tell application "Numbers"
set nombreDeDocuments to count of documents
open csv_temporaire
repeat while (count of documents) = nombreDeDocuments
delay 0.2
end repeat
set nomdutableur to name of document 1
tell document 1 to tell sheet 1 to tell table 1
Insert a row at top to insert the required formulas.
add row above first row
Insert the formulas calculating the AVERAGEs and the STDEVs .
repeat with c from 2 to 16 by 2
set laPlage to (name of cell 8 of column c) & " : " & name of cell |dernière| of column c
set value of cell 1 of column c to "=" & AVERAGE_loc & laPlage & ")"
set value of cell 1 of column (c + 1) to "=" & STDEV_loc & laPlage & ")"
end repeat -- with c
Extract the calculated values to build a new row in the resume.
set une_ligne to {nomdu_csvtemporaire}
tell row 1
repeat with c from 2 to 17
copy (value of cell c) as text to end of une_ligne
--copy (value of cell c) to end of une_ligne
end repeat
end tell -- row 1
end tell -- document
Save the new Numbers document.
I don't know if it is useful but it's easy to remove or disable the instruction.
save document 1 in (dossierdetravail & nomdutableur)
close document 1 saving no (* So, if you disable the Save instruction, it will close quietly *)
end tell -- Numbers
Write the new row in the resume text file.
write (my recolle(une_ligne, tab) & return) to file mon_Rapport starting at eof
end if -- (|dernière| > 0) or
end if -- read file unFichier…
Delete the temporary csv file
tell application "System Events" to delete file csv_temporaire
end traiteunfichier
--=====
Creates a new iWork document from the Blank template and returns its name.
example:
set myNewDoc to my makeAnIworkDoc(theApp)
on makeAnIworkDoc(theApp)
local t, n
if theApp is "Pages" then
set commun to "iWork '" & my get_iWorkNum("Pages") & ":Pages.app:Contents:Resources:Templates:Blank.template:"
try
set t to ((path to applications folder as text) & commun) as alias
on error
set t to ("Western 2:Applications communes:iWork '" & commun) as alias
end try
else if theApp is "Numbers" then
set commun to "iWork '" & my get_iWorkNum("Numbers") & ":Numbers.app:Contents:Resources:Templates:Blank.nmbtemplate:"
try
set t to ((path to applications folder as text) & commun) as alias
on error
set t to ("Western 2:Applications communes:" & commun) as alias
end try
else
if my parleAnglais(theApp) then
error "The application “" & a & "“ is not accepted !"
else
error "l’application « " & a & " » n’est pas gérée !"
end if
end if
tell application theApp
set n to count of documents
open t
repeat until (count of documents) > n
delay 0.1
end repeat
set n to name of document 1
end tell -- theApp
return n
end makeAnIworkDoc
--=====
on dateTimeStamp()
return (do shell script "date +_%Y%m%d-%H%M%S")
end dateTimeStamp
--=====
Set the parameter delimiters which must be used in Numbers formulas
on getLocalized_Delimiters()
if character 2 of (0.5 as text) is "." then
return {",", ".", ";", ","}
else
return {";", ",", ",", "."}
end if
end getLocalized_Delimiters
--=====
on get_iWorkNum(a)
local verNum
tell application a to set verNum to item 1 of my decoupe(get version, ".")
if (a is "Numbers" and verNum is "2") or (a is "Pages" and verNum is "4") then
return "09"
else
return "11"
end if
end get_iWorkNum
--=====
Useful to get function's localized name if we need to build formulas
examples:
set OFFSET_loc to my getLocalizedFunctionName("Numbers", "OFFSET")
set ADDRESS_loc to my getLocalizedFunctionName(theApp, "ADDRESS")
set INDIRECT_loc to my getLocalizedFunctionName(theApp, "INDIRECT")
on getLocalizedFunctionName(theApp, x)
return my getLocalizedName(theApp, x, (path to application support as text) & "iWork '" & ¬
my get_iWorkNum(theApp) & ":Frameworks:SFTabular.framework:Versions:A:Resources:")
end getLocalizedFunctionName
--=====
on getLocalizedName(a, x, f)
tell application a to return localized string x from table "Localizable" in bundle file f
end getLocalizedName
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
on decoupe(t, d)
local TIDs, l
set TIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to TIDs
return l
end decoupe
--=====
on recolle(l, d)
local TIDs, t
set TIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set t to l as text
set AppleScript's text item delimiters to TIDs
return t
end recolle
--=====
replaces every occurences of d1 by d2 in the text t
on remplace(t, d1, d2)
local TIDs, l
set TIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d1
set l to text items of t
set AppleScript's text item delimiters to d2
set t to l as text
set AppleScript's text item delimiters to TIDs
return t
end remplace
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) vendredi 11 juin 2010 19:01:46 -
[Solved]conky autostart link using kdemod4.3x
I followed the arch wiki to install conky and the config works fine. The wiki says to autostart conky $ ln -s usr/bin/conky ~/.kde/share/autostart/conkylink. But I have .kdemod4 not .kde in my home directory. Trying the above link with ''.kdemod4" instead of ".kde" gave creating link /home/user/ ~/.kdemod4/share/autostart/conkylink "no such file or directory"
Looking at ~/.kdemod4>ls -aF shows ./ ../ Autostart/ cache-myhost@ share/ socket-myhost@ tmp-myhost@. Autostart is an empty dir. $ cd share shows apps/ config/ and kde4/ .
How do I create the correct conky link using kdemod4.3 to autostart conky? Or how to do same with SystemSettings > Advanced.>Autostart in KDE . Thanx:)
Last edited by lestoil (2009-08-17 21:10:37)Following another thread by 'pencuse' on 2008-05-12 under Desktop Environments suggested cd to ~/kdemod4/Autostart then ln -s /usr/bin/conky conky. Now @conky shows under ~/kdemod4/Autostart:).
Last edited by lestoil (2009-08-17 21:15:12)
Maybe you are looking for
-
TS3212 Files missing from my Itunes
Hi, I have tried to reinstall itunes but it keeps telling me that files are missing. It states 'Itunes drivers for importing and burning CD's and DVD's are missing. This can happen as a result of installing other CD-burning software. Please reinstall
-
How do i print pictures from a disc inserted into the Apple Superdrive connected to the 2011 MacBook Air by USB port? Thanks
-
Time out error in BI portal.
Hello All, When I am executing a report in BI portal, it is throwing time out error. Please find the below error. 500 Connection timed out Error: -5 Version: 7000 Component: ICM Date/Time: Thu Apr 8 03:08:22 2010 Module: icxxthr_mt.c Line: 2698 Serv
-
No audio cross dissolve in iMovie 10.0.8/Yosemite?
I know iMovie is not a professional editing solution, but I am baffled why I cannot cross-dissolve audio clips but I can do so with picture. Before the flamers start in on me, I am going to be teaching an editing class in an inner city magnet school
-
SNMP TRAP ON Secondary WLC 5508
Hi I'm Louis, I work on 2 WLC 5508 with version 7.4 and Prime Infrastructure 1.3 We have activate AP SSO to work with a primary and secondary controller. We have added the controller to Prime infrastructure and activated SNMP. We receive correctly th