0

One of my friend has an application built in Clipper. Now he wants to add some new features to his application, but he does not know how to code for it. I can complete his requirements in a console application in .net. So, I written a function like below in C#:

public static void sendSmsDemo(string MobileNo, string Password)
{
    Console.WriteLine("Your Mobile Number is : " + MobileNo + "\n" + "Your Password is : " + Password);
}

I call this function in main method's constructor. And my program works fine.

Now, He wants to call this function from his application developed in Clipper. Is there anybody who knows how to communicate between C# app and Clipper app?

Vishal
  • 6,238
  • 10
  • 82
  • 158
  • Is his application so big in source code size? Wouldn't it make sense to migrate the Clipper application to C#? I do not know any reason to use Clipper nowadays instead of C# unless it is a big legacy application or it has a bigger customer base and fears the impact of change. Disclaimer: I migrated one big app from Clipper to C#. It was very worth the effort. – sergiol Jan 27 '15 at 12:26
  • 1
    Yes, the application is huge. Also my friend does not know C#, so that he cannot make new changes to the application. – Vishal Jan 27 '15 at 12:31
  • You can't call c# code from clipper, but there should be a way to run another exe-file, pass parameters (or even use IPC) **by Clipper** ( ask your friend). To example (without any security consideration), Clipper exe-file can execute .net exe-file with command line parameters. Or you can use predefined file to pass parameters and/or return results, etc. – Sinatr Jan 27 '15 at 12:39
  • This depends on the specific vendor variation you are using, E.g. XBase supports COM Interop with .Net. What Clipper implementation are you using? – Alex K. Jan 27 '15 at 12:43
  • @Sinatr I have already asked him to run my app from his app and he has successfully done that. But he is not able to call the function, I mean how can he pass parameters to the function that is defined in my application. – Vishal Jan 27 '15 at 12:58
  • 1
    He can't. But if he can run .net exe-file, then **he can pass parameters** (see [here](https://msdn.microsoft.com/en-us/library/aa288457.aspx) of how to read them). This is just one way. Other, easily programmable is to agree (or pass as command line parameter) on file, containing input parameters (in text, binary or serialized form: xml, ini, etc) and/or output file for return results (if you need them). Performance-wise best is IPC: run .net exe, use IPC to share something what will cause execution of c# code, get data back. Question is: how good Clipper is at IPC? – Sinatr Jan 27 '15 at 13:08

2 Answers2

0

If what you're wanting is to call a C# routine natively from Clipper, you're out of luck.

Another approach may be to recode the Clipper app in Vulcan.NET. Vulcan is a .NET native development environment for XBase.

Otherwise, there may be other techniques, but more details are needed: for example, whether your colleague is using Clipper 5 or Harbour, etc. Some more source from the Clipper side showing what is needed would be helpful.

bugmagnet
  • 7,631
  • 8
  • 69
  • 131
0

1º First Step

I create a Class Library in C# and compile options, mark Register for COM interop.

2º The Class sample

Public Class Order

Public Function Total() As Decimal
    Return 100
End Function

Public Property Description As String = "Teste"

End Class

3º Test in Harbour // Now is possible use methods e properties the class

include "minigui.ch"

Function Main()

Local oOrder

//HarbourInvoke the name of my Class Library in C#
oOrder = CreateObject("HarbourInvoke.Order")

MsgInfo(oOrder:Total())
MsgInfo(oOrder:Description())

oOrder:Description := "new test"

MsgInfo(oOrder:Description())

oSuma := nil
    

Return Nil

Community
  • 1
  • 1
Marks
  • 41
  • 5