Variables ( Solved )
-
- Posts: 603
- Joined: Sun May 04, 2008 8:44 pm
Variables ( Solved )
MyArray:={ {'campo1', 30}, {'campo2', 50}}
for n = 1 to len(MyArray)
// How make it ?
// #define MyArray[n][1] MyArray[n][2]
next n
msginfo(campo2) // need return 50
i maked it
// it´s OK more is define campo2 as 50 only inside this function when i try msginfo(campo2) in other function
// give me erro variable no exist.
&( " "+Alltrim(MyArray[n][1]) +" := " + Alltrim(str(MyArray[n][1])) )
i try make it too.
&( "Public "+Alltrim(MyArray[n][1]) +" := " + Alltrim(str(MyArray[n][1])) )
More give me erro.
Someone can help ?
thanks
for n = 1 to len(MyArray)
// How make it ?
// #define MyArray[n][1] MyArray[n][2]
next n
msginfo(campo2) // need return 50
i maked it
// it´s OK more is define campo2 as 50 only inside this function when i try msginfo(campo2) in other function
// give me erro variable no exist.
&( " "+Alltrim(MyArray[n][1]) +" := " + Alltrim(str(MyArray[n][1])) )
i try make it too.
&( "Public "+Alltrim(MyArray[n][1]) +" := " + Alltrim(str(MyArray[n][1])) )
More give me erro.
Someone can help ?
thanks
Last edited by lailton.webmaster on Tue Sep 08, 2009 4:22 am, edited 1 time in total.
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: Variables
Sorry, I don't understand what you're trying to do. Can you rephrase your question?
EMG
EMG
-
- Posts: 603
- Joined: Sun May 04, 2008 8:44 pm
Re: Variables
METHOD Events() CLASS MyActiveX
local act, oReg, cTypeLib, aEvents
oReg := TReg32():New( HKEY_CLASSES_ROOT, "CLSID\" + ::cString + "\InprocServer32" )
cTypeLib := oReg:Get( "" )
oReg:Close()
act:=TactiveX():new(::Janela, ::cString,0,0,0,0)
if ! Empty( cTypeLib ) .and. File( cTypeLib )
aEvents = ActXEvents( cTypeLib, act:hActiveX )
endif
for n = 1 to len(aEvents)
#define aEvents[n][1] aEvents[n][2] // problem aqui
no stay defined ...
next n
Return nil
local act, oReg, cTypeLib, aEvents
oReg := TReg32():New( HKEY_CLASSES_ROOT, "CLSID\" + ::cString + "\InprocServer32" )
cTypeLib := oReg:Get( "" )
oReg:Close()
act:=TactiveX():new(::Janela, ::cString,0,0,0,0)
if ! Empty( cTypeLib ) .and. File( cTypeLib )
aEvents = ActXEvents( cTypeLib, act:hActiveX )
endif
for n = 1 to len(aEvents)
#define aEvents[n][1] aEvents[n][2] // problem aqui

next n
Return nil
-
- Posts: 603
- Joined: Sun May 04, 2008 8:44 pm
Re: Variables
other sample
MyArray:={ {'campo1', 30}, {'campo2', 50},{'kakaka',100},{'mouseon',20},{'click',-12} }
// this Array i receive in function ActEvents of fivewin. it´s only sample. no return always same array.
for n = 1 to len(MyArray)
#define MyArray[n][1] MyArray[n][2]
next n

MyArray:={ {'campo1', 30}, {'campo2', 50},{'kakaka',100},{'mouseon',20},{'click',-12} }
// this Array i receive in function ActEvents of fivewin. it´s only sample. no return always same array.
for n = 1 to len(MyArray)
#define MyArray[n][1] MyArray[n][2]
next n

- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: Variables
Code: Select all | Expand
FUNCTION MAIN()
LOCAL aArray := { { "SYMBOL1", 10 }, { "SYMBOL2", 20 } }
LOCAL i
FOR i = 1 TO LEN( aArray )
&( "M -> " + aArray[ i, 1 ] + " := " + LTRIM( STR( aArray[ i, 2 ] ) ) )
NEXT
? M -> SYMBOL1
? M -> SYMBOL2
RETURN NIL
EMG
-
- Posts: 603
- Joined: Sun May 04, 2008 8:44 pm
Re: Variables
DOnt have other code ?
that dont need add M-> VAr ?
and i need too call this var in a function OutSide this method.
thanks
that dont need add M-> VAr ?
and i need too call this var in a function OutSide this method.
thanks
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Variables
In order to see data outside the class it has to be defined as data of the class.
You cannot use #DEFINE to define data of the class.
Or, if you want to make a class for each type of ActiveX that you are using, then you can define all the event names as data of the class, then you can assign the values to them when the object is initialized. Then you can access each event from outside the class.
James
Code: Select all | Expand
class myActiveX
data aEvents
...
endclass
Now you can access aEvents:
MsgInfo( oActiveX:aEvents[1][1] )
MsgInfo( oActiveX:aEvents[1][2])
You cannot use #DEFINE to define data of the class.
Or, if you want to make a class for each type of ActiveX that you are using, then you can define all the event names as data of the class, then you can assign the values to them when the object is initialized. Then you can access each event from outside the class.
Code: Select all | Expand
// ActiveX calendar class
CLASS calendar from TActiveX
DATA Campo1
DATA Campo2
endclass
Method new()
...
aEvents = ActXEvents( cTypeLib, act:hActiveX )
::Campo1 := aEvents[1][2]
::Campo2 := aEvents[2][2]
...
return self
oCalendar := calendar():new()
msgInfo( oCalendar:Campo1 ) // returns value, e.g. 30
James
Last edited by James Bott on Sun Sep 06, 2009 4:30 pm, edited 2 times in total.
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Variables
Here is another way you could do it. Create a method getEvent() and pass it the name of the event to get the value.
James
Code: Select all | Expand
method getEvent( cEvent )
local uValue, i
cEvent:= upper(alltrim(cEvent))
for i=1 to len( ::aEvents )
if upper(::aEvents[i]) == cEvent
uValue:= ::aEvents[i][2]
endif
next
return uValue
msgInfo( oCalendar:getEvent("campo1") ) // returns 30
James
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Variables
If you haven't already read them, there are some articles on writing FW classes on my website at http://www.gointellitech.com.
James
James
Re: Variables
lailton.webmaster wrote:MyArray:={ {'campo1', 30}, {'campo2', 50}}
for n = 1 to len(MyArray)
// How make it ?
// #define MyArray[n][1] MyArray[n][2]
next n
msginfo(campo2) // need return 50
i maked it
// it´s OK more is define campo2 as 50 only inside this function when i try msginfo(campo2) in other function
// give me erro variable no exist.
&( " "+Alltrim(MyArray[n][1]) +" := " + Alltrim(str(MyArray[n][1])) )
i try make it too.
&( "Public "+Alltrim(MyArray[n][1]) +" := " + Alltrim(str(MyArray[n][1])) )
More give me erro.
Someone can help ?
thanks
To get the value 50 on the second element of second sub-element is like this (as I understand your code):
....
LOCAL aX
MyArray:={ {'campo1', 30}, {'campo2', 50}}
FOR EACH aX IN MyArray
IF aX[2] == 50 //second sub element of MyArray var
msginfo( aX[1] ) //as 'campo2'
msgInfo( aX[2] ) //as 50
END
NEXT
.....
Regards,
Frances
Kind Regards,
Frances
Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
Frances
Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Variables
Frances,
That may work but assigning value to PUBLICs inside a class is not good OOP practice. It kind of defeats the purpose of having a class. The data should be stored inside the class.
Regards,
James
That may work but assigning value to PUBLICs inside a class is not good OOP practice. It kind of defeats the purpose of having a class. The data should be stored inside the class.
Regards,
James
-
- Posts: 603
- Joined: Sun May 04, 2008 8:44 pm
Re: Variables
James Bott wrote:Frances,
That may work but assigning value to PUBLICs inside a class is not good OOP practice. It kind of defeats the purpose of having a class. The data should be stored inside the class.
Regards,
James
Thanks for the Idea. Best solution.
Kind Regards,
Frances
Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
Frances
Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15