Welcome to APLNext Sign in | Join | Help
in
Community Website
Blogs Forums

Setting C# method attributes using [APLNex.APL.Objects.AplFuncitons()]

Last post 02-08-2007, 12:10 PM by fredmw. 1 replies.
Sort Posts: Previous
  • Setting C# method attributes using [APLNex.APL.Objects.AplFuncitons()]

     02-07-2007, 2:46 PM

    I tried to replicate Fred’s demo from the January 5th (or 12th) screen cast where he enabled C# methods with APL attributes.   See my C# code below. 

    I was unable to reference the APLadd function from Cielo using the,  a APLadd b , notation it worked just like the CSadd.   So [APLNext.APL.Objects.AplFunctions()] did not seem to work.   My C# class library project has APLNext.APL listed as a reference.   I was able to use C# funcitions: APLadd, CSadd and dltb   from Cielo if they were referenced using the C# notation  func().    Executing   
     
    10 APLadd 21   from Cielo returned:

                10  <built-in function APLadd>  21

    Here is the C# Class code:

    public class CStestClass1

    {

        [APLNext.APL.Objects.AplFunction()]

        public static object APLadd(object a, object b)

        {

            if ((a is int) && (b is int))

            {

                return (int)a + (int)b;

            }

            throw new ApplicationException("Domain Error - interger expected");

        }

        public static int CSadd(int a, int b)

        {

            return a + b;

        }

        public static object dltb(object a)

        {

            if (a is string)

            {

                return ((string)a).Trim();

            }

            throw new ApplicationException("Domain Error - string expected");

        }

    }

  • Re: Setting C# method attributes using [APLNex.APL.Objects.AplFuncitons()]

     02-08-2007, 12:10 PM

    George,

    Your code looks good, you just need to do a using down to the class level in your Visual APL class or the Visual APL Session.

    For instance, if your namespace had been "ClassLibrary1", then your using statement would look like this:

    using ClassLibrary1
    using ClassLibrary1.CStestClass1

    I compiled your example and it worked just fine.  Here is the code I used in the session to import your DLL and test the function:

          refbyfile @"c:\samps\WindowsApplication39\ClassLibrary1\bin\debug\ClassLibrary1.dll"
          using ClassLibrary1
          using ClassLibrary1.CStestClass1
          10 APLadd 20
    30

    Let me know if this works for you,

    Fred

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems