NX二次开发uc1608 函数介绍

158 阅读4分钟

uc1608

Defined in: uf_ui.h 
int uc1608(const char * cp1, const char cp2 [ ] [ 16 ] , int ip3, int ia4 [ ] , double ra5 [ ] , int ip6 [ ] )

overview 概述

Display a keyboard entry menu and obtain integer or real data.

This routine displays an entry menu with integers and reals. The two arrays ia4[ip3] and ra5[ip3] are initialized with the default parameters that you specify. Both of these arrays as well as array ip6[ip3] and cp2[ip3][16] must be dimensioned to ip3. For example, if you decide to use the maximum of 14 parameter values you would dimension ia4[14], ra5[14], ip6[14], and cp2[14][16].

The array values of ip6[ip3] determine which menu entries are doubles and which are integers. For example if you set ip6[7] = 1, you are specifying the 8th menu entry to be double. This also means that the eighth value of ra5 (ra5[7]) is used as the default value. The index array value of ip6 maps to the index array values of ia4 and ra5 depending on whether you use an initial integer or double parameter value. For example, if you specify four integers and then one double you will get ra[4] as your first double, not ra[0]. The entry menu values always maintain the data type (double or int) of the initialized default values. Therefore, if you enter a double value into the entry menu where an integer was the default, the double is converted to an integer by truncating the decimal portion of the double. Similiarly, if you enter an integer where the default was a double, the integer is converted to a double.

Note: If a real number containing more than 12 decimal places is passed into this function, the underlying code will truncate it to 12 decimal places. This will then pass back a return a value of 4 (OK with user input) instead of the expected 3 (OK - No user input). By truncating your real parameter to 12 or less decimal places before calling this function, it will work as expected.


显示键盘输入菜单并获取整数或实际数据。这个例程显示一个包含整数和实数的输入菜单。两个数组 ia4[ ip3]和 ra5[ ip3]使用您指定的默认参数进行初始化。这两个数组以及数组 ip6[ ip3]和 cp2[ ip3][16]都必须维度为 ip3。例如,如果您决定使用最多14个参数值,那么您将维度 ia4[14]、 ra5[14]、 ip6[14]和 cp2[14][16]。Ip6[ ip3]的数组值决定了哪些菜单条目是双精度的,哪些是整数。例如,如果您设置 ip6[7] = 1,那么您将第8个菜单项指定为 double。这也意味着使用 ra5的第八个值(ra5[7])作为默认值。Ip6的索引数组值映射到 ia4和 ra5的索引数组值,这取决于您使用的是初始整数值还是双参数值。例如,如果您指定四个整数,然后一个双精度数,您将得到 ra [4]作为您的第一个双精度数,而不是 ra [0]。条目菜单值始终维护初始化默认值的数据类型(double 或 int)。因此,如果在条目菜单中输入一个 double 值,其中默认为整数,则通过截断 double 的小数部分,将 double 转换为整数。类似地,如果输入默认值为 double 的整数,则该整数将转换为 double。注意: 如果一个包含超过12个小数位的实数被传递到这个函数中,底层代码会将其截断为12个小数位。然后返回一个值4(用户输入 OK) ,而不是预期的3(OK-没有用户输入)。通过在调用此函数之前将实参数截断到小数点后12位或更少,它将按预期工作。

UFUN例子

获取源码例子请搜索 里海NX二次开发3000例专栏

parameters 参数

const char *cp1InputMenu title to display on the cue line. This may be a maximum of 80 characters.
在提示线上显示的菜单标题。最多可以显示80个字符。
const charcp2 [ ] [ 16 ]InputThis is the array of menu items to display.
这是要显示的菜单项数组。
intip3InputThis is the number of items in the menu array, cp2. This is also the size of the integer and double arrays.
这是菜单数组 cp2中的项数。这也是整数和双数组的大小。
intia4 [ ]Input / OutputOn input these are the initial parameter values. On output these are the values as modified by the user. This must be an array dimensioned to [ip3].
在输入时,这些是初始参数值。在输出时,这些值是由用户修改的。这必须是一个维度为[ ip3]的数组。
doublera5 [ ]Input / OutputOn input these are the initial parameter values. On output these are the values as modified by the user. This must be an array dimensioned to [ip3].
在输入时,这些是初始参数值。在输出时,这些值是由用户修改的。这必须是一个维度为[ ip3]的数组。
intip6 [ ]InputThis is the variable type to use for each menu item. if ip6[n] is 0, then the item is an integer. If ip6[n] is 1, then the item is a double. If an item is marked as an integer, its default value comes from ia4, and its return value is in ia4. If an item is marked as a double, its default value comes from ra5, and its return value is in ra5. This parameter must also be dimensioned as [ip3].
这是用于每个菜单项的变量类型。如果 ip6[ n ]为0,则该项为整数。如果 ip6[ n ]为1,则该项为 double。如果一个条目被标记为整数,它的默认值来自 ia4,它的返回值是 ia4。如果一个条目被标记为 double,它的默认值来自 ra5,返回值来自 ra5。此参数的尺寸也必须为[ ip3]。