pick/UniVerse 数据库中的常量

发布于 2024-10-17 04:47:10 字数 235 浏览 3 评论 0原文

  1. 如何声明一个常量值 PICK/UniVerse 数据库?
  2. 如何将参数传递给 通过常量引用函数?

IBM UniVerse 数据库手册中有一些关于常量的信息,但没有什么特别的信息。

请注意:

DEFINE语句值

不是我正在寻找的,因为它在编译时用值替换语句并且不提供值的真正常量性。

有谁知道如何申报这些?

谢谢。

  1. How to declare a constant value in
    PICK/UniVerse database?
  2. How to pass an argument to a
    function by constant reference?

There is some information in the IBM's manual for UniVerse database about constants, but nothing in particular.

Please note that:

DEFINE statement value

is not what i'm looking for because it substitutes the statement with value at compile time and doesn't provide real constness of the value.

Does anyone know how to declare those?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

粉红×色少女 2024-10-24 04:47:10

与UniData(UniVerse的姊妹数据库,统称为U2)中的语句相同,即:EQUEQUATE

例如:

EQU statements TO value

我不完全确定第 2 点的意思,但我会仔细研究一下。默认情况下,所有参数都是“按引用传递”,但没有 const 参数的形式。它仍然允许您在函数/子例程内部更改参数值,但结果不会影响调用程序/函数/子例程中的等式值。


旁注:如果您想确保子例程/函数不会更改您传递的实际变量的值(按值传递),您可以将其分配给临时变量并传递它,或者用括号将其括起来

例如:

CALL MySub(PassByRef, (PassByValue))

() 的作用是创建 PassByValue 的临时副本,然后通过引用传递临时副本。这会阻止更改传播回 PassByValue

It is the same statement as in UniData (UniVerse's sister database; both are collectively referred to as U2), which is: EQU and EQUATE

For example:

EQU statement TO value

I'm not entirely sure what you mean by point 2, but I'll give it a dig. By default, all parameters are 'pass by reference', but there is no form of const argument. It will still allow you to change the parameter value internally in the function/subroutine, but the results will not affect the values of the equates back in the calling program/function/subroutine.


Side note: If you want to ensure a subroutine/function does not change the value of an actual variable you pass (pass by value), you can either assign it to a temp variable and pass that, or surround it with parenthesis

For example:

CALL MySub(PassByRef, (PassByValue))

what the () does is create an temporary copy of PassByValue then pass the temp copy by reference. This stops the changes propagating back into PassByValue

煞人兵器 2024-10-24 04:47:10

Pick/Universe 中使用变量之前,您不需要定义变量。

要分配在编译时定义的变量,请使用

EQU PI TO 3.14

要在运行时分配它,请使用

PI = 3.14

这里的主要区别在于,一旦在编译时分配,使用 EQUATE 时,无法重新分配变量,而在运行时分配变量则可以。因此,编译时的编译通常只保留给常量,而运行时的赋值既可以用于常量,也可以用于标准变量值。

You do not need to define variables before they are used in Pick/Universe.

To assign a variable that is defined at compile time use

EQU PI TO 3.14

To assign it at run time use

PI = 3.14

The main difference here is that once assigned at compile time, using an EQUATE, the variable cannot be reassigned, whereas when it is assigned at run time it can be. Therefore compilation at compile time is usually reserved solely for constants, whereas assignment at run time may be used both for constants and for standard variable values.

情栀口红 2024-10-24 04:47:10

我将使用 EQUATE 语句来创建常量,如果您想让它们可用于多个程序,您应该将它们放在自己的记录中,并使用 $INCLUDE 语句将定义拉入其他程序。请注意,所有值都将在编译时建立。

至于在编译时以外的某个时间建立的“常量”,或通过标签间接引用值(传递常量引用),大多数 U2 程序员使用某种类型的控制记录。由于 U2 中的文件系统和编程语言如此紧密地交织在一起,因此没有人会三思而后行。我使用过的大多数系统都有一个或多个名为“SOMETHING.OR.OTHER.CTRL”的文件,具有自由格式的记录结构。编辑器用于将数据填充到控制文件中的记录中,其中包含描述功能的键,例如“INVENTORY.CONSTANTS”。

对于间接引用,设置记录的第一个属性具有多值“常量”名称,第二个字段具有“常量”值(也是多值)。像这样:(

INVENTORY.CONSTANTS:

001: JOHN*PAUL*GEORGE*RINGO
001: 100*57*83*19833

其中“*”实际上是一个值标记)。

然后程序将执行以下操作:

SUBROUTINE SAMPLE(CONSTANT.NAME)
     .
     .
     .
OPEN "","SOMETHING.OR.OTHER.CONTROL" TO CTRL.FILE ELSE BOMB
READ CONST.REC FROM CTRL.FILE, "INVENTORY.CONTSTANTS" THEN
  LOCATE CONSTANT.NAME IN CONST.REC<1> SETTING CONST.POS THEN
    CONST.VALUE = CONST.REC<2,CONST.POS>
  END ELSE
    BOMB
  END
END ELSE
  BOMB
END

I'd use the EQUATE statements to create constants, and if you want to have them available to multiple programs you should place them in their own record and use the $INCLUDE statement to pull the definitions into other programs. Note that all of the values are going to be established at compile time.

As to "constants" that are established at some time other than compile time, or indirectly referencing values through tags (passing a constant reference), most U2 programmers use control records of some sort. Since the file system and the programming language in U2 are so intertwined, nobody ever thinks twice about this. Most systems I've used have one or more files called something like, "SOMETHING.OR.OTHER.CTRL" with free-form record structures. The editor is used to stuff data into records in the control file with keys that describe the function, like, "INVENTORY.CONSTANTS".

For indirect references, set up the record with the first attribute having the "constant" names multivalued and the second field with the "constant" values, also multivalued. Like this:

INVENTORY.CONSTANTS:

001: JOHN*PAUL*GEORGE*RINGO
001: 100*57*83*19833

(where the "*" is actually a value mark).

Then the program would do the following:

SUBROUTINE SAMPLE(CONSTANT.NAME)
     .
     .
     .
OPEN "","SOMETHING.OR.OTHER.CONTROL" TO CTRL.FILE ELSE BOMB
READ CONST.REC FROM CTRL.FILE, "INVENTORY.CONTSTANTS" THEN
  LOCATE CONSTANT.NAME IN CONST.REC<1> SETTING CONST.POS THEN
    CONST.VALUE = CONST.REC<2,CONST.POS>
  END ELSE
    BOMB
  END
END ELSE
  BOMB
END
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文