【问题标题】:dxl script to paste the clipboard contents in selected objectsdxl 脚本将剪贴板内容粘贴到选定对象中
【发布时间】:2019-04-29 12:14:37
【问题描述】:

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

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

选择的对象有一些文本,例如“此对象中已经存在的文本”,剪贴板内容,例如“我的剪贴板文本”应该添加在开头并作为单个对象形成。

(输出应该类似于下面的单个对象。)

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

我的代码:

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)

【问题讨论】:

    标签: ibm-doors


    【解决方案1】:

    不确定您为什么要为此使用 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
    

    请注意,这仅适用于已明确选择的项目。

    编辑 - 为具有对象标题的对象添加了排除项。不幸的是,DOORS 不允许(据我所知)不连续的对象选择(相当于 Windows 中的 ctrl-左键单击),这可能非常令人沮丧。

    【讨论】:

    • 这很有魅力。非常简洁明了。谢谢拉塞尔。我已经循环为选择的对象放置缩进和项目符号。并想将剪贴板内容放在此之前。
    • 我不能在选择的标题对象上有例外吗?脚本应排除选择中的标题对象。
    • 更新了代码以排除具有对象标题的对象 - 请注意,如果您在同一个对象中有对象标题和对象文本的内容,它将被跳过。
    • 是的!它确实有效。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-24
    • 2013-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-06
    相关资源
    最近更新 更多