Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Eval equivalent and expression builder
Message
From
28/12/2006 21:37:05
 
 
To
28/12/2006 20:25:31
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01180815
Message ID:
01180816
Views:
16
>I would like have .NET feature like EVAL() in VFP in my application.
>
>IF EVAL(UDFExpr)
>*** Do something
>ENDIF
>
>
>Also, any tool that allow user to build expression using UI (just like filter expression in foxfire! and stonefield query) ?
>
>Or, any other way to do this in .NET?

In .NET, such issue would have to be resolved with Reflection. Here is an example that takes the class name as well as the method name from a DBF:
    ' expO1 Data provider
    Private Function ProcessTaskQuery(ByVal toDataProvider As Framework.Framework.Data) As Boolean
        Dim lcClass As String = ""
        Dim lcMethod As String = ""
        Dim lnCounter As Integer = 0
        Dim loAssembly As System.Reflection.Assembly
        Dim loMethod As System.Reflection.MethodInfo
        Dim loObject As Object
        Dim loParameterClass(1) As Object
        Dim loRow As DataRow
        Dim loType As System.Type

        loParameterClass(0) = oApp
        loParameterClass(1) = Me

        ' Establish the reference to the EXE
        loAssembly = System.Reflection.Assembly.LoadFrom(oApp.cStartupDirectory + "Robot.exe")

        ' Scan each task to execute
        For lnCounter = 0 To toDataProvider.nCount - 1
            loRow = toDataProvider.oDataSet.Tables("Temp").Rows(lnCounter)
            Status.Text = "Processing " + Trim(loRow("Title")) + "..."
            lcClass = Trim(loRow("Class"))
            lcMethod = Trim(loRow("Method"))
            Try

                ' Get a reference to the class
                loType = loAssembly.GetType("Robot." + lcClass)
                loObject = Activator.CreateInstance(loType, loParameterClass)

                ' Get a reference to the method
                loMethod = loObject.GetType().GetMethod(lcMethod)

                ' Call the method
                loMethod.Invoke(loObject, Nothing)

            Catch loError As Exception
                oApp.ErrorSetup(loError)
                Return False
            End Try
        Next

        Return True
    End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform