- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我编写了一个将文件导出到特定目录的程序,但我觉得我编写了一些不需要的逻辑。所以我想知道导出文件的简短且最佳的方法。让我分享一下我的尝试
DEFINE VARIABLE cData AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE icount AS INTEGER NO-UNDO.
DEFINE VARIABLE cName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cPath AS CHARACTER NO-UNDO.
DEFINE TEMP-TABLE ttdata
FIELD GetName AS CHARACTER
FIELD iValue AS INTEGER.
ASSIGN
icount = 2
cPath = "*******".
DO I = 1 TO icount:
IF I = 1 THEN cName = "David".
IF I = 2 THEN cName = "Macavo".
CREATE ttdata.
ASSIGN
ttdata.GetName = cName
ttdata.iValue = 100.
END.
/** ttdata has two records now*/
FOR EACH ttdata.
RUN CallProc.p (INPUT ttdata.GetName,
INPUT ttdata.iValue).
END.
PROCEDURE CallProc:
DEFINE INPUT PARAMETER getName AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER iValue AS INTEGER NO-UNDO.
OUTPUT TO cPath.
PUT UNFORMATTED ttdata.GetName ttdata.GetName.
OUTPUT CLOSE.
END PROCEDURE.
从我的逻辑来看,它运行良好,并按我的预期导出 2 个文件,但调用另一个过程是个糟糕的主意。请帮助这个案例。
最佳答案
我将在我的示例中使用sports2000 db。每个人都有一份副本,因此可以轻松运行示例。
define stream outFile. /* using a named stream rather than the default, unnamed, stream avoids unintended conflicts if someone else's code is lazily using the unnamed stream */
function mkTemp returns character ( input tmpid as character, input extension as character ):
define variable fname as character no-undo.
run adecomm/_tmpfile.p ( tmpid, extension, output fname ).
/* create the temp file with no content
*/
output stream outFile to value( fname ).
output stream outFile close.
return fname.
end.
procedure doStuff:
define input parameter tmpfile as character no-undo.
define input parameter custid as integer no-undo.
output stream outFile to value( tmpFile ) append. /* open the existing file in append mode */
put stream outFile "customer:" custId skip.
for each order no-lock where order.custNum = custId and orderStatus <> "shipped" and salesRep = "bbb":
put stream outFile orderNum " " promised skip.
end.
output stream outFile close.
return.
end.
define variable i as integer no-undo.
define variable tmpName as character no-undo.
/* tmpName = mkTemp( "xyzzy", ".tmp" ). */ /* if you only need one temp file get the name here and comment it out below */
for each customer no-lock:
tmpName = mkTemp( "xyzzy", ".tmp" ). /* use this if every customer should get a distinct temp file */
run doStuff ( tmpName, custNum ).
/* if there is no good reason to be calling the doStuff() procedure then just remove it and do it inline like this: */
/*
*
output stream outFile to value( tmpFile ) append. /* open the existing file in append mode */
put stream outFile "customer:" customer.custNum skip.
for each order no-lock where order.custNum = customer.CustNum and orderStatus <> "shipped" and salesRep = "bbb":
put stream outFile orderNum " " promised skip.
end.
output stream outFile close.
*/
i = i + 1.
if i >= 3 then leave. /* just do 3 customers for the sample run... */
end.
关于openedge - 如何在每个循环中导出文本文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56455441/
美好的一天: 简单问题:我可以在 OpenEdge 中执行动态查询吗? 示例: def temp-table tt-num1 field f1 as int field f2 as int. def
美好的一天: 简单问题:我可以在 OpenEdge 中执行动态查询吗? 示例: def temp-table tt-num1 field f1 as int field f2 as int. def
我是进步的新手,我想从出生日期计算年龄,但我不知道该怎么做。如果有人知道这件事,请帮助我。 提前致谢。 到目前为止我尝试过的是: define var dob as date. define var
我是 OpenEdge 数据库平台的新手,到目前为止我真的很挣扎。我有一位客户给了我他的数据库备份(单个 .bak 文件),该备份取自 OpenEdge v10。我只有一个 OpenEdge v11
显示日期时的默认 DATE 格式是 DD/MM/YY 我想把它改成 DD.MM.YYYY 这只是一个简单的程序: DEFINE VARIABLE daDate AS DATE NO-UNDO. daD
OpenEdge 中是否有类似多线程的概念?如果有,请给我简单介绍一下。 我想在 OpenEdge 中创建一个贪吃蛇游戏。为此,用户必须控制对象,但一旦应用程序启动,那里就没有用户交互可用。 最佳答案
进展专家您好!!! 我正在尝试根据进度条中的完成百分比显示不同的颜色,例如百分比 0% - 25% - 红色,25% - 50% - 黄色,50% - 100% - 绿色。 这里的问题是以下代码有助于
在单元测试中,我需要验证程序在处理表时是否跳过锁定的记录。我无法设置锁定记录,因为测试无法锁定自身,这很有意义。 这是我想要实现的目标的示例。 DEV VAR v_isCommitted
我编写了一个将文件导出到特定目录的程序,但我觉得我编写了一些不需要的逻辑。所以我想知道导出文件的简短且最佳的方法。让我分享一下我的尝试 DEFINE VARIABLE cData AS CHARACT
在单元测试中,我需要验证程序在处理表时是否跳过锁定的记录。我无法设置锁定记录,因为测试无法锁定自身,这很有意义。 这是我想要实现的目标的示例。 DEV VAR v_isCommitted
我找不到任何有关如何重新抛出我刚刚捕获的相同异常的信息。 我的 catch 表达式如下所示: CATCH ex1 AS Progress.Lang.Error : MESSAGE ex
我想检查 OpenEdge 中的变量是否采用 pascal 大小写。 我找到了 matches 运算符,并编写了以下代码: define variable cVariable as character
我想在 OpenEdge 中检查一个变量是否为 Pascal 大小写。 我找到了 matches 运算符,并编写了以下代码: define variable cVariable as characte
我发现 OpenEdge 没有 OLEDB 或 native ADO.NET 驱动程序。 有没有人成功地将 OpenEdge 驱动程序与 Linq 或 Entity Framework 一起使用? 最
我有一个 OpenEdge Progress v10.1C Linux 服务器,上面有一堆数据。我们正在将此数据迁移到 SQL 服务器。我只需要以某种方式从服务器获取数据,无论是一堆 CSV 表还是一
我正在编码(又名 OpenEdge ABL)。 我有一个保存时间的变量,我想弄清楚它是否大于当前时间。 但是我在我读过的文档中找不到任何向我展示如何检索当前正在进行的时间的内容。 我只能找到有关检索当
问题很常见,让我们看看 OpenEdge 在代码可读性、灵活性和性能方面的优缺点。 静态查询: + readability: convenient `buffer.field` notation
我有一个来自 Progress OpenEdge 系统的数据导出,我想用 JavaScript 进行解析。我想使用正则表达式查找导出的所有字段。 我尝试过很多与此类似的事情: /("[^"]*")|[
我尝试从整数中获取 10 位格式值(实际格式为 4 位)。但它的修剪前缀为零并返回相同的值。 让我分享一下我的尝试。 DEFINE VARIABLE idata AS INTEGER NO-UNDO.
我发现了在 Progress 4GL 中记录某些内容的不同方法,但没有一种方法令人满意: 简单的 MESSAGE 语句有一个缺点,它处理帧的方式非常糟糕: ON CHOOSE OF btn-Q4 DO
我是一名优秀的程序员,十分优秀!