Loading ...
Sorry, an error occurred while loading the content.
 

Moving things around with clips

Expand Messages
  • John Shotsky
    This is one thing I have never been able to figure out, but the time has come where no alternative exists.and I need to learn anyway. I need to be able to move
    Message 1 of 3 , May 4, 2009
      This is one thing I have never been able to figure out, but the time has come where no alternative exists.and I need to
      learn anyway.

      I need to be able to move chunks of text from one place to another within a defined set of delimiters.

      These happen to be recipes, which makes it easier to explain what is needed than a generic example would provide.

      In some instances, tools that import recipes must have the recipe parts in a specific order. There can be many recipes
      in a single file, but only part of them need to be modified. The ones to be modified are lacking a specific identifier
      that describes what format they are in, so those need to be put into a specific order and given a tag to identify them.

      As in my previous example, the delimiters are [[[ recipe ]]]. What I'd like to do is parse a single recipe, storing into
      variables anything to be moved, the ingredients (multiple lines) the directions (one to multiple paragraphs).

      Within the delimiters, the title will always be found first, so we have both a starting delimiter and a title as two
      known elements. The section after the ingredients, until the final delimiter is the directions, along with any other
      stuff that will be moved to the end. In some recipes, there are things between the title and the ingredients, and those
      are what need to be moved. Example below.

      Note that it is possible to tag the ingredients start point and directions start point before processing, if that helps
      the solution. Actually, each item could be tagged first, if that helps, then the tags could be removed after processing.

      [[[
      Recipe Title
      Move Line 1. Line to be moved after Directions 2.

      Move Line 2. Another line to be moved after Directions 2.
      Optional ingredient label.
      1 ingredient
      2 ingredients
      3 ingredients
      Optional directions label.
      Directions 1. A whole paragraph.

      Directions 2. A whole paragraph.

      ]]]

      After processing:
      [[[
      @@@@@ <identifier that denotes that the file has been processed.
      Recipe Title

      1 ingredient
      2 ingredients
      3 ingredients

      Directions 1. A whole paragraph.

      Directions 2. A whole paragraph.

      Moved Line 1. Line moved after Directions 2.

      Moved Line 2. Another line moved after Directions 2.
      ]]]

      One way to do it would be to store each item, including the final delimiter into variables, then 'print' them back in
      place of the original. I envision doing that by creating a final variable that contains the entire recipe in the correct
      order, then replacing the original recipe with that variable. That's quite a bit past my skill set.

      Later, I'll extend the solution to more items to move.recipes come in many flavors, I've even seen them with the
      directions preceding the ingredients. I'll always be able to identify and tag these sections, so a generic a solution
      should work for any of them.

      To this point, I have always managed to just tag things so they could be moved by another tool, but in this case, the
      applicable tool will only accept the recipes if they are in the specified order, so that it can recognize them as
      recipes. Can anyone help? (I have sample files with real recipes available to work with.).

      Thanks!

      John Shotsky
      100 SW 195th Avenue Unit 155
      Beaverton, OR, 97006-2233
      shotskyftp.gotdns.com
      ftp://shotskyftp.gotdns.com <ftp://shotskyftp.gotdns.com/>



      [Non-text portions of this message have been removed]
    • Axel Berger
      ... A very rough draught: 1) Do a Regex Find with braces to highlight exactly the part you mean. 2) Set a variable to the highlighted part. 3) Use variables as
      Message 2 of 3 , May 4, 2009
        John Shotsky wrote:
        > storing into variables anything to be moved

        A very rough draught:

        1) Do a Regex Find with braces to highlight exactly the part you
        mean.
        2) Set a variable to the highlighted part.
        3) Use variables as indicated.

        Axel
      • Alec Burgess
        John Shotsky (jshotsky@comcast.net) wrote (in part) (on 2009-05-04 at ... Question: Are Move Line nnn. and Directions nnn. the actual tags found in the
        Message 3 of 3 , May 4, 2009
          John Shotsky (jshotsky@...) wrote (in part) (on 2009-05-04 at
          07:58):
          > [[[
          > Recipe Title
          > Move Line 1. Line to be moved after Directions 2.
          >
          > Move Line 2. Another line to be moved after Directions 2.
          > Optional ingredient label.
          > 1 ingredient
          > 2 ingredients
          > 3 ingredients
          > Optional directions label.
          > Directions 1. A whole paragraph.
          >
          > Directions 2. A whole paragraph.
          >
          > ]]]
          >
          > After processing:
          > [[[
          > @@@@@ <identifier that denotes that the file has been processed.
          > Recipe Title
          >
          > 1 ingredient
          > 2 ingredients
          > 3 ingredients
          >
          > Directions 1. A whole paragraph.
          >
          > Directions 2. A whole paragraph.
          >
          > Moved Line 1. Line moved after Directions 2.
          >
          > Moved Line 2. Another line moved after Directions 2.
          > ]]]
          >
          > One way to do it would be to store each item, including the final
          > delimiter into variables, then 'print' them back in
          > place of the original. I envision doing that by creating a final
          > variable that contains the entire recipe in the correct
          > order, then replacing the original recipe with that variable. That's
          > quite a bit past my skill set.
          >
          > Later, I'll extend the solution to more items to move.recipes come in
          > many flavors, I've even seen them with the
          > directions preceding the ingredients. I'll always be able to identify
          > and tag these sections, so a generic a solution
          > should work for any of them.
          >
          > To this point, I have always managed to just tag things so they could
          > be moved by another tool, but in this case, the
          > applicable tool will only accept the recipes if they are in the
          > specified order, so that it can recognize them as
          > recipes. Can anyone help? (I have sample files with real recipes
          > available to work with.).
          >
          Question: Are "Move Line nnn. " and "Directions nnn." the actual tags
          found in the original files to be converted?

          Sounds like an interesting text processing job. If you could put up a
          zip containing two files in
          http://tech.groups.yahoo.com/group/ntb-clips/files/Help_wanted/ showing
          (1) 3 or 4 source recipes (I'm assuming each file has more than one
          recipe based on your previous question?)
          (2) the source file converted to desired output format.

          I'll have a look at it if someone else doesn't beat me to it :-)
          Axel's suggestion sounds like the way I'd approach it too. Another
          approach that might be workable would be to grab each individual recipe
          (stuff between delimiters) - transfer it to new file/buffer, then prefix
          lines so that a standard sort will move the "Move Line nnn." below the
          corresponding Directions nnn." then strip the created prefixes and
          finally move the revised recipe back to original location.

          --
          Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)




          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.