Question: Problem with read package from multiple files

Hi all,

I have a problem when creating package by using 'read' function to concatenate package's elements

Case1: Create package normally, Proc1 and Proc2 are exported

restart;
###################################
# Define package Test contains 2 proc: Proc1 and Proc2
##################################
Test := module()
    option package;
    export Proc1, Proc2;

    Proc1 := proc()
        description "Proc1() is an element of package Test";
        printf("In Proc1\n");
    end proc;
    Proc2 := proc()
        description "Proc2 is an element of package Test";
        printf("In Proc2\n");
        Proc1();
    end proc;
end module;

#################################
# Try to call Proc1 from Proc2
#################################
Test:-Proc2();

Console output:

> Test:-Proc2();
In Proc2
In Proc1

==> The result looks OK

 

Case2: Split Proc1 into another file and include it into master file by using 'read' function, Proc1 and Proc2 are exported

restart;
###################################
# Define package Test contains 2 proc: Proc1 and Proc2
##################################
Test:= module()
    option package;
    export Proc1, Proc2;

    ###########################
    # Code to concatenate "Proc1.maple" here
    ###########################

    read "Test/Proc1.maple";

    Proc2 := proc()
        description "Proc2 is an element of package Test1";
        printf("In Proc2\n");
        Proc1();
    end proc;


end module;


#################################
# Try to call Proc1 from Proc2
#################################
Test:-Proc2();

Console output:

> Test:-Proc2();
In Proc2
                                    Proc1()

==> The Proc1 seem does not execute or evaluate

 

Case3: Split Proc1 into another file and include it into master file by using 'read' function, just export Proc2, not export Proc1

restart;

###################################
# Define package Test contains 2 proc: Proc1 and Proc2
##################################
Test:= module()
    option package;
    export Proc2;

    ###########################
    # Code to concatenate "Proc1.maple" here
    ###########################

    read "Test/Proc1.maple";

    Proc2 := proc()
        description "Proc2 is an element of package Test1";
        printf("In Proc2\n");
        Proc1();
    end proc;


end module;


#################################
# Try to call Proc1 from Proc2
#################################
Test:-Proc1();

Console output:

> Test:-Proc2();
In Proc2

In Proc1

==> The result looks good

 

Please help to explain the problem from case 2 and case 3. If I want to split package proc into many files, how can I do?

 

Please Wait...