Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Struggling with arrays
Message
From
16/06/2001 08:30:20
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00520246
Message ID:
00520250
Views:
22
>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()

*ParseToArray
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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform