On Apr 10, 2007, at 5:32 PM, Christian Smith wrote:

On Tuesday, April 10, 2007, Bill Hernandez wrote:

So Now these includes work by using relative paths (aliases) from the default
templates folder which in  this case is  "~/bb_repository/" ...

Glad to hear you got it working.

--
Christian Smith

Christian,

ODDLY enough "insert clipping " uses a full path...

Best Regards,

Bill Hernandez
Plano, Texas

(*
-- +---------+---------+---------+---------+---------+--------- +---------+---------+ These few lines below SOLVE the problem using AppleScript WITH a full path..
        
        The code below is a simple demo for inserting text files...
-- +---------+---------+---------+---------+---------+--------- +---------+---------+ property g_src_filepath_text : "HardDisk:Users:dabney:Library:Application Support:BBEdit:Clippings:Applescript:Basic Header"
        
        set source_clipping_filepath_text to g_src_filepath_text
        
        set try_posix to true
        if (try_posix) then
set source_clipping_filepath_posix to POSIX path of source_clipping_filepath_text
                insert clipping POSIX file source_clipping_filepath_posix into 
w_ref
        else
                insert clipping file source_clipping_filepath_text into w_ref
        end if
*)

-- +---------+---------+---------+---------+---------+--------- +---------+---------+
on script_title()
        (*
                Author                          : Bill Hernandez

                ProjectNo               : 000
                ProjectName     : BB_INSERT_CLIPPING

                FileName                        : bb_insert_clipping.txt
FilePath : ~/scripting/AS_Studio/current_projects/ bb_insert_clipping.txt

                Version                         : 1.0.0
                VersionDate             : [ 2007_04_11 ]

                Created                 : Wednesday, April 11, 2007 ( 5:37 PM )
                Updated                 : Wednesday, April 11, 2007 ( 5:40 PM )
        *)
end script_title
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
on script_notes()
        (*
                INSERT_CONTENT_DESCRIPTION_HERE
        *)
end script_notes
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
on script_about_this_framework()
        (*
                -- [1000] General purpose properties used with most projects
                -- [2000] Properties required to load, and use any of the 
libraries.
-- [3000] Properties specific to this project, not needed by the libraries.

                -- [4000] ass - handlers - Application events
                -- [5000] ass - handlers - plist_prefs - project generic 
settings
                -- [5200] ass - handlers - plist_prefs - project specific 
settings
                -- [5400] ass - handlers - plist_prefs - bbedit specific 
settings
-- [6000] ass - handlers - Specific to this project, will not be added to the libraries. -- [7000] ass - handlers - Generic, that can later be added to, and used from the library -- [7000] ass - handlers - Generic, that are not best run from a library, such as the error, and log handlers -- [7000] ass - handlers - Generic, that call interface items and cannot easily run from a library -- [8000] ass - handlers - Required by every project that does not use libraries -- [9000] ass - handlers - Required to verify the framework, and load the libraries
        *)
end script_about_this_framework
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
on script_function_names()
        (*

        *)
end script_function_names
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
on script_misc_related()
        (*

        *)
end script_misc_related
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
-- [2970] Properties required for this project
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
property bh_debug_me : false -- normally set to false
property bh_debug_test_error_handlers : false -- normally set to false
property bh_debug_msg_stays_open : 10
property bh_debug_insert_clipping_and_update_page_automatically : not bh_debug_me -- +---------+---------+---------+---------+---------+--------- +---------+---------+
property g_continue : true

property g_section_divider : "-- +---------+---------+--------- +---------+---------+---------+---------+---------+"
property g_search_and_replace_divider : g_section_divider & return

property g_src_clip_text : "AS_Clips:Basic Header"
property g_src_filepath_text : "HardDisk:Users:dabney:Library:Application Support:BBEdit:Clippings:Applescript:Basic Header" -- +---------+---------+---------+---------+---------+--------- +---------+---------+
on run
        tell application "BBEdit"
                activate
                set w_ref to text window 1
                if (bh_debug_insert_clipping_and_update_page_automatically) then
                        tell w_ref
                                set w_props to get properties
                                set w_file to file of w_props
                                select line 1
                                set theLine to the selection as string
                                select insertion point before the selection
                                if (theLine is not equal to 
g_search_and_replace_divider) then
                                        set selection to 
g_search_and_replace_divider
                                        select line 1
                                        select insertion point before the 
selection
                                end if
                        end tell
                end if
                
                try
                        -- THIS NEXT LINE GENERATES AN UNEXPECTED ERROR
                        insert clipping g_src_clip_text into w_ref
                on error errorMsg number errorNo
set str to "Ooops, that didn't work." & return & return & "There was no insertion at this time..." & return & return & errorMsg & return & "error number " & errorNo
                        my bh_debug_ShowDebugMessage(str, 0)
                        try
                                set source_clipping_filepath_text to 
g_src_filepath_text
                                
                                set try_posix to true
                                if (try_posix) then
set source_clipping_filepath_posix to POSIX path of source_clipping_filepath_text insert clipping POSIX file source_clipping_filepath_posix into w_ref
                                else
                                        insert clipping file 
source_clipping_filepath_text into w_ref
                                end if
                                
set str to "Hallellujah!" & return & return & "Happiness is a positive insertion..." & return & return
                                my bh_debug_ShowDebugMessage(str, 0)
                                
                                -- THIS NEXT HANDLER GENERATES AN INTENTIONAL 
ERROR
-- theNo is UNDEFINED here so trapping for the "if (theNo = missing value) then"
                                -- will take care of it, and establish a default 
value"
                                my bh_debug_GenerateAnError(theNo)
                        on error errorMsg number errorNo
set str to "Ooops, that didn't work either." & return & return & "Perhaps more training is in order..." & return & return & errorMsg & return & "error number " & errorNo
                                my bh_debug_ShowDebugMessage(str, 0)
                        end try
                end try
                if (bh_debug_insert_clipping_and_update_page_automatically) then
                        if (w_file is not equal to missing value) then
                                try
                                        update w_file
                                on error errorMsg number errorNo
set str to "Ooops, that didn't work either." & return & return & "Perhaps more training is in order..." & return & return & errorMsg & return & "error number " & errorNo
                                        my bh_debug_ShowDebugMessage(str, 0)
                                        
                                end try
                        else
set str to "Ooops, the file needs to be saved before it can be updated." & return & return
                                my bh_debug_ShowNormalMessage(str, 20, "BBEdit")
                        end if
                end if
                
        end tell
end run
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
on bh_debug_ShowDebugMessage(str, howLong)
        if (howLong = 0) then
                set howLong to bh_debug_msg_stays_open
        end if
        if (bh_debug_me) then
                tell me
display dialog str buttons {"Continue..."} default button {"Continue..."} giving up after howLong
                end tell
        end if
end bh_debug_ShowDebugMessage
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
on bh_debug_ShowNormalMessage(str, howLong, theApp)
        if ((theApp = "") or (theApp = missing value)) then
                tell me
                        if (howLong = 0) then
                                set howLong to bh_debug_msg_stays_open
                        end if
display dialog str buttons {"Continue..."} default button {"Continue..."} giving up after howLong
                end tell
        else
                tell application theApp
                        if (howLong = 0) then
                                set howLong to bh_debug_msg_stays_open
                        end if
display dialog str buttons {"Continue..."} default button {"Continue..."} giving up after howLong
                end tell
        end if
end bh_debug_ShowNormalMessage
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
on bh_debug_GenerateAnError(theNo)
        if ((theNo = "") or (theNo = 0) or (theNo = missing value)) then
                set theNo to -1234 -- generate an arbitrary error number
        end if
        if (bh_debug_me) then
                if (bh_debug_test_error_handlers) then
                        error number theNo
                end if
        end if
end bh_debug_GenerateAnError
-- +---------+---------+---------+---------+---------+--------- +---------+---------+


--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to