Twitter Updates

Sep 8, 2009

Make TextWrangler Open Some Files using AppleScript

I wrote a script of AppleScript with TextWrangler to open some perl’s script files inside one document. The script will open some files that have extentions ‘.pl’ and ‘.pm’ in a folder you select. Every file in some nested folders is target.

You don’t need to drop the same folder since second time, only click the applet. The applet remembers the folder you dropped.

Before making the below script run, you may should check and rewrite bounds data of window in the fourth line from the bottom of script to adjust to your monitor.

property jobFolder : null

on open ARGV
  set jobFolder to item 1 of ARGV as alias
  run of me
end open

on run
  if jobFolder is null then
    set jobFolder to choose folder with prompt "Select a  folder including some perl’s script files."
  end if
  
  set targetFiles to {}
  getScriptFiles(jobFolder, a reference to targetFiles) of me
  openTextWranglerWindow(targetFiles) of me
end run

on getScriptFiles(jobFolder, targetFiles_ref)
  tell application "Finder"
    set scriptFiles to every item of jobFolder ¬
      whose ((name of it) ends with ".pm") or ((name of it) ends with ".pl")
  end tell
  repeat with a_file in scriptFiles
    set contents of targetFiles_ref to contents of targetFiles_ref & (a_file as alias) as list
  end repeat
  
  set innerFolders to {}
  tell application "Finder" to set innerFolders to every item of jobFolder whose (class of it) is folder
  if innerFolders is not {} then
    repeat with f in innerFolders
      getScriptFiles(f, targetFiles_ref) of me
    end repeat
  end if
end getScriptFiles

on openTextWranglerWindow(targetFiles)
  tell application "TextWrangler"
    activate
    open targetFiles opening in new_window with properties {bounds:{0, 20, 800, 1000}}
    set show documents drawer of text window 1 to true
  end tell
end openTextWranglerWindow

Aug 8, 2009

Libxml2 and LibXML Module

If we output a serialized XML node using a combination of Perl’s LibXML and libxml2 library which remain an environment installed from Leopard OS install DVD, Japanese of element contents are output as numeric character reference.

Two weeks ago, I wrote an entry about decoding with entities() of HTML::Entities module. When debugging a program, that doesn't matter. But when their decoded XML element are output as xml documents and we’ll use them, there is a problem. Example, it is the time when an InDesign document imports the XML document. After serializing with toString() if the result is decoded by decode_entities(), every general-entity reference will be replaced their characters; as ‘<’, ‘>’ and ‘&’. In that case, InDesign can’t accurately treat. I failed due to it.

Though, if both of libxml2 and Perl’s LibXML are updated, we’ll come good without decoding them.

I updated them yesterday. The libxml2’s version is 2.7.3 and I compiled it using a source file downloaded from xmlsoft.org. And the LibXML module is 1.69_2. I downloaded it from CPAN site without using CPAN module.

Jul 28, 2009

About an Alert Message of RegexKit.framework

In November last year, I wrote an entry about the RegexKit.framework on my another blog. A program I wrote returns correct results, but show an alert message, too.

CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary.

I couldn’t find the cause of it. I wonder how should I search the “missing semicolon” in the framework. I had trouble finding it. In the end, I couldn’t find it.

A few day ago, alex told me where is a file has the reason for the errors in.

The file /Developer/Local/Frameworks/RegexKit.framework/Versions/A/Resources/English.lproj/Localizable.strings is missing a semi colon on line 160.

Above the file path was hiding behind the side menu. I want you to join the following two lines,

/Developer/Local/Frameworks/RegexKit.framework/Versions/A
/Resources/English.lproj/Localizable.strings

The RegexKit’s version is 0.6.0 Beta. I edited line 160 as he say. Then, the error disappeared. Thank alex for his advice.

 
Cross the Sea - Templates Novo Blogger