I have developed an application which can create Xml files from Xml schema with some user defined rules for generating value for each node.
I want to give my user the ability to write scripts for generating value for each node and in this scripts user should be able to refer to generated value of other nodes .
a simple script will be something like :
returtn (#node1.value + 10) ;
I don't know what will be the value of #node1.value because the file generation process hasn't started yet.
so what is the solution do I have to replace it every time with the generated value and then run the script or is there a better way to do something like this ?
may be I have to run this script thousand of times to generate value for created instances so which scripting language is the fastest one for me to use ?
thanks
You can look at IronPython.
If you are looking for a script language with a sysntax similar to C#, then you can look at CS-Script.
Have you looked at using C# as your scripting language?
http://www.csscript.net/
Use locks :-). If someone invokes get_method of the property that isn't set just lock the caller until value is set.
PowerShell embeds well into a C# application, here's how from the PowerShell Team Blog
Related
I have to create a function in C# allowing to calculate Excel formulas entered in a string:
for example :
ROUND(COUNTIF(['YES', 'NO'],'YES')*(100/4),1)
I absolutely have to use a free library, but I can't find anything to do so in C#.
Has anyone come across this problem before ?
Thanks for your help
Explications of the app context :
This function receives as a parameter a string which has already been generated on another application over which I do not have control.
the need is to find a way evaluate this kind of string containing some Excel functions.
EPPlus v4 is LGPL. It can create Excel files but not execute them AFAIK. But you could automate Excel afterwards.
As #DS_London said: it is a weird use case, are you sure you got it right?
I'm trying to run a function in C# from UnityScript. My UnityScript file has:
GetComponent("C#File").C#FunctionName();
But in the editor it's telling me that the function isn't a member of UnityEngine.Component.
Try
GetComponent<"C#File">().C#FunctionName();
You need to put the "to be accessed" script in one of the folders thats compiled earlier.
That does not only mean the editor folder, but also Plugins, Standard Assets and Pro Assets
That way scripts of the other languages are able to work with it.
The only alternative is not to access it directly at all and use SendMessage instead
The least amount of trouble and headache is present if you just focus on one language instead of mixing 2+ languages
I am hoping that someone might be able to help me out here. I am relatively new to C# and am trying to execute some Python code I wrote from within a C# winform app.
What I would like to do is input a name from a text box within the winform and have it process through the python scripts and return a result in another textbox on the winform.
I have found several good examples of how to execute a single script within C#, but I am having some trouble understanding how I can reference multiple scripts.
As an example, I have one python script that references two other scripts within code
from FindTelephone import *
from FindAddress import *
def createPerson(name)
telephone = FindTelephone(name)
address = FindAddress(name)
....
Is there a way to have C# point to a reference of my other python scripts before running my main script?
Thanks in advance for the help.
Marshall
Like in these posts?:
Call Python function from c# (.NET),
run a python script from c#?
Or
You might want to look into pythonnet.
Or
If you want an easyer way of doing this then I recommend using Iron Python in place of normal Python. IronPython is an open-source implementation of the Python programming language which is tightly integrated with the .NET Framework. Means that it is much easyer to use with C# and Windows Forms and looks almost just like normal Python.
Or
For in case you are using Visual Studio, VS has some Python tools that might help you in your quest. Link. You can find more documentation Here This last link is provided by Jedediah from comments so vote his comment up if you liked this last link.
Other handy link: Integrating Python With Other Languages
in my project i have some sort of level builder that create a new text file and save all my wanted data as readable json string in 1 line.
while the project run in web build or in unity it self i can read the levels from that text file and every thing working great, in mobile builds that doesn't work.
my question is:
is there a way to create or add lines to a class at runtime?
for example write a new string in the class at run time that will stay there after run time is over?
No, there isn't. At least not at mobile platforms.
But you should be able to parse JSON on mobile platforms if you set the Api Compatibility Level to .Net 2.0, not .Net 2.0 Subset and disable Strip Engine Code in the Player Setting.
As #Tijmen said there is no way to change a C# class at runtime. But I see no reason to do so. Instead you should change the JSON string, write it to the file and recreate the level instance.
Looking at your code reveals that you are writing to Application.dataPath which is not writable in iOS player. So it should work when your are using Application.persistentDataPath.
Further on I would refrain from calling the folder Resources as this has a special meaning in Unity.
No there isn't, but you can make an ArrayList instead and put the info from the text file into the ArrayList. Then extract information from the ArrayList.
I want to write a program is C# that will allow me to execute a vbscript step by step like I would do in a debugger. I know I can run vbscript by creating a new process class form System.Diagnostics but I was wondering if that will allow me to execute one line of vbs code at a time.
Background:We have this UI automation framework that generates vbscript based on the tests written in an excel file. This vbscript in turn make calls to a dll that performs actions on the application.
We want to get away from excel and put this automation framework in silverlight.
So what I need is an ability for the user to run though step by step through that vb script like a debugger on an interpreter would.
Any ideas?
You'd have to implement your own scripting host. Don't know much about it, ought to be challenging in C#. Start reading here.
You might try the MS ScriptControl.
You should be able to execute your code line by line, however maintaining the state might be a challenge depending on how many variables are being used by the VBScript or if you are just making one distinct call per line.