Thread object accesibility

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Thread object accesibility

#1 Post by bwolfsohn »

In our xb2net application, i have a thread object.

i can refer to it in code

Code: Select all

x:=oThread:getvar("userid")
However, i can't figure out if it's possible to access this dynamically i.e.

Code: Select all

x:=[oThread:getvar("userid")]
? &x
is this possible ??
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Thread object accesibility

#2 Post by skiman »

Hi Brian,

Maybe as follows?

Code: Select all

x:='{|o| o:getvar("userid")}'
bBlock := &(x)
? eval(bBlock,oThread)
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Thread object accesibility

#3 Post by rdonnay »

The macro will work only if oThread is a private or public variable.
The eXpress train is coming - and it has more cars.

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Thread object accesibility

#4 Post by bwolfsohn »

is it possible to only macro the var portion in some way ???

x:="userid"
? oThread:getvar(&x)
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Thread object accesibility

#5 Post by skiman »

Brian,

Code: Select all

x:='userid'
bBlock := &('{|o| o:getvar("'+x+'")}')
? eval(bBlock,oThread)
Best regards,

Chris.
www.aboservice.be

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Thread object accesibility

#6 Post by bwolfsohn »

skiman wrote:Brian,

Code: Select all

x:='userid'
bBlock := &('{|o| o:getvar("'+x+'")}')
? eval(bBlock,oThread)

Chris,

this worked fine for oThread..

But, with no getvar for oSession:profile , i'm stuck again... :pray: :pray:

oSession and oSession:profile are both objects.. i ned to dynamically grab the value of a class var in profile...
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Thread object accesibility

#7 Post by skiman »

Hi Brian,

Can you explain this? It should work without any problem.

Also the previous posted code can be optimized this way:

Code: Select all

bBlock := {|o,x| o:getvar(x)}
x:="userid"
? eval(bBlock,oThread,x)
For your oSession sample:

Code: Select all

bBlock := {|o,cVar,oProfile| oProfile:=o:profile, oProfile:getvar(cVar) }
x := 'userid'
cUserid := eval(bBlock,oSession,x)
Best regards,

Chris.
www.aboservice.be

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Thread object accesibility

#8 Post by bwolfsohn »

skiman wrote:Hi Brian,

Can you explain this? It should work without any problem.

Also the previous posted code can be optimized this way:

Code: Select all

bBlock := {|o,x| o:getvar(x)}
x:="userid"
? eval(bBlock,oThread,x)
For your oSession sample:

Code: Select all

bBlock := {|o,cVar,oProfile| oProfile:=o:profile, oProfile:getvar(cVar) }
x := 'userid'
cUserid := eval(bBlock,oSession,x)
Chris,
The oThread example works perfectly...
the oProfile example does not...
getvar is not a method in osession

it looks like i need to add an inline method getvar to my oSession class...
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: Thread object accesibility

#9 Post by Auge_Ohr »

bwolfsohn wrote: The oThread example works perfectly...
the oProfile example does not...
getvar is not a method in osession
what about using oProfile:Cargo Slot ?
greetings by OHR
Jimmy

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Thread object accesibility

#10 Post by skiman »

Hi Brian,

Just a wild guess:

Code: Select all

bBlock := {|o,cVar,oProfile| oProfile:=o:profile, oProfile:&(cVar) }
x := 'userid'
cUserid := eval(bBlock,oSession,x)
Best regards,

Chris.
www.aboservice.be

Post Reply