How to change contents of .CS file at Runtime
-
27 Temmuz 2012 Cuma 13:50
i have a function in my .cs file like
int anycalc( int a, int b)
{
return a+b
}
At runtime, i want to give user the option to code the code in the anycalc function that exists in the CS file.
like if user creates wants [a*b/b+b*2] he can edit that function directly in the cs file
Is it possible?
or can i do it in a .H file?
An Idea, can infect your mind
Tüm Yanıtlar
-
27 Temmuz 2012 Cuma 13:55
Hi,
remember, everything IS possible.
The only question is, if you (or we here) are capable of creating it (the code I mean).
So, I didnt really get you question. You have some method (anycals), and you showed us an exmaple od "a+b", and if I have understood you well, you would like that instead of "a+b" there is a function that will dinamically change depending on the user`s input.
Am I right?
---
So if user writes "a+b*c" the code should calculate it. Correct?
Mitja
-
27 Temmuz 2012 Cuma 14:26Moderatör
Do you want allow users to do something similar to this?
MathParser - Math Formula Parser - CodeProject
Rudy =8^D
Mark the best replies as answers. "Fooling computers since 1971."
- Yanıt Olarak Öneren servy42Microsoft Community Contributor 27 Temmuz 2012 Cuma 16:30
- Yanıt Olarak İşaretleyen shahzeb2019 31 Temmuz 2012 Salı 13:47
-
27 Temmuz 2012 Cuma 16:01You can create an GUI for User to create his own formula. like just ask for the user to insert folrmula into textArea and validate this formula by your programming logic and if its validated and save it for this user.
Kapul
-
31 Temmuz 2012 Salı 09:36
Kapul, i have that GUI for user control ready.
This is the main idea. I want a person to build a mathematical formulae like a+b+c/d[ The user would have complete control of whatever he wants to do].
Then i want user to define the values of variable eg. a,b,c,d....
Now i want that user gets the answer right there on the website. how can i do that?
is there anyway to achieve this?
An Idea, can infect your mind
-
31 Temmuz 2012 Salı 09:37
RudeDog2, i dont want to build that kind of project.
This is the main idea. I want a person to build a mathematical formulae like a+b+c/d[ The user would have complete control of whatever he wants to do].
Then i want user to define the values of variable eg. a,b,c,d....
Now i want that user gets the answer right there on the website. how can i do that?
Its a complex maths calculator on the web. and i want my calculator to return multiple values as well.
is there anyway to achieve this?
An Idea, can infect your mind
-
31 Temmuz 2012 Salı 11:50
Hi Shahzeb2019
What you basically want to do (as far as I understood) is that You want the User to enter an Expression (Formula)
that should be evaluated and then you want your application to calculate the result.
Ex: User enters: 5 + 2 -1
Output = 6
This is also known as Infix Expression. Check this for a pseudo algorithm to do this.
.NET Maniac -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
31 Temmuz 2012 Salı 12:32Moderatör
RudeDog2, i dont want to build that kind of project.
This is the main idea. I want a person to build a mathematical formulae like a+b+c/d[ The user would have complete control of whatever he wants to do].
Then i want user to define the values of variable eg. a,b,c,d....
Now i want that user gets the answer right there on the website. how can i do that?
Its a complex maths calculator on the web. and i want my calculator to return multiple values as well.
is there anyway to achieve this?
An Idea, can infect your mind
I don't see that much of a difference. The most significant difference that I can see is that you want a "web" application and the example is a WinForms application. The sample is equipped to handle a specific type of formula, not an infinite variety.
To allow user the freedom to have "complete control" is a tall order. Mathematical formulas can get pretty complex in an infinite variety of ways. Like it or not, you will have to initially establish some guidelines and rules. As time goes on, you will be able add a wider and wider range of types of formulas to your application.
Regardless, the user should never have "complete control", at best only the illusion of it. Case in point, what if the user inputs a formula that results in a singularity, which in many cases in not exactly an error. Can the same tool be used to enter a first order polynomial and then multidimensional matrix field equations that physicists use to compute gravitational effects on space/time around black holes?
Mark the best replies as answers. "Fooling computers since 1971."
- Yanıt Olarak İşaretleyen shahzeb2019 31 Temmuz 2012 Salı 13:46