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

Forming strings from separate lines

Expand Messages
  • John Shotsky
    I have encountered a situation where data from from a 2-line table ends up with each data element on a separate line. I d like to format them as indicated.
    Message 1 of 2 , Sep 3, 2009
      I have encountered a situation where data from from a 2-line table ends up with each data element on a separate line.
      I'd like to format them as indicated.

      Input data:
      Servings
      Prep. Time
      Cooking Time
      Calories
      % from Fat
      Fat
      Sodium
      Carbohydrates
      Protein
      Cholesterol
      6
      N/A
      N/A
      475
      21
      N/A
      N/A
      N/A
      N/A
      N/A

      Desired output:
      Servings: 6
      Prep. Time: N/A
      Cooking Time: N/A
      Calories: 475; % from Fat: 21; Fat: N/A; Sodium: N/A; Carbohydrates: N/A; Protein: N/A; Cholesterol: N/A

      Of course, sometimes it won't be N/A, but the actual value, of variable length, such as 125mg. Also, there may be a
      different number of elements, though I haven't seen any examples of that yet.

      Ideas?
      Thanks!
      John




      [Non-text portions of this message have been removed]
    • Hugo Paulissen
      ... Hi John, If you have the table data in a separate document, with no trailing blank lines, this should work (well, it does for me). ^!ClearVariables ^!Set
      Message 2 of 2 , Sep 4, 2009
        > I have encountered a situation where data from from a 2-line
        > table ends up with each data element on a separate line.
        > I'd like to format them as indicated.
        >
        > Of course, sometimes it won't be N/A, but the actual value,
        > of variable length, such as 125mg. Also, there may be a
        > different number of elements, though I haven't seen any examples
        > of that yet.
        >
        > Ideas?

        Hi John,

        If you have the table data in a separate document, with no trailing blank lines, this should work (well, it does for me).

        ^!ClearVariables
        ^!Set %StopAt%=^$Calc(^$GetLineCount$/2)$
        ^!Jump 1
        ^!Set %NewLine%=^$getLine$: ^$getLine(+^%StopAt%)$
        ^!Jump +1
        ^!Append %Recipe%=^%NewLine%^%NL%
        ^!If ^$GetRow$>^%StopAt% INSERT
        ^!Goto Skip_-4
        :INSERT
        ^!Select All
        ^%Recipe%

        Hugo




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