用于将剪贴板内容粘贴到选定对象中的 dxl 脚本

dxl script to paste the clipboard contents in selected objects

我想使用 dxl 脚本在现有对象文本中添加剪贴板内容。

我四处搜索,包括 dxl_reference_manual,但没有任何帮助。

选择的对象有一些文本,例如 "Already existing text in this object" 和剪贴板内容,例如 "My Clipboard text" 应该添加在开头并形成一个单独的对象。

(单个对象中的输出应如下所示。)

我的剪贴板文本 此对象中已有文本

我的代码:

Skip    fGetSelectedObjects(Module in_mod) 
{     
    Skip    skpObjects = create()  // Return KEY and DATA both 'Object'
    if (null in_mod) return(skpObjects)
    Object  oCurr = current,
                    o
    for o in entire (in_mod) do
    {  if (isSelected(o)   or
           o == oCurr)              put(skpObjects, o, o)
    }
    return(skpObjects)
}     // end fGetSelectedObjects()
Skip    skpObjects = fGetSelectedObjects(current Module)
Object  o

for o in skpObjects do
{   // deal with the selected o
string s = o."Object text"
// I don't know the way to activate the object text attribute instead  of manual click. Thus it loops through selection and pastes the clipboard contents. 

  pasteToEditbox

//For Single Indentation use 360 points, double indentation 720 points and so on...

o."Object text" = richText (applyTextFormattingToParagraph(richText s,false,360,0))      

}
delete(skpObjects)

不确定为什么要为此使用 Skip。我希望执行以下操作:

// Create Variables
Module mod = current
Object obj = null
Buffer buf = create
string str = stringOf ( richClip )

// Loop through Module
for obj in entire ( mod ) do {
    // Grab the rich text from the clip and reset the buffer
    buf = str
    // Check if it's selected and object heading is empty
    if ( ( isSelected ( obj ) ) && ( obj."Object Heading" "" == "" ) ) {
        // If it is, add the text to the buffer
        buf += " " richText ( obj."Object Text" )
        // Set the object text with the clip stuff in front
        obj."Object Text" = richText ( buf )
    }
}

delete buf

请注意,这仅适用于专门选择的项目。

编辑 - 添加了对 object 标题 Object 的排除。不幸的是,DOORS(据我所知)不允许 non-contiguous object 选择(相当于 ctrl-left 在 Windows 中单击),这非常令人沮丧。