[Ironpython-users] Ccalling c# from python script
Perez, Justin
Justin.Perez at energytransfer.com
Sat Oct 8 03:12:11 CEST 2011
I would like to be able to call a C# something from a python script from IDLE or if better from ironpython. The code I need to call is below. I am fairly certain that this is VB.net so if easiest I could build this in a vb.net something. I do not know how to package this into something that could be called from python (c# or vb -.net). It would be most cool if I could call from ironpython. Thanks.
Public Sub ListUniqueRecords()
Dim pMyTable As ITable
Dim pCurs As ICursor = Nothing
Dim intFieldIdx As Integer
Dim pDataStatistics As IDataStatistics
Dim pEnumVar As IEnumerator
Dim pWorkspaceFactory As IWorkspaceFactory
Dim pWorkspace As IWorkspace
Dim pFeatWorkSpace As IFeatureWorkspace
Dim strMyField As String = “VAL”
Try
pWorkspaceFactory = New AccessWorkspaceFactory
pWorkspace = pWorkspaceFactory.OpenFromFile(“C:\MyPath\MyGDB.mdb”, 0)
pFeatWorkSpace = CType(pWorkspace, IFeatureWorkspace)
pMyTable = pFeatWorkSpace.OpenTable(“MyTableName”)
intFieldIdx = pMyTable.FindField(strMyField)
pCurs = pMyTable.Search(Nothing, True)
pDataStatistics = New DataStatistics
pDataStatistics.Field = strMyField
pDataStatistics.Cursor = pCurs
pEnumVar = CType(pDataStatistics.UniqueValues, IEnumerator)
Do Until pEnumVar.MoveNext = False
Debug.Print(pEnumVar.Current.ToString)
Loop
Catch ex As Exception
Trace.WriteLine(ex.ToString)
Finally
‘clean up
pCurs = Nothing
pWorkspace = Nothing
End Try
End Sub
________________________________________
From: ironpython-users-bounces+justin.perez=energytransfer.com at python.org [ironpython-users-bounces+justin.perez=energytransfer.com at python.org] on behalf of ironpython-users-request at python.org [ironpython-users-request at python.org]
Sent: Friday, October 07, 2011 5:00 AM
To: ironpython-users at python.org
Subject: Ironpython-users Digest, Vol 5, Issue 4
Send Ironpython-users mailing list submissions to
ironpython-users at python.org
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/ironpython-users
or, via email, send a message with subject or body 'help' to
ironpython-users-request at python.org
You can reach the person managing the list at
ironpython-users-owner at python.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Ironpython-users digest..."
Today's Topics:
1. Re: Help Change Python Engine Options inside Python (Jeff Hardy)
----------------------------------------------------------------------
Message: 1
Date: Thu, 6 Oct 2011 14:08:20 -0700
From: Jeff Hardy <jdhardy at gmail.com>
To: Mark Wilson <mwilsonedu at yahoo.com>
Cc: "ironpython-users at python.org" <ironpython-users at python.org>
Subject: Re: [Ironpython-users] Help Change Python Engine Options
inside Python
Message-ID:
<CAF7AXFHv8DE+UW+s1+BGsViByOJGc+w-VAMYfff_J_1ti2xUTg at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
I'm pretty sure that once the Python Engine has started, the options
cannot be changed.
If you have VS available you could attach to the ipy process and debug
using that. Calling System.Diagnostics.Debugger.Break() in your python
code will trigger a breakpoint.
- Jeff
On Wed, Oct 5, 2011 at 3:19 PM, Mark Wilson <mwilsonedu at yahoo.com> wrote:
> Hi,
> I am writing python scripts in a launched?ironpython console. I cannot use
> the pdb debug module because the FullFrames and Tracing were off. I cannot
> relaunch ipy -X:FullFrames -X:Tracing. Could you advise how to debug the
> scripts within the?existing?python console 2.7?
> Thanks in advance,
> Mike
>
>
>
>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>
>
------------------------------
_______________________________________________
Ironpython-users mailing list
Ironpython-users at python.org
http://mail.python.org/mailman/listinfo/ironpython-users
End of Ironpython-users Digest, Vol 5, Issue 4
**********************************************
More information about the Ironpython-users
mailing list