Hello,
May i get the number of references for one object? Is it possible?
Can i know how many references each object has in the garbage colletion control?
Thank you,
First, sorry about my english mistakes...i don´t know how to write in english very well...
I need to make a function like a Handle function.....for objects of a particular class ...
example:
def var x as handle no-undo.
def var y as handle no-undo.
def var str as char no-undo.
str = string(x).
y = handle(str).
So.. i have my class ellen...
def var x as ellen no-undo.
def var y as ellen no-undo.
def var str as char no-undo.
str = x:tostring().
How can I get the object from str??
I made the next code....but it is very expansive ( time) when i have many objects.
Define Variable myObject As Char no-undo.
define variable loop as Progress.Lang.Object no-undo.
Assign myObject = "1234".
loop = Session:First-object.
Do While valid-object(loop) :
if (loop:tostring() = myObject) then Do:
MESSAGE "Found!!!" VIEW-AS ALERT-BOX INFO BUTTONS OK.
Leave.
End.
loop = loop:Next-sibling.
End.
As alternative solution......I am saving the objects in a temp table.. but the garbage colletion never deletes my object because they have an reference in my temp-table.......... and I dont have when i should delete the record..... :/
Again - what problem are you trying to solve?
I need to make a function like a Handle function.....for objects of a particular class.
First, sorry about my english mistakes...i don´t know how to write in english very well...
I need to make a function like a Handle function.....for objects of a particular class ...
example:
def var x as handle no-undo.
def var y as handle no-undo.
def var str as char no-undo.
str = string(x).
y = handle(str).
So.. i have my class ellen...
def var x as ellen no-undo.
def var y as ellen no-undo.
def var str as char no-undo.
str = x:tostring().
How can I get the object from str??
I made the next code....but it is very expansive ( time) when i have many objects.
Define Variable myObject As Char no-undo.
define variable loop as Progress.Lang.Object no-undo.
Assign myObject = "1234".
loop = Session:First-object.
Do While valid-object(loop) :
if (loop:tostring() = myObject) then Do:
MESSAGE "Found!!!" VIEW-AS ALERT-BOX INFO BUTTONS OK.
Leave.
End.
loop = loop:Next-sibling.
End.
As alternative solution......I am saving the objects in a temp table.. but the garbage colletion never deletes my object because they have an reference in my temp-table.......... and I dont have when i should delete the record..... :/
Flag this post as spam/abuse.
Each reference to an object is a "handle" or pointer to that object. What it sounds like is you're looking to create a collection of objects that you want to do similar things to.
Are you trying to write your own object manager instead of relying on garbage collection? If so, then each request for an object you would need to keep your own count and then decrement that count when the object is no longer used. I.e., do the same thing the GC is doing for you.
If the OP's using an older version of Progress, she may not have garbage collection in the language hence the need to count references...
“If the OP's using an older version of Progress, she may not have a garbage collection hence the need to count references...”
Good point. But no one should do new development on 10.1x anymore!
If that is the requirement, Tim, the OP could probably adapt the ideas here www.oehive.org/PseudoSingleton
[quote user="Mike Fechner"]
But no one should do new development on 10.1x anymore!
[/quote]
Some developers don't have a choice in the matter....
Thank you ........ do you think this is the best solution?
I did the same..... and "solve" my problem except because too time-consuming
Define Variable myObject As Char no-undo.
define variable loop as Progress.Lang.Object no-undo.
Assign myObject = "1234".
loop = Session:First-object.
Do While valid-object(loop) :
if (loop:tostring() = myObject) then Do:
MESSAGE "Found!!!" VIEW-AS ALERT-BOX INFO BUTTONS OK.
Leave.
End.
loop = loop:Next-sibling.
End.
If you follow your approach, I would change a few things - especially the data type you store the object reference in. Do not use ToSTring() for this stuff, since you cannot know what value is returned. It might have a reference in it - per the default - but there are times when it won't.
define variable myObject as INTEGER. Assign myObject = 1234. loop = Session:First-object. Do While valid-object(loop) : if INTEGER(loop) eq myObject) then Do: MESSAGE "Found!!!" VIEW-AS ALERT-BOX INFO BUTTONS OK. Leave. End. loop = loop:Next-sibling. End.
Hi Peter,
Thank you for your advices.
It was much better than using ToString, but, even so, if I have a set of 1000 objects and realize 1000 searches this way the time required is extremely high =(
There is no function that returns the object from reference, is there? another solution besides using loop...