pb赋值问题
PB中,如何通过一条赋值语句而不是for循环来把数据窗口中的某一个字段的全部的值存到(相当于是赋值)数组arry[]中难道没有PB高手吗?其实这个问题应该很简单的,只要有...
PB中,如何通过一条赋值语句而不是for循环来把数据窗口中的某一个字段的全部的值存到(相当于是赋值)数组arry[]中
难道没有PB高手吗?其实这个问题应该很简单的,只要有经验的、知识面广点的都知道的呀,我只是初学,用for循环是可以解决,但编程要讲究精炼嘛!我的问题应该描述的很清楚了吧。举个实例:数据窗口dw_1,有字段ID,NAME,CLASS.假设dw_1中一共有三条数据,NAME的三个值分别为张三、李四、王二。怎么通过一条语句,将张三、李四、王二赋值到数组arry[]中。 展开
难道没有PB高手吗?其实这个问题应该很简单的,只要有经验的、知识面广点的都知道的呀,我只是初学,用for循环是可以解决,但编程要讲究精炼嘛!我的问题应该描述的很清楚了吧。举个实例:数据窗口dw_1,有字段ID,NAME,CLASS.假设dw_1中一共有三条数据,NAME的三个值分别为张三、李四、王二。怎么通过一条语句,将张三、李四、王二赋值到数组arry[]中。 展开
4个回答
展开全部
这个满足你的要求
可以将数据窗口指定的起始行、结束行---起始列、结束列整个块得数据放到一个数组中
如果指定列2即起始列和结束列均为2 你可以设置行为0到dw.RowCount
如果英文看来有不便之处 可以细问
Description
You can access data in a range of rows and columns by specifying the starting and ending row and column numbers.
Syntax
dwcontrol.Object.Data {.buffer } {.datasource } [ startrownum, startcolnum, endrownum, endcolnum ]
Parameter Description
dwcontrol The name of the DataWindow control or child DataWindow in which you want to get or set data
buffer (optional) The name of the buffer from which you want to get or set data. Values are:?Primary ?(Default) The data in the primary buffer (the data that has not been deleted or filtered out)?Delete ?The data in the delete buffer (data deleted from the DataWindow control)?Filter ?The data in the filter buffer (data that was filtered out)
datasource (optional) The source of the data. Values are:?Current ?(Default) The current values in the DataWindow control?Original ?The values that were initially retrieved from the database
startrownum The number of the first row in the desired range of rows
startcolnum The number for the first column in the range
endrownum The number of the last row in the desired range of rows
endcolnum The number for the last column in the rangeThe row and column numbers must be enclosed in brackets and separated by commas
Return value
An array of structures or user objects. There is one structure element or user object instance variable for each column in the designated range. The data type of each element matches the data type of the corresponding column. There is one structure or user object in the array for each row in the range of rows.
Usage
When you specify a block, the expression always returns an array and you must assign the result to an array, even if you know there is only one structure in the result.
This expression returns an array of one structure from row 22:
dw_1.Object.data[22,1,22,4]
This expression returns an array of one value from row 22, column 1:
dw_1.Object.data[22,1,22,1]
可以将数据窗口指定的起始行、结束行---起始列、结束列整个块得数据放到一个数组中
如果指定列2即起始列和结束列均为2 你可以设置行为0到dw.RowCount
如果英文看来有不便之处 可以细问
Description
You can access data in a range of rows and columns by specifying the starting and ending row and column numbers.
Syntax
dwcontrol.Object.Data {.buffer } {.datasource } [ startrownum, startcolnum, endrownum, endcolnum ]
Parameter Description
dwcontrol The name of the DataWindow control or child DataWindow in which you want to get or set data
buffer (optional) The name of the buffer from which you want to get or set data. Values are:?Primary ?(Default) The data in the primary buffer (the data that has not been deleted or filtered out)?Delete ?The data in the delete buffer (data deleted from the DataWindow control)?Filter ?The data in the filter buffer (data that was filtered out)
datasource (optional) The source of the data. Values are:?Current ?(Default) The current values in the DataWindow control?Original ?The values that were initially retrieved from the database
startrownum The number of the first row in the desired range of rows
startcolnum The number for the first column in the range
endrownum The number of the last row in the desired range of rows
endcolnum The number for the last column in the rangeThe row and column numbers must be enclosed in brackets and separated by commas
Return value
An array of structures or user objects. There is one structure element or user object instance variable for each column in the designated range. The data type of each element matches the data type of the corresponding column. There is one structure or user object in the array for each row in the range of rows.
Usage
When you specify a block, the expression always returns an array and you must assign the result to an array, even if you know there is only one structure in the result.
This expression returns an array of one structure from row 22:
dw_1.Object.data[22,1,22,4]
This expression returns an array of one value from row 22, column 1:
dw_1.Object.data[22,1,22,1]
更多追问追答
追问
非常谢谢你的回答,你说的意思我也懂了,不过这里只是把字段的值取出来了,如果要分别存到数组arry[]中应该怎么写呢?tmbh[]=ds_wlinfo.object.data[1,1,ll_count,1],我这样写是错的。还有补充一下:是把张三、李四、王二分别存到数组arry[]中的arry[1],arry[2],arry[3]中,有n条数据,就存到arry[n]为止
追答
你直接那样做应该报:Mismatched ANY data types in expression 类似这样的错误吧powerobject xx
any xy[]
xy[] = dw_1.Object.data[2,2,20,2]
string yy[]
yy[] =xy[]
如此测试成功
你可以试一试
展开全部
取该字段首地址,付给数组arry[]的首地址。
更多追问追答
追问
可不可以更详细点,我暂时语法还不是很熟,而且我指的是某一个字段的多个值,而不是一个值,取字段首地址怎么取呀?
追答
你所谓的字段不是一个字符串?那一条语句比较难以实现。
一般来说,字符串是按照地址空间顺序存储的一个个字符,通过读取第一个字符的地址,顺序向下读取,可以取出全部字符串的内容。
但是,如果你不是字符串,而是一串无意义的数据类型,可能存储的空间就不是连续的,也因此就不能通过一条语句全部读取了。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个是可以的。
不怎么常用。写法真的忘记了,你百度百度吧,应该可以找到的。
不怎么常用。写法真的忘记了,你百度百度吧,应该可以找到的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数组名 = 数据窗口.Object.列名.current
更复杂的看PB的帮助数据窗口参考那里有详细的存取数据的方法
更复杂的看PB的帮助数据窗口参考那里有详细的存取数据的方法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询