AS400 RPGLE/运行中的自由动态变量 [英] AS400 RPGLE/free dynamic variables in operations

查看:155
本文介绍了AS400 RPGLE/运行中的自由动态变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过多年的搜索,我相当确定这是不可能的,但是我还是会问.

I'm fairly certain after years of searching that this is not possible, but I'll ask anyway.

问题是,当您不知道字段名称时是否可以在操作中使用动态变量.例如,我有一个包含数百个字段的数据结构.操作员选择这些字段之一,程序需要从传递的数据结构中知道哪些数据驻留在该字段中.因此,我们说有100个字段,而field50是操作员选择对其进行操作的对象.该程序将在FLDNAM变量的字段名称(即field50)中传递.该程序将以正常方式读取如下内容:

The question is whether it's possible to use a dynamic variable in an operation when you don't know the field name. For example, I have a data structure that contains a few hundred fields. The operator selects one of those fields and the program needs to know what data resides in the field from the data structure passed. So we'll say that there are 100 fields, and field50 is what the operator chose to operate on. The program would be passed in the field name (i.e. field50) in the FLDNAM variable. The program would read something like this the normal way:

/free
  if field50 = 'XXX'
  // do something
  endif;
/end-free

问题是我必须为每个操作将此代码编码100次.例如:

The problem is that I would have to code this 100 times for every operation. For example:

/free
  if fldnam = 'field1';
  // do something
  elseif fldnam = 'field2';
  // do something
  ..
  elseif fldnam = 'field50';
  // do something
  endif;

是否有可能在未知的字段上执行操作? (即,如果FLDNAM(指针数据)='XXX',则执行某项操作)

Is there any possible way of performing an operation on a field not yet known? (i.e. IF FLDNAM(pointer data) = 'XXX' then do something)

推荐答案

如果数据结构是外部描述的,并且知道它来自什么文件,则可以使用QUSLFLD API找出偏移量,长度和类型数据结构中的字段,然后使用子字符串获取数据,然后使用其他计算获取值,具体取决于数据类型.

If the data structure is externally-described and you know what file it comes from, you could use the QUSLFLD API to find out the offset, length, and type of the field in the data structure, and then use substring to get the data and then use other calculations to get the value, depending on the data type.

这篇关于AS400 RPGLE/运行中的自由动态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆