Author Topic: The return integer value is not right by LispFunction .  (Read 1609 times)

0 Members and 1 Guest are viewing this topic.

gswang

  • Newt
  • Posts: 117
The return integer value is not right by LispFunction .
« on: November 23, 2016, 01:37:48 AM »
     :no:
    public class MyCommands
    {
        [LispFunction("MyTest")]
        public int MyLispFunction(ResultBuffer args) // This method can have any name
        {
            return 120000;
        }
    }

命令: (setq n (MyTest))
-11072

n is -11072, not 120000
why? thank you, everyone.

kpblc

  • Bull Frog
  • Posts: 396
Re: The return integer value is not right by LispFunction .
« Reply #1 on: November 23, 2016, 01:39:44 AM »
Try to use not int, but Int32
Sorry for my English.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: The return integer value is not right by LispFunction .
« Reply #2 on: November 23, 2016, 02:04:30 AM »
Hi

Returning a typed value instead of int (or Int32 which is the same) allows you to specify the returned type and avoids implicit cast from int to short).

Code - C#: [Select]
  1. [LispFunction("foo")]
  2. public TypedValue Foo (ResultBuffer resbuf)
  3. {
  4.     return new TypedValue((int)LispDataType.Int32, 120000);
  5. }
Speaking English as a French Frog

gswang

  • Newt
  • Posts: 117
Re: The return integer value is not right by LispFunction .
« Reply #3 on: November 23, 2016, 02:10:20 AM »
Success, thank you very much.