メインコンテンツまでスキップ
バージョン:25.2

merge

  • function
  • The merge function will scan a text string for SenseTalk variables or expressions enclosed in double-square-brackets ( [[ and ]] ) and replace those expressions with their values:
         put merge("A week has [[24*7]] hours") 
—> "A week has 168 hours"

    In addition to expressions, the embedded code may include full SenseTalk statements, including repeat loops:

     put ("apple", "banana", "orange", "pineapple") into list
put merge(<<List contains the following items:[[
repeat with n = 1 to the number of items in list]]
Item [[n]]: [[item n of list]][[end repeat]]
That's all!>>)

    which produces the following output:

         List contains the following items:
Item 1: apple
Item 2: banana
Item 3: orange
Item 4: pineapple
That's all!

    and if statements:

         put merge("There are [[number of items in list]] item[[if number of items in list is not 1 then]]s[[else]] (okay, I know, that should have been 'is' for one item)[[end if]] in the list.")

    which produces the following output:

         There are 4 items in the list.

    To use delimiters other than double-square-brackets, supply the opening and closing merge delimiters as additional parameters to the merge function (if only one delimiter is given, it will be used as both the opening and closing delimiter):

         put merge("Dear <customerName>", "<", ">") into greeting