凡尘clsoho™的博客

E-mail & MSN: clsoho@hotmail.com
QQ1超级群: <101817641已满> QQ2群:<110722895已满>
QQ3超级群:<23765855>QQ4超级群:<85338969>

DESCRIBE DISTANCE

Syntax 语法

DESCRIBE DISTANCE BETWEEN dobj1 AND dobj2 INTO dst
                          IN {BYTE|CHARACTER} MODE.

Effect 作用

This statement assigns the distance between the starting positions of the data objects dobj1 and dobj2 to the data object dst, for which the data type i is expected. In case of deeper data types, the referenced data object is not relevant but the position of the internal reference (for strings and internal tables) or the reference variables. It is not important, in which order dobj1 and dobj2 are specified.

这个语句把数据对象dobj1dobj2的起始位置的距离赋给i类型的数据对象dst。如果是复杂数据类型,被参照的数据类型是不相关的除了内部参照的位置(对于字符串和内表)或者参考变量。Dobj1dobj2以哪种顺序被指定并不重要。

In Unicode programs, the addition MODE must be specified. The variant with the addition IN BYTE MODE determines the distance in bytes. The variant with the addition IN CHARACTER MODE converts the distance into characters that can be stored in this length according to the current character presentation. In non-Unicode programs and in releases prior to 6.10, the addition MODE can be omitted. In this case, the addition IN BYTE MODE is used implicitly. When you use this addition in IN CHARACTER MODE and the determined distance cannot be converted into a number of characters, an exception that cannot be handled is triggered.

unicode程序中,选项mode须发被指定。具有选项in byte mode的变式以字节判断距离。具有选项in character mode的变式根据当前字符的描述把距离转换成可以以这个长度保存的字符。在non-unicode程序和在6.10之前的版本中,选项mode可以被省略。这种情况下,选项in byte mode隐式地被使用。如果使用选项in character mode并且判断出来的距离不能被转换成若干字符,将会触发一个不可处理的异常。

Note

The distance between data objects should only be determined within the same structure and only the structure's components should be used because only they are always in a successive order in the memory. Note that the alignment gaps are counted as well. Therefore, use the addition IN BYTE MODE to avoid an exception that cannot be handled.

应当只能判断具有相同结构的数据对象之间的距离,应该只能使用结构的字段因为只有它们在内存中总是连续的。注意也要计算差异。所以,使用选项in byte mode来避免不可处理的异常。

Example 例子

Determination of the offset and length of a character-type fragment within the structure struc in bytes, access to the fragment using an offset / length access und an assignment to a field symbol of the type c. Since the structure is not purely character-type, a field symbol is used for the offset / length access. Otherwise, a syntax error occurs in a Unicode program. The field symbol is of the type x, because offset and length are determined in bytes. Due to the alignment gap before comp3, a different value is determined for off in Unicode system as in non-Unicode systems. In both cases, the field symbol <result> has the same content "Hey you!". 翻译略。有点绕口,呵呵

DATA: BEGIN OF struc,
        comp1    TYPE i,
        comp2(1) TYPE x,
        comp3(4) TYPE c VALUE 'Hey',
        comp4(4) TYPE c VALUE 'you!',
        comp5    TYPE x,
      END OF struc.

DATA: off TYPE i,
      len TYPE i.

FIELD-SYMBOLS: <hex> TYPE x,
               <result> TYPE c.

DESCRIBE DISTANCE BETWEEN:
         struc       AND struc-comp3 INTO off IN BYTE MODE,
         struc-comp3 AND struc-comp5 INTO len IN BYTE MODE.

ASSIGN: struc TO <hex> CASTING,
        <hex>+off(len) TO <result> CASTING.

Exceptions

Non-Catchable Exceptions 不可捕捉的异常

  • Cause: Distance cannot be converted into characters.
    Runtime Error:
    UC_NO_CHAR_NUMBER
posted on 2010-03-10 12:50  凡尘clsoho  阅读(483)  评论(0编辑  收藏  举报