在运行时调用数学函数 [英] calling math functions at run time

查看:72
本文介绍了在运行时调用数学函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道怎么问这个,所以有人不会误读它但是这里

去了。


在运行时我想要能够评估数学库中的函数,

但是在设计时我不知道需要什么函数。


我知道我能做到


如果Userinput =" SINE"然后zz = Sin(无论如何)


但我想做的是zz = MyMappingToMath(用户输入)


例如

假设用户在运行时输入SINE(30)

如果我没有特别的

条款,我有什么方法可以得到SINE(30)的值在设计时为SINE设计?


谢谢

解决方案

如果我理解正确的话,


你可以:

1.创建定义你的

语法的函数和/或运算符重载,

2让用户提供代码并动态编译到内存中,


我的意思是Activator.CreateInstance等等

(这需要一些很少熟悉反思,CodeDOM,

代表...)

http://www.thescripts.com/forum/thread348196.html

....


Franky ha scritto:

我不知道怎么问这个,所以有人不会误读它但是这里

去了。


在运行时,我希望能够从数学库中评估函数,

但在设计时我不知道需要什么函数。


我知道我可以做


如果Userinput =" SINE"然后zz = Sin(无论如何)


但我想做的是zz = MyMappingToMath(用户输入)


例如

假设用户在运行时输入SINE(30)

如果我没有特别的

条款,我有什么方法可以得到SINE(30)的值在设计时为SINE设计?


谢谢


Franky,


实际上没有,但你可以使用脚本(VBS)我认为那些功能

在那些地方。

http://www.vb-tips.com/dbpages.aspx?。 ..1-2b03e1a439ae

我希望这能给出一些想法/ s


Cor


"永邦" < fr ********** @ a-znet.comschreef in bericht

新闻:OZ ************** @ TK2MSFTNGP04.phx .gbl ...


>我不知道如何问这个问题,以致有人不会误读它,但是这里
去了。 />

在运行时,我希望能够从Math

库中评估函数,但在设计时我不知道需要哪些函数。 />

我知道我可以做


如果Userinput =" SINE"然后zz = Sin(无论如何)


但我想做的是zz = MyMappingToMath(用户输入)


例如

假设用户在运行时输入SINE(30)

如果我没有特别的

条款,我有什么方法可以得到SINE(30)的值在设计时为SINE设计?


谢谢



谢谢,我用过但现在我我想知道我是否真的可以解释一个

小型基础课程

谢谢,就是我需要的东西


" Cor Ligthert [MVP]" < no ************ @ planet.nlwrote in message

news:uJ ************** @ TK2MSFTNGP03.phx .gbl ...


Franky,


其实没有,但你可以使用脚本(VBS)我认为那些

的功能在哪里。

http://www.vb-tips.com/dbpages.aspx?...1-2b03e1a439ae


我希望这能给出一些想法/ s


Cor


"永邦" < fr ********** @ a-znet.comschreef in bericht

新闻:OZ ************** @ TK2MSFTNGP04.phx .gbl ...


>>我不知道如何问这个问题,以致有人不会误读它,但这里
去了。

在运行时我希望能够从Math
库中评估函数,但在设计时我不知道需要哪些函数。

我知道我能做到

如果Userinput =SINE然后zz = Sin(无论如何)

但我想做的是zz = MyMappingToMath(userinput)

例如
假设用户输入SINE(30)at运行时间
如果我在设计时没有为SINE做出特殊的规定,有什么办法可以获得SINE(30)的价值吗?

谢谢




I don''t know how to ask this so that someone will not misread it but here
goes.

At run time I want to be able to evaluate functions from the Math library,
but at design time I do not know what functions will be needed.

I know I can do

If Userinput = "SINE" Then zz = Sin(whatever)

but what I want to do is zz= MyMappingToMath(userinput)

e.g
Suppose the user inputs SINE(30) at run time
Is there some way I can get the value of SINE(30) if I made no special
provisions for SINE at design time?

Thanks

解决方案

If I understand you correctly,

you could:
1. Create functions and/or operator overloads that define your
syntax,
2. Let the user provide the code and compile it to memory on the fly,

I mean the Activator.CreateInstance stuff and so on
(this requires some little familiarity with reflection, CodeDOM,
delegates ... )

http://www.thescripts.com/forum/thread348196.html
....

Franky ha scritto:

I don''t know how to ask this so that someone will not misread it but here
goes.

At run time I want to be able to evaluate functions from the Math library,
but at design time I do not know what functions will be needed.

I know I can do

If Userinput = "SINE" Then zz = Sin(whatever)

but what I want to do is zz= MyMappingToMath(userinput)

e.g
Suppose the user inputs SINE(30) at run time
Is there some way I can get the value of SINE(30) if I made no special
provisions for SINE at design time?

Thanks


Franky,

In fact not, but you can use scripting (VBS) I thought that those functions
where in those.

http://www.vb-tips.com/dbpages.aspx?...1-2b03e1a439ae
I hope this gives some idea/s

Cor

" Franky" <fr**********@a-znet.comschreef in bericht
news:OZ**************@TK2MSFTNGP04.phx.gbl...

>I don''t know how to ask this so that someone will not misread it but here
goes.

At run time I want to be able to evaluate functions from the Math
library, but at design time I do not know what functions will be needed.

I know I can do

If Userinput = "SINE" Then zz = Sin(whatever)

but what I want to do is zz= MyMappingToMath(userinput)

e.g
Suppose the user inputs SINE(30) at run time
Is there some way I can get the value of SINE(30) if I made no special
provisions for SINE at design time?

Thanks



Thanks, I used that but now I''m wondering if I can actually interpret a
small Basic program
Thanks, just what I needed

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uJ**************@TK2MSFTNGP03.phx.gbl...

Franky,

In fact not, but you can use scripting (VBS) I thought that those
functions where in those.

http://www.vb-tips.com/dbpages.aspx?...1-2b03e1a439ae
I hope this gives some idea/s

Cor

" Franky" <fr**********@a-znet.comschreef in bericht
news:OZ**************@TK2MSFTNGP04.phx.gbl...

>>I don''t know how to ask this so that someone will not misread it but here
goes.

At run time I want to be able to evaluate functions from the Math
library, but at design time I do not know what functions will be needed.

I know I can do

If Userinput = "SINE" Then zz = Sin(whatever)

but what I want to do is zz= MyMappingToMath(userinput)

e.g
Suppose the user inputs SINE(30) at run time
Is there some way I can get the value of SINE(30) if I made no special
provisions for SINE at design time?

Thanks




这篇关于在运行时调用数学函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆