Scripting

G

Guest

Hello, I am trying to figure out how to do some scripting.

Can I script in csharp?
Can I script in VBScript if my web page has been developed using csharp?

Can I iterate though a datatable object in my script file? How can I
reference the datatable object which was created in my code-behind form?

Thanks in advance for your assistance!!
 
K

Kevin Spencer

Scripting, by definition, is not compiled. .Net, by definition, IS compiled.
Therefore, you cannot do scripting with ANY .Net language.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
B

bruce barker

actually jscript.net has a complete scripting engine. code executed thru the
eval() is actully run thru an interpreter, rather than compiling/jiting code
into the app domain (the standard approach in writing c# scripts).

-- bruce (sqlwork.com)



| Scripting, by definition, is not compiled. .Net, by definition, IS
compiled.
| Therefore, you cannot do scripting with ANY .Net language.
|
| --
| HTH,
| Kevin Spencer
| .Net Developer
| Microsoft MVP
| Neither a follower
| nor a lender be.
|
| | > Hello, I am trying to figure out how to do some scripting.
| >
| > Can I script in csharp?
| > Can I script in VBScript if my web page has been developed using csharp?
| >
| > Can I iterate though a datatable object in my script file? How can I
| > reference the datatable object which was created in my code-behind form?
| >
| > Thanks in advance for your assistance!!
|
|
 
P

Peter Strøiman

Hi.

I implemented VB Script by using the MSScriptControl ActiveX component. Add
this as an ActiveX component reference.

You can add objects to the script control that will be accessible as global
variables in your script. The .NET Framework will automatically generate a
wrapper around you component that will allow the script to communicate with
it.
You can then add code. Call a function and get the return value.
There is however a problem with calling functions in the script that has
byref-arguments. You can get the value in, but not out. There is a solution
but it is pretty hard-core (it involves modyfing the automaticcaly generated
wrapper for the ActiveX component).

Please note, that it is possible to create scripts in VB.NET using the
Microsoft.Vsa namespace, but it is IMHO way too complex.

IScriptControl scriptControl;
scriptControl = new ScriptControlClass();
try
{
scriptControl.Language = "VBScript"; // could also be JScript.
// Add an object that is accessible from the script.
scriptControl.AddObject("SomeObject", someObject , false);
// Add some code to the script.
scriptControl.AddCode( code );
// Execute a function
object returnValue = scriptControl.Run(functionName, arguments );
}
finally
{
// This is a COM Object so we should release it manually.
System.Runtime.InteropServices.Marshal.ReleaseComObject(
scriptControl );
}
 
K

Kevin Spencer

Well, that is news to me, and interesting. I'll pack that bit of info away.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top