Choosing which line to copy with AppleScript

Hi guys,
I am having a simple problem making applescript choose which line from a textwrangler document to copy. It's very simple, all I want it to do is the following.
1)Check to see if line 22 is just a carriage return
2) If it is, copy line 13 to the clipboard
3) If it's not, copy line 22 to the clipboard
My current code is this:
tell application "TextWrangler"
     activate
     if contents of line 22 of window 1 is "\r" then <--this is really two backslashes before the r
               copy line 13 of window 1
     else
               copy line 22 of window 1
     end if
end tell
Any help would be appreciated.
Thanks!
Cameron

Hi
The contents of a line does not contain *end of line*, you must verify that the line is empty.
tell application "TextWrangler" to tell window 1
if contents of line 22 is "" then
copy line 13
else
copy line 22
end if
end tell

Similar Messages

  • Choose which ANE to import with compiler constants

    Hi,
    I've released a iOS app and I would like to upload a Android version.
    In order to do that, I've created two compiler constants: CONFIG::ANDROID and CONFIG::IOS.
    I'm having problems when I try to choose which ANE import in a class. Basically, the import does not work if it's inside a if.
    In the code sample mobile.LIB is loaded but com.myane is not when CONFIG::IOS is set to true
    CONFIG::IOS
      import com.myane.*;
      import mobile.LIB;
    If I remove the first line of the code everything works fine.
    Does anybody know if there is a issue with ANE and compile constants in Adobe Air?
    thanks!

    There is a Adobe Air bug (reported) with this issue, routes with asterisks fail inside a condition in compiler time.
    Solution:
    CONFIG::IOS{
    import com.myane.stuff1;
    import com.myane.stuff2;
    import com.myane.stuff3;
    import com.myane.stuff4;}

  • How to choose which specs to get with 15 inch rMBP

    I want to make the transition from a PC to my first mac and looking at the 15 inch rMBP. I just dont know which specs to consider upgrading or if the base model is the right one for me. I need a new computer for school and I am a general use computer user: school documents/presentations, online research (multiple open tabs), and a normal amount of video streaming. I think my use falls into the base model range, but I just dont want to get stuck with not enough. Is there a decent way to help decide?
    Thanks

    I am currently running about a 5 y/o Dell studio. It has done everything I needed so far. I need to uprgrade bcs the school I will be attending has software that my computer wont support it (I dont know what that means bcs im not computer literate). Over time my machine has been slowing and "not responding" might be a once a day occurence when multiple tabs are open and streaming video. current machine specs are:
    Intel Core 2 Duo Processor 2.2GHz
    4GB DDR2 RAM
    320GB Hard Drive
    Windows 7 Home Premium (64-bit)
    I dont know how or if I can check how much of the memory i have used up, but judging by these specs I think the base model might be the best option. I am not huge into pic/video editing but may have a need for it occasionally.
    Also, I dont need to purchase for a couple of months, would it be best to wait and see what apple does in the next couple months, i know speculation, or should I just get it and start getting used to the transition from PC to Mac.
    again thanks

  • How do I repair lines when copying with my LaserJet 3050?

    It is not my scanner I check it and it works fine, the problem is where the print itself is created. Almost like something is stuck like dirt or dust and it places it on every copy I make?
    Thanks for your help!
    Have A Great Day!
    stormin

    Hi stormin54, 
    What is the model number of your printer?
    I am an HP employee.
    Say Thanks by clicking the Kudos Star in the post that helped you.
    Please mark the post that solves your problem as "Accepted Solution"

  • HT4889 can I choose which applications to transfer with migration assistant?

    I do not want to transfer all my applications from my old Mac Book Pro.  (like Toast or DVD Studio since there is no DVD burner and other apps that I don't use)
    Is there a way to customize the transfer to pick just the Applications I want using Migration Assistant or something else?

    It will transfer ALL applications except the older versions of the standard apps. Just delete them after the transfer.

  • Generating signal from the 5412 which is in sync with the external signal

    Hi,
    I am using the 5412 AWG. An external signal comes from the test unit. I need to generate a signal to the test unit which should be in synchronous with external signal which comes from the test unit. Can anyone help in this?
    Regards,
    Rajashekar

    Hi Rajashekar,
    You could synchronize these two signals by sharing a start trigger and using the input signal from your test unit as the sample clock for the 5412.  There are some considerations when doing this that can be seen in the External Sample Clock Considerations section of the 5412 help linked below:
    External Sample Clock Sources
    If you are using LabVIEW, you can find examples in the Example Finder located at Help >> Find Examples.  The FGEN examples are located at Hardware Input and Output >> Modular Instruments >> NI-FGEN >> Arbitrary Waveform Generation.  You can choose which line to use as the sample clock.  You will also need to add in some triggering.  You can find an example of triggering at  Hardware Input and Output >> Modular Instruments >> NI-FGEN >> Synchronization >>FGEN DAQmx Synchronization.vi.  This is synchronizing to a DAQ card, but you can synchronize to your external signal just the same way, i.e., sharing a start trigger and a reference clock.
    Regards,
    Jim Schwartz

  • How do I choose which space should "Reminders" open in?

    I was reading the support page (http://support.apple.com/kb/PH11158?viewlocale=en_US) to learn how to choose which spaces to use with particular apps. But what is said at the suport page doesn't applies to the app "Reminders".
    Someone can teach me how to set up "reminders" to open on the second desktop spaces?

    go to Desktop 2

  • Several contacts have the same email address. How can I choose which contact name appears on the address line in Mail?

    Several contacts have the same email address. How can I choose which contact name appears on the address line in Mail?

    you can't really, but you might be able to filter them by message content into folders for each, or color them with tags

  • I am using InDesign CS5. I have a body of text which is ranged left with tabbed indents. My client now wants the copy to be justifed, keeping the tabbed indents. Help and advice needed please!

    I am using InDesign CS5. I have a body of text which is ranged left with tabbed indents. My client now wants the copy to be justifed, keeping the tabbed indents. Help and advice needed please!

    Hi
    That screen grab helps a lot. There’s a much easier way of doing what you’re doing.
    Remove all your tabs and set the text in justified paragraphs.
    I’ve typed in dummy text in the example I made below, but after “19.1” put in a space and put your blinking cursor after the space and before the ’N’ of ‘Notices'.
    Then hold down the Command key and hit Backspace (on Mac at least - it’s the key between the Inverted commas/ apostrophe key and the return key).
    The text will jump into place the way you want it to.
    Hope that helps
    Paul
    PS You can set a tab, instead of using a space, in the description I gave above. So, after 19.1 or 19.2 or 19.185 etc etc insert a tab, then hit the Command Backspace after every paragraph number and they'll all line up exactly together. You'll find that editing text within the paragraphs
    after you've set it will be LOADS easier this way.
    You can put the tab anywhere you want it to be using 'Command-ShiftT' and putting a 'left align' tab just after the number. Just type the Command Backspace after the paragraph number and it'll work

  • HT4597 Can I just choose which apps or photos to sync via iCloud since I don't want all of them in all my devices?  I have all photos & apps in my iMac but only sync manually some of them to my iPad and to my iPhone. Can I still do this with iCloud?

    I have 3 Apple devices - iMac, iPhone, and iPad.  I am planning to move to iCloud from MobileMe.  In iTunes, I just choose to sync whatever files I want my iPhone and iPad to have since they don't have sufficient disk space as my iMac. 
    Can I just choose which apps or photos to sync via iCloud since I don't want all of them in my iPhone and iPad?  I have all photos & apps in my iMac but only sync manually some of them to my iPad and to my iPhone. Can I still do this with iCloud?
    Calendars, emails, contacts, are fine since files are small.  What I'm afraid of are the apps and photos.
    Any reply will be appreciated.
    Thanks.

    With the exception of photo stream, iCloud doesn't sync your apps or photos between devices. You will continue to sync this content via iTunes in the same way as you do now.
    Photo stream allows you to sync your most recent photos between all devices, you have the option to use photostream or not.

  • The report in FI which contains Quantity field with every line item

    Hi Gurus,
    What are the reports in Finance which contains Qty field with every Line Item reports & reports that contains user name & System Id in it along with other informations e.g. G/L, Ar, AP
    Thanks & Regds,
    Santosh Rothe

    Hi
    Using the line item display report you can get the required details by changing layout in the output:
    FBL1N: Vendor line item
    FBL3N: G/L line item
    FBL5N: Customer line item
    VVR

  • Since changing over to Mountain Lion I discover that I am no longer able to adjust spaces between lines. If I choose spacing of 1.3 after two lines single-spaced, the entire previous lines end up with 1.3 spacing. What am I missing?

    Since changing over to Mountain Lion I discover that I am no longer able to adjust spaces between lines. If I choose spacing of 1.3 after two lines single-spaced, the entire previous lines end up with 1.3 spacing. What am I missing?

    Do those previous lines have a Return/Linefeed after them, or are they just wrapped to a new line?
    What App is it you're using?

  • How to choose which one to use when using handoff if one has more than one phone with different network

    I am using 2 iPhone with 2 different network. How to choose which phone to use when making a call.

    Are you confirming your POP account is selected as the sending email account before the message is sent?
    And regardless if the email is a new email or is replying to or forwarding an email received by the POP account and cofirming the POP acconut is selected as the sending email account, the message is sent by the Gmail account?
    All message sent by the POP account are sent by the Gmail account?
    If so, delete the Gmail account from your iPad and test if a message sent with your POP account which will be the only email account available with the iPad's Mail app is recieved from your POP account/address.
    If not, something else is wrong or on play that has nothing to do with the iPad.

  • Choosing which folder to save downloaded files to as soon as file is downloaded?

    I'm completely new to this so if there's a simple solution to this, do forgive me and thanks in advance for your patience!
    So I've just started messing about with Automator today and read about Applescript.
    I'm basically trying to find a way of having a prompt for me to select which folder I'd like to save downloaded files to, as soon as the files are downloaded into that folder.
    I've tried a couple of things:
    Setting up a Folder Action in Automator for my Downloads folder.
    'Revealing items in Finder'
    'Get selected items in Finder' (thinking that this somehow grabs the items that were revealed and selected in the previous step)
    Then running an Applescript (as an 'action' in Automator) to do something like this:    
    on adding folder items to this_folder after receiving these_items
      tell application "Finder"
      set the destination_folder to [choose folder with prompt choose folder]
      end tell
    end adding folder items to
    Or something like this:
    on run {input, parameters}
      tell application "Finder"
      select files
      move files to [choose folder with prompt choose folder]
      end tell
      return input
    end run
    As you can probably tell, I really haven't a clue (although this is addictive and I can't deny I'm enjoying myself)... I've tried a few more variations based on scripts I've seen dotted around the web doing similar things but I didn't hold on to them so I can't show you them. The script  actually runs really smoothly, and runs through with no errors - I copy a file into my downloads folder (to test) from another folder. The Downloads folder opens up automatically, selects and shows me the file I've just added then pops up with the window prompting me to choose a folder. It's just that when I do end up choosing the folder, the file doesn't move at all. The window disappears then pops back up again, then disappears after I press 'Choose' for the second time, as though something has happened. I suppose the files that the Finder revealed, selected and 'got' had no connection to the following action/script?
    What do I need to change? As I said, completely new to all of this so please do treat me like I'm a bit stupid!
    Thanks!

    Others have already given alternative pointers to solve your specific problem, but I can understand the desire to roll your own
    From your script samples, you're on the right track, but are missing a couple of key concepts. I'll try to clarify.
    Your script:
    on adding folder items to this_folder after receiving these_items
      tell application "Finder"
      set the destination_folder to [choose folder with prompt choose folder]
      end tell
    end adding folder items to
    First up, let's correct that 'choose folder' command. Specifically, the prompt - it should be a string (enclosed in quotes). As it stands, conceptually, you're kind of invoking 'choose folder' again, and the result of that is used as the prompt on the first 'choose folder'. Not going to work so well.
    Instead, your choose folder should look more like:
      set the destination_folder to choose folder with prompt "Select a folder:"
    Note how I've quoted the text and now it's interpreted correctly - the selected folder will now be stored in destination_folder.
    Now that you have the destination folder, what you need is the files to move. Fortunately, Folder Actions provide this for you in the way the command is called:
    on adding folder items to this_folder after receiving these_items
    In this case, these_items is a list of the newly added files., so all you need to do is move these files to the destination_folder:
    on adding folder items to this_folder after receiving these_items
      set the destination_folder to choose folder with prompt "Select a folder:"
      tell application "Finder"
      move these_items to folder destination_folder
      end tell
    end adding folder items to
    Note how I've moved the 'choose folder' line outside of the 'tell application "Finder"' block - there's no need for it to be in there, and this way it will prevent the context switch where the Finder comes active to ask you for the folder.
    Incidentally, this is a 'pure' AppleScript implementation, not an Automator action. The Automator action would be radically different in that the files would be passed into your workflow - you'd need to store these in a variable, then prompt for the destination folder and store that in another variable, then use the move Finder items action to move the files, like:
    Personally, I prefer the AppleScript option

  • BAPI SALES ORDER & Copy with reference

    Hello,
    I'm creating sales order copied with reference to an invoice. My problem is that the data item is empty. When I create the sales order manually and use the option 'Create with reference' and choose an invoice, the sales order is created with all data item. I don't know how I can get to copy the data item from the invoice in the new sales order. The code that I'm using is the following:
    DATA: order_header_in      LIKE bapisdhd1,
          order_partners       LIKE bapiparnr OCCURS 0 WITH HEADER LINE,
          order_text           LIKE bapisdtext OCCURS 0 WITH HEADER LINE,
          order_header_inx     LIKE bapisdhd1x,
          order_item_in        LIKE bapisditm OCCURS 0 WITH HEADER LINE,
          order_schedules_in   LIKE bapischdl OCCURS 0 WITH HEADER LINE,
          order_conditions_in  LIKE bapicond OCCURS 0 WITH HEADER LINE,
          extensionin          LIKE bapiparex OCCURS 0 WITH HEADER LINE,
          partneraddresses     LIKE bapiaddr1 OCCURS 0 WITH HEADER LINE,
          order_cfgs_ref       like BAPICUCFG occurs 0 with header line.
    DATA: salesdocument LIKE bapivbeln-vbeln.
    DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    order_header_in-doc_type   = 'ZA09'.
    order_header_in-sales_org  = '1700'.
    order_header_in-distr_chan = '01'.
    order_header_in-division   = '01'.
    order_header_in-BILL_DATE   = '20060701'.
    order_header_in-ref_doc    = '0900000019'.
    order_header_in-refdoc_cat = 'M'.
    *order_header_in-REF_DOC_L_LONG = '0900000019'.
    order_header_in-purch_no_c  ='prueba'.
    *order_header_in-ord_reason = '003'.
    *order_header_in-pmnttrms   = '0002'.
    *order_header_in-sales_off  = '2800'.
    order_header_in-ref_doc_l  = 'FACTURA ES'.
    *order_header_in-fix_val_dy = '20060701'.
    *order_header_in-currency   = 'USD'.
    *order_header_in-exchg_rate = '1.2'.
    order_partners-partn_role = 'AG'.
    order_partners-partn_numb = '0000000001'.
    order_partners-langu      = 'EN'.
    order_partners-name       = 'El corte aleman'.
    order_partners-country = 'ES'.
    APPEND order_partners.
    order_partners-partn_role = 'RE'.
    order_partners-partn_numb = 'ARR000'.
    order_partners-addr_link  = '0000030044'.
    APPEND order_partners.
    CALL FUNCTION 'ADDR_GET_COMPLETE_ALL_TYPES'
      EXPORTING
        addrnumber                 = order_partners-addr_link
      PERSNUMBER                 =
        address_object_type        = '1'
      IV_CURRENT_COMM_DATA       = 'X'
    IMPORTING
      ADDR1_COMPLETE             =
      ADDR2_COMPLETE             =
      ADDR3_COMPLETE             =
       ADDR1_COMPLETE_BAPI        = partneraddresses
      ADDR2_COMPLETE_BAPI        =
      ADDR3_COMPLETE_BAPI        =
    EXCEPTIONS
      PARAMETER_ERROR            = 1
      ADDRESS_NOT_EXIST          = 2
      PERSON_NOT_EXIST           = 3
      INTERNAL_ERROR             = 4
      OTHERS                     = 5
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    data: vl_texto(40) value 'NUEVOOOOO'.
    partneraddresses-name    = vl_texto. clear vl_texto.
    partneraddresses-name_2  = vl_texto.
    partneraddresses-name_3  = vl_texto.
    partneraddresses-name_4  = vl_texto.
    partneraddresses-langu   = 'E'.
    APPEND partneraddresses.
    DATA: vl_cantidad LIKE bapisditm-target_qty.
    vl_cantidad = 1.
    order_item_in-itm_number = 10.
    order_item_in-material = 'HONORARIOS'.
    order_item_in-ref_doc = '0900000019'.
    order_item_in-ref_doc_it = 10.
    order_item_in-ref_doc_ca = 'M'.
    APPEND order_item_in.
    order_schedules_in-itm_number = 10.
    order_schedules_in-req_qty = vl_cantidad.
    APPEND order_schedules_in.
    order_text-text_id = 'Z001'.
    order_text-ITM_NUMBER = ''.
    order_text-langu = 'EN'.
    order_text-text_line = 'Hola, CARACOLAcola'.
    APPEND order_text.
    order_text-text_id = 'Z001'.
    order_text-langu = 'EN'.
    order_text-text_line = 'Adios caracol'.
    APPEND order_text.
    order_text-itm_number = '000010'.
    order_text-text_id = '0001'.
    order_text-langu = 'EN'.
    order_text-text_line = 'Hola, POSICIÓN'.
    APPEND order_text.
    extensionin-structure = 'BAPE_VBAK'.
    extensionin-valuepart1 = '          BCL  7'.
    APPEND extensionin.
    order_cfgs_ref-posex = '10'.
    order_cfgs_ref-config_id = '10'.
    order_cfgs_ref-root_id = '00000001'.
    append order_cfgs_ref.
    CALL FUNCTION 'ZBAPI_SALESORDER_CREATEFROMDT2'
      EXPORTING
       SALESDOCUMENTIN               =  salesdocument
        order_header_in               =  order_header_in
       ORDER_HEADER_INX              =  order_header_inx
      SENDER                        =
      BINARY_RELATIONSHIPTYPE       =
      INT_NUMBER_ASSIGNMENT         =
      BEHAVE_WHEN_ERROR             =
      LOGIC_SWITCH                  =
      TESTRUN                       =
      CONVERT                       = ' '
    IMPORTING
       salesdocument                 = salesdocument
      TABLES
        return                        = return
        order_items_in                = order_item_in
      ORDER_ITEMS_INX               =
        order_partners                = order_partners
        order_schedules_in            = order_schedules_in
      ORDER_SCHEDULES_INX           =
        order_conditions_in           = order_conditions_in
      ORDER_CONDITIONS_INX          =
        ORDER_CFGS_REF                = order_cfgs_ref
      ORDER_CFGS_INST               =
      ORDER_CFGS_PART_OF            =
      ORDER_CFGS_VALUE              =
      ORDER_CFGS_BLOB               =
      ORDER_CFGS_VK                 =
      ORDER_CFGS_REFINST            =
      ORDER_CCARD                   =
        order_text                    = order_text
      ORDER_KEYS                    =
       extensionin                   = extensionin
        partneraddresses              = partneraddresses
    PERFORM  report TABLES return.
    *DATA: salesdocument LIKE bapivbeln-vbeln.
    *DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    *refresh return.
    *CALL FUNCTION 'BAPI_SALESDOCUMENT_COPY'
    EXPORTING
       salesdocument          = '0400000191'
       documenttype           = 'ZA04'
      TESTRUN                = ' '
    IMPORTING
       SALESDOCUMENT_EX       = salesdocument
    TABLES
       RETURN                 = return
    *PERFORM  report TABLES return.
    *write: / salesdocument.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT          =
    IMPORTING
      RETURN        =
    *&      Form  report
          text
         -->P_MENSAJE  text
    FORM report  TABLES   p_mensaje STRUCTURE bapiret2.
      DATA: vl_mensaje TYPE string.
      LOOP AT return.
        CLEAR vl_mensaje.
        MESSAGE ID     return-id
                TYPE   return-type
                NUMBER return-number
                INTO   vl_mensaje
                WITH   return-message_v1
                       return-message_v2
                       return-message_v3
                       return-message_v4.
        WRITE: / vl_mensaje.
      ENDLOOP.
    ENDFORM.                    " report

    Hi Manuel,
    There are some function modules which is there to copy the order details. I am not sure about the function module name. But you can search in SE37. But bapi for creating the sales order does not have the functionality of copying the data from one document to another document.
    You can try using this function module.
    BAPI_SALESDOCUMENT_COPY
    Data will be copied based on the copy control routines that is set between the two document types.
    Thanks,
    Arun

Maybe you are looking for