【问题标题】:How to copy and add a prefix to a filename?如何复制并为文件名添加前缀?
【发布时间】:2021-03-04 13:39:30
【问题描述】:

我是进度 4GL 的新手。我使用以下查询,但不确定如何在复制到新目录之前为文件名添加前缀。它是文件中的单行查询,可以使用进度编译器进行编译。

注意 - 原文件应与重命名、复制后相同。

define variable lvc_filename as character no-undo.
define variable lvc_newpath as character no-undo.

assign
    lvc_filename = '/mgeditmp/ast/wbxp.i'
    lvc_newpath  = '/mgeditmp/wbxp.i'
    .
unix silent value("cp -f " + lvc_filename + ' ' + lvc_newpath).

【问题讨论】:

    标签: openedge progress-4gl


    【解决方案1】:

    您可以使用num-entriesentry 语句和entry 函数:

    def var iparts as int  no-undo.
    def var cold   as char no-undo initial '/dir/file'.
    def var cnew   as char no-undo.
    
    iparts = num-entries( cold, '/' ).
    if iparts > 0 then
       assign 
          cnew = cold
          entry( iparts, cnew, '/' ) = 'prefix' + entry( iparts, cnew, '/' )
          .
    

    【讨论】:

      【解决方案2】:

      看看OS-COPY 命令。如果您在同一个文件夹中,还有一个 OS-RENAME 命令。

      【讨论】:

        猜你喜欢
        • 2015-07-28
        • 2018-11-10
        • 1970-01-01
        • 1970-01-01
        • 2019-12-04
        • 2016-04-23
        • 2012-06-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多