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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to refer or pass through array-property? 1

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!
I am working on a generic toolbar-class which will work in conjunction with the active form.
On the toolbar I do have a button(1) which has to fire a method on the active form e.g. for doing sort or search.
Next to that toolbar-button I do have a small button(2) with down-arrow to select 'how to sort' or 'on what to search'.
Both buttons are in a container and are class-members (item of class library).
This container classmember sits in the toolbar.
The aim is to let this container have only generic code.

On the active form I do have custom array-properties like
aSort[] and aSearch[]. These do hold the required data for sort and search.

I added two custom properties to the toolbarcontainer.
-1- Method2Fire
-2- Array2SelectFrom
Method2Fire has value like 'SortForm' or 'SearchForm'. These methods do exist on the active form.
So by clicking toolbarbutton(1) I can fire 'SortForm(n)'
Sortdata is in form-array[]. n decides how to sort.

So far so good.

Clicking toolbarbutton2 fires a small 'select'-form holding only radiobuttons which in turn have to display values of the activeform array e.g. aSort.

My Q:
The name 'aSort' is put at designtime in the toolbar container property.
How can I pass this name through to the 'select'-form in such as way that the 'select'-form can use that name by picking-up the array-values, required to populate the radiobutton captions. Of course all with generic code.

At this moment this all works fine but I hardcoded the arrayname in the 'select'-form which is bad behaviour for class-desgn.

Hope someone can give me a hand on this.

-Bart









 
First, don't name a property aSort. That's a built-in function.

To pass an array property as a parameter, you have to copy it to a local array and pass that instead.

local aArray
ACOPY(This.aMyArray, aArray)
DO FORM Whatever with @aArray
* If the called item can make changes
ACOPY(aArray, This.aMyArray)

Tamar
 
Tamar,
Still a problem.
In the toolbar I set at designtime in a property the name of the form-array e.g. 'aSearch'. So that is a stringvar.
But how can I, from the toolbar, refer to the form-array?
From the toolbar I can refer to the active form by:
loForm = _screen.activeform
I do know the name which is stored in the toolbar-property : 'aSearch'.
But I don't know how to use that property to refer to the form.property holding the required array.

Any idea?
-Bart
 
Hi Tamar,
Thanks again for your reply. But still I can't get things to work as aspected.
In brief once again:
- On the form I do have an array-property called aSearch.
- In the toolbar I do have a property named aLocalArray in which (at design) I put in the string 'aSearch'
_ During runtime I need (code in toolbar) to copy the form-array to a local array.
I tried :
aArrayName = '_screen.activeform.'+ (aLocalArray)

acopy (aArrayName,aNewArray)

Here error : 'aArrayName is not an array' pops up.

Any idea?

-Bart
 
Try macro expansion to make this work:

ACOPY(&aArrayName, aNewArray)

Tamar
 
Tamar,

Thanks,the macro-expansion made it indeed to work.
Star for your worthfull-help!

-Bart
 
Tamar,
Just one Q left.
Code:
LOCAL loForm, laArray, lnSelectedItem, lcCommand
WITH this
	lnSelectedItem = .nSelectedItem
	laArray		= '_screen.activeform.'	+(.cSelectArrayName)
	ACOPY(&laArray	, la)
	loForm = CREATEOBJECT('tbrSpecSortOptions',lnSelectedItem, @la, .left)
	IF VARTYPE(loForm) = 'O'
		.nselecteditem = loForm.nReturnValue
		lnSelectedItem = .nSelectedItem
		lcCommand = '_screen.ActiveForm.'+(.cMethod2Run)+'['+ALLTRIM(STR(lnSelectedItem))+']'
		&lcCommand
	ENDIF 	
ENDWITH

This is code I put in the click-metod of a toolbarbutton.
The problem is that only the first element of la is passed through.
Is that because I use the 'createobject'iso doform?

-Bart
 
I'm not sure why this is failing. One thing I would try is declaring the array before you populate it with ACOPY().

Tamar
 
Tamar,
Problem remains. As a workaround, for the time being, I go through by having a public array holding the required data.
Later on (after the app has almost finished) I'll try tidying up this.
-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top