Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating cursor from array ? 2

Status
Not open for further replies.

mensudb

Programmer
Sep 2, 2004
13
US
Hello,

I was trying to create a cursor from an array and it was usuccessful:
create cursor cPrint (slip n(7) null)
append from array('orderArray')

If my array orderArray has, for example 5 items, created cursor always has only one record, and it is the first item of the array.
I have tried to run something like:
for i=1 to alen(orderArray)
append from array orderArray(i)
endfor

but the first item is just repeated ALEN(arrayOreder) times !?

Please help.

Thanks.

Mensud
 
Well this tripped me up until I remembered something and checked the help file. I've added the appropriate parts here.

Remarks
...
If the array is one-dimensional, APPEND FROM ARRAY adds one record to the table.
...
If the array is two-dimensional, APPEND FROM ARRAY adds a new record to the table for each row in the array. For example, if the array has four rows, four new records are appended to the table.
...
This works:
Code:
DIMENSION orderArray[5,1]
orderArray[1] = 1
orderArray[2] = 10
orderArray[3] = 100
orderArray[4] = 100000
orderArray[5] = 1000000

 
create cursor cPrint (slip n(7) null)
append from ARRAY orderArray
Rick

 
Nice read on the problem Rick, I was wondering what the deal was but hadn't the time to figure it out. Star, because I will remember this in the future and it will probably save me some time. Not exactly sure why this would have been designed this way, but I guess the one-dimensional behavior could prove useful somehow.

boyd.gif

 
Thanks rgbean.
It works. You saved me a time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top