1

I'm a complete newbie when it comes to APL, and I hope some of you fine folks might be able to help me...

I have a class library written in C# and exported to a dll. I then import this class in Dyalog APL (v14.0) and I am able to instantiate objects of the types defined in the class library and can access fields as needed. However I find myself unable to iterate over items of any List<T>.

C# class (nothing to write home about but I included it just in case):

namespace Motor_lib.Objects
{
    public class Motor
    {
        public int? Id_motor = null;
        public string Reference = null;
        public string Message = null;
        public DateTime? Date_modif = null;
        public int? Id_hydrotorque = null;
        public int? Id_spline = null;
        public int? Id_pivot = null;
        public int? Id_cam_cover = null;
        public int? Id_cam_B_sup = null;
        public int? Id_status = null;
        public int? Id_CalcType = null;
        public Status Status = null;
        public Calculation_type Calculation_type = null;
        public Spline Spline = null;
        public List<Relation> Compatible_Valving_covers;
        public Valving_cover Valving_cover = null;
        //even more fields...

        public Motor()
        {
        }

        //Methods...
    }
}

Back to APL:

⎕using ← 'Motor_lib.Objects,D:\Motor_lib.dll'
⍝Fetch a motor from db
myMotor ← Motor.Get 5
⍝The following works
myMotor.Reference
⍝produce the following output
Ref of 5
myMotor.Reference ← ⊂'new ref of 5' ⍝Also works
⍝Now if i do 
myMotor.Compatible_Valving_covers.Count
⍝Produces 2 which is correct
myMotor.Compatible_Valving_covers[1].Reference ⍝Also works; I can access the 
reference...

My question is: How do I iterate over each element of the List and display their field values? I tried the following with no luck:

]display ⌷¨myMotor.Compatible_Valving_covers
┌────────────────────────────────────────────────────────────┐
│ ┌→───────────────────────────────────────────────────────┐ │
│ │ Motor_lib.Objects.Relation  Motor_lib.Objects.Relation │ │
│ └#───────────────────────────────────────────────────────┘ │
└∊───────────────────────────────────────────────────────────┘

How do I get it to display me the values of the fields of Relation (like Relation.Id or Relation.Reference ...)

Sorry for the quite long question, and if it is unclear. Any help is appreciated.

Adám
  • 6,573
  • 20
  • 37
  • I'm not sure I completely understand, but try removing the `¨`, like: `]display ⌷myMotor.Compatible_Valving_covers`. – Adám Dec 10 '17 at 00:52
  • Could you pls. add the result of `]display ⌷myMotor.Compatible_Valving_covers.Reference` to your question? (Hopefully that helps to answer...) – MBaas Dec 11 '17 at 07:31
  • Sorry for my late response, @Adám `code`]display ⌷myMotor.Compatible_Valving_covers ┌→───────────────────────────────────────────────────────┐ │ Motor_lib.Objects.Relation Motor_lib.Objects.Relation │ └#───────────────────────────────────────────────────────┘ @MBaas `code`]display ⌷myMotor.Compatible_Valving_covers.Reference * Command Execution Failed: VALUE ERROR – Jean-Benoist Brault Dec 13 '17 at 14:53

1 Answers1

2

Ok, it appears that i was close all i needed to do was :

⍝ It works !!! 
(⌷¨myMotor.Compatible_Valving_covers).Reference
Test_vc_01  Test_vc_02