Here is a new feature for PwrDev..
It's now able to compile code like VB.NET or CSharp on demand fully in memory.
Also the assembly (dll) created remains in memory and PwrDev can use this assembly to create object instances from class inside this assembly.
See this topic which also provides an executable to test this feature:
http://www.hellobasic.com/cgi-bin/fo...num=1206649272
--
This is a simple example of the PB code, note that ordinary PowerBASIC variants and dispatches are used.
No registering of any assembly is required to become a dispatch object (ActiveX).
It's now able to compile code like VB.NET or CSharp on demand fully in memory.
Also the assembly (dll) created remains in memory and PwrDev can use this assembly to create object instances from class inside this assembly.
See this topic which also provides an executable to test this feature:
http://www.hellobasic.com/cgi-bin/fo...num=1206649272
--
This is a simple example of the PB code, note that ordinary PowerBASIC variants and dispatches are used.
No registering of any assembly is required to become a dispatch object (ActiveX).
Code:
Local v As Variant Local oAssembly As Dispatch Local vClass1 As Variant Local oClass1 As Dispatch Local sCode As String Local sError As String '----------------------------------------------------------------------- ' Step 1, compile the CSharp code into an assembly. '----------------------------------------------------------------------- sCode = VD_GetText( nCbHndl, %ID_FORM1_TXTCSHARP ) ' Note that multiple libraries need to be CrLf separated. VD_CLR_AssemblyCompiler_CompileCSharp( sCode, "System.Data.dll", oAssembly, sError ) ' Test if an assembly was created. If IsFalse( IsObject( oAssembly ) ) Then MsgBox sError, %MB_TASKMODAL, VD_App.Title: Exit Function '----------------------------------------------------------------------- ' Step 2, create a specific class found in the assembly. '----------------------------------------------------------------------- v = "Class1" Object Call oAssembly.CreateInstance( v ) To vClass1 ' Move the class1 object in the variant into a dispatch object. oClass1 = vClass1: vClass1 = Empty ' Unload the assembly, you may keep it alive if there are more classes to use. Set oAssembly = Nothing '----------------------------------------------------------------------- ' Step 3, call a function in the class. '----------------------------------------------------------------------- Object Call oClass1.GetDateTime() To v MsgBox "Result: " & Variant$( v ), %MB_TASKMODAL, VD_App.Title ' Unload the class Set oClass1 = Nothing
Comment