Re: scripting bbedit "insert timestamp" menu item
Re: scripting bbedit "insert timestamp" menu item
- Subject: Re: scripting bbedit "insert timestamp" menu item
- From: Rowland Carson via AppleScript-Users <email@hidden>
- Date: Fri, 31 May 2019 05:12:14 +0100
On 2019-05-30, at 23:43, Nigel Garvey via AppleScript-Users
<email@hidden> wrote:
> 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
Nigel - thanks for your message. I was obviously focussing too narrowly on what
I could do in BBEdit and didn’t realise I could construct my own timestamp from
within AppleScript. Your sample script works perfectly for me - thank you for
taking the trouble to construct & post it.
in friendship
Rowland
| Rowland Carson ... that's Rowland with a 'w' ...
| <email@hidden> http://www.rowlandcarson.org.uk
| Skype, Twitter: rowland_carson Facebook: Rowland Carson
_______________________________________________
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