- Aug
- 2,059
- 83
Here's how I access functions written in C# from TCC, using the new PSHELL and @PSHELL in TCC 21.
First, create a file with your C# code, in this example, TCCPS1.cs;
Next, load this class into memory;
Use one of the functions from the class;
With the class loaded into memory, you can also use the @PSHELL function;
...or...
You can also use VB Code from TCC, in this example, TCCPS1.vb;
Joe
First, create a file with your C# code, in this example, TCCPS1.cs;
Code:
public class MathClass
{
public static long Multiply(long x, long y)
{
return x * y;
}
public static long Add(long i, long j)
{
return i + j;
}
}
Code:
pshell /s "add-type -path c:\utils\tccps1.cs"
Code:
pshell /s "[MathClass]::Add(652,4)"
Code:
echo %@pshell[[MathClass]::Add(652,4)]
Code:
[c:\utils]set MathAdd=%@pshell[[MathClass]::Add(652,4)]
[c:\utils]echo %MathAdd
656
You can also use VB Code from TCC, in this example, TCCPS1.vb;
Code:
Public Class MathClass
Public Shared Function Multiply(ByVal x As Long, ByVal y As Long) As Long
Return x * y
End Function
Public Shared Function Add(ByVal i As Long, ByVal j As Long) As Long
Return i + j
End Function
End Class
Joe