>Hi,
>I try to store some numeric values in a array property and troubles with:
>
>1. Using a ParseToArray() function I need to send the array with reference. But I can't use @this.arr, but have to use a local variable @Arr. Is this the way it is?
>
>2. Defining the array-property in a form with arr[5] the value is .F. and can't be edited in the property window.
>
>So I ended up with code like
>
>ParseToArray('0;3;2;1;0,5',@Arr,';')år
>For i=1 to 5
> this.arr[i]=VAL(arr[i])
>Next
>
>Could I have done something easier like: this.arr={1,2,3,4,5} ?
Einar,
1)
-Instead of parsed array you might pass the string and called routine might parse to a local array of its own.
-If parsed first to pass array shouldn't be a property array
dimension myArr[1]
ParseToArray('0;3;2;1;0,5',@myArr,';')
this.myMethod(@myArr)
-Or do not pass anything since called method has access to object properties (or pass object ref)
dimension myArr[1]
ParseToArray('0;3;2;1;0,5',@myArr,';')
acopy(myArr,this.Arr)
this.myMethod()
-Or pass PaerseToArray array property name
ParseToArray('0;3;2;1;0,5','this.Arr',';')
this.MyMethod()
Lparameters tcList, tcArrayName
Local lnElemCount, lnArrayElem
lnElemCount = occurs(",",tcList)+1
Local aArray[lnElemCount]
lnArrayElem = 1
Do while occurs(",",tcList)>0
aArray[lnArrayElem] = alltrim(substr(tcList,1, at(",",tcList)-1))
lnArrayElem = lnArrayElem + 1
tcList = substr(tcList, at(",",tcList)+1)
Enddo
aArray[lnArrayElem] = alltrim(substr(tcList,1))
Dimension &tcArrayName.[lnElemCount]
Acopy(aArray, &tcArrayName)
2) Unfortunately you can't initialize an array with C, Pascal etc notation using { .. }
You should just define the array property (I generally directly add array property myArr[1] whatever the real dimensions would be - routines that should play with it dimension it as necessary). You can't edit in property window but in code as wherever you see fit. ie : form.init
ParseToArray('0;3;2;1;0,5','this.myArr',';')
Note that last ParseToArray code take care of dimensioning it.
PS: Pls note that in ParseToArray a list is accepted is comma separated values and not comaptible with your params list. Change routine.
Cetin