Re: scripting bbedit "insert timestamp" menu item
Re: scripting bbedit "insert timestamp" menu item
- Subject: Re: scripting bbedit "insert timestamp" menu item
- From: Nigel Garvey via AppleScript-Users <email@hidden>
- Date: Thu, 30 May 2019 23:43:31 +0100
Rowland Carson wrote on Thu, 30 May 2019 18:05:56 +0100:
>In most PHP scripts I have a line near the top such as:
>
>$last_update = "2019-05-30, 15:55”;
>
>At the commit of every edit, I scroll up to the top of the file, select
the
>string between the quotes and choose Edit/Insert/Short time stamp. It
would
>save me a little time if I could automate that step in AppleScript.
>Obviously I can find the required string using GREP, but then I am
stuck. I
>cannot see anywhere in the BBEdit scripting dictionary a way to call the
>required menu item directly. I seem to recall that there is a way to
choose
>a specific menu item, but I can’t remember how to do it. I’m also
slightly
>nervous that if the BBEdit menu structure changes it would probably
foul up
>that type of script.
>
>Any suggestions?
Hi.
As far as I can see, that particular menu item in BBEdit inserts a time
stamp based on the User's preferences in System Preferences. Assuming
your preferences are set for short dates in the above form and for
24-hour time, you can make and insert your own time stamp like this:
tell (current date) to set timeStamp to its short date string & ", " & text 1
thru -4 of its time string
tell application "BBEdit"
tell text of window 1
replace "(?<=\\$last_update = \")[^\"]*+(?=\";)" using timeStamp options
{search mode:grep, starting at top:true}
end tell
end tell
NG
_______________________________________________
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