Thanks for the concept Barry. It worked after a little bit modification.

Regards
Krish



-----Original Message-----
From: Bayliss, Barry [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 22, 2005 11:26 AM
To: Axapta-Knowledge-Village@yahoogroups.com
Subject: RE: [Axapta-Knowledge-Village] Return Array of Class



Krish,


Another way would be to use containers. Your code would be something
like 

Container
        Initialise
        (
        )
{
        Container                       Results;
        class1                  class1; 
        ;

        while 
        select  table1
        where   table1.NoYesId == true
        {
                class1  = new class1(element);  
                class1.initmethod(table1);              
                Results += [Class1.pack()];
        }
        Return  Results;
}



Barry.


-----Original Message-----
From: Krishnendu Roy [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 22 February 2005 3:46 PM
To: Axapta-Knowledge-Village@yahoogroups.com
Subject: [Axapta-Knowledge-Village] Return Array of Class


Hi All
I am facing a problem of holding the initialised value of a class when
it is put in an array.

The coding is done in a form method. Following is the code 
        
    array A1 = new array(types::Class);
    class1 class1;      
    int i = 1;
    ;

    while select table1
    where table1.NoYesId == true
    {
        class1 = new class1(element);   //instantiate the class
        class1.initmethod(table1);              //The method is
responsible to
initialise some values of the
class with the selected record in
table1

        A1.value(i,class1);                     //The instantiated &
initialised                                                     class is
added as an array element
          Class1 = null;                                

        i++;

    } 

The first loop executed perfectly without any problem. But as soon as
the class1 is getting instantiated & initialised for the second record
the first element in the array got overwritten with the second record.
AS a result at the end of second loop both the elements of the array are
initialised with the second record. And after the execution of the
entire loop the array contains number of elements same as no of selected
records; but none of the elements is initialised.
The cause of the problem may be the array is containing the reference of
the object instead of actual object. As soon as the object is
re-initialised or nullified the values get lost. If that is the reason
how to overcome that.
Any other suggestions will be helpful for me.

Thanks & regards
Krish







Sharing the knowledge on Axapta. 
Yahoo! Groups Links



 






Sharing the knowledge on Axapta. 
Yahoo! Groups Links



 





------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/kGEolB/TM
--------------------------------------------------------------------~-> 

Sharing the knowledge on Axapta. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/Axapta-Knowledge-Village/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to