Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Defining Classes -Sending Parameters or Using variables
Message
From
05/11/2001 14:39:59
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00577526
Message ID:
00577528
Views:
10
>how do you Pass a parameter or reference a variable when defining a class.

Basically, you can pass a parameter two ways (apart from a few workarounds, like public or private variables):

1) Pass the parameter when you create the object:
CreateObject('MyFormClass', par1, par2)
Parameters have to be accepted (and copied to properties) in your Class's Init().

2) CreateObject(), without additional parameters, and then call a custom method to pass information.
loForm = CreateObject('MyClass')
loForm.SetValues(par1, par2)
>
>I am trying to Create a form with the controls on fly by using an array. and creating the command buttons and procedures using a loop. Problem is I cannot get this to work.
>
>sample code.
>
>AllOptions = CREATEOBJECT('Form') && Create a Form
>AllOptions.Closable = .F. && Disable the Control menu box
>
>loopcnt=alen(OptionArray,1)
>n = 1
>for n = 1 to loopcnt
> option='Option'+alltrim(str(n))
> AllOptions.AddObject('cmdCmndBtn'+alltrim(str(n)),'Option'+alltrim(str(n)))
>next
>
>AllOptions.cmdCmndBtn1.Visible =.T. && Up Command button visible
>AllOptions.cmdCmndBtn2.Visible =.T. && Down" Command button visible
>AllOptions.cmdCmndBtn3.Visible =.T. && Quit Command button visible
>
>AllOptions.SHOW && Display the form
>READ EVENTS && Start event processing
>
>
>DEFINE CLASS Option3 AS CommandButton && Create Command button
> Caption = 'Exit' && Caption on the Command button
> Cancel = .T. && Default Cancel Command button (Esc)
> Left = 125 && Command button column
> Top = 150 && Command button row
> Height = 25 && Command button height
>
> PROCEDURE Click
> CLEAR EVENTS && Stop event processing, close Form
>ENDDEFINE
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform