If you need not Merlin to support you on the screen, remove the code from log form. This is a simple Logbook Program using Foxpro.
TestTable.WriteXml(sw, XmlWriteMode.Basics of Visual FoxPro Programming – Free download as Powerpoint Presentation. Using sw As New StreamWriter(Console.OpenStandardOutput()) Public Overrides Function TrySetMember(binder As SetMemberBinder, value As Object) As BooleanĪnd the usage of the above class: Dim testTable As New DataTable("TheTable")ĭim columnNames As New List(Of String)(From column As DataColumn In testTable.Columns Select column.ColumnName)ĬolumnNames.ForEach(Sub(x) DirectCast(m, myDynObj).AddProperty(x))Ĭonsole.WriteLine(String.Format("The current properties of the object are as follows: ", x, CallByName(m, x, CallType.Get, Nothing)))) Return internalDict.TryGetValue(binder.Name, result) Public Overrides Function TryGetMember(binder As GetMemberBinder, ByRef result As Object) As Boolean Public Overrides Function GetDynamicMemberNames() As IEnumerable(Of String)
InternalDict.Add(kvPair.Key, kvPair.Value) InternalDict.Item(kvPair.Key) = kvPair.Value If internalDict.ContainsKey(kvPair.Key) Then
Public Sub addOrSetProperties(ByVal ParamArray newPropertyValuePairs() As KeyValuePair(Of String, Object))įor Each kvPair As KeyValuePair(Of String, Object) In newPropertyValuePairs.Where(Function(x) Not IsNothing(x.Key)) Public Sub AddProperty(ByVal PropertyName As String, Optional ByVal Value As Object = Nothing)ĪddOrSetProperties(New KeyValuePair(Of String, Object)(PropertyName, Value)) InternalDict = New Dictionary(Of String, Object) Private internalDict As Dictionary(Of String, Object) Private Class myDynObj : Inherits DynamicObject I'm going to provide a very basic example and it is very bare bones but hopefully it'll give you an idea on where to start. So this example from the MSDN page CREATE TABLE Test FREE If you start getting into the more complicated uses of the scatter command to break up the values into a new object where the object has properties which are the same as the columns in the original table, well the VB equivilent gets much harder because you'll have to make a class that inherits the class. Where (("A") Or ("P")) _Īnd Not ("PARTNO") Select rowItem MyArray = From rowItem In (From row As DataRow In testTable.Rows Select row.ItemArray) _ I think this would be best translated to a using LINQ query which could return an Object() array. The above looks is just getting all fields that start with A* and P* and is excluding items matching PARTNO* from the results. Looking at this MSDN page, it looks like the to perform a simple scatter command in FoxPro you would use something like this: SCATTER FIELDS LIKE A*,P* EXCEPT PARTNO* TO myArray
If you have any recommendations on how to improve any of the above, please let me know.įirst off, I've never dealt with FoxPro or Visual FoxPro, so don't expect what I say is going to work perfectly for every scenario. XinCompile.Rows(j).Item("featType") = featTypeĬontent = content.Remove(0, crntTag.Length) XinCompile.Rows(j).Item("lineToPrev") = lineToPrev XinCompile.Rows(j).Item("DTMexclude") = DTMexclude XinCompile.Rows(j).Item("numCode") = NumCode XinCompile.Rows(j).Item("symbDesc") = SymbDesc WholeTag = wholeTag.Remove(wholeTag.IndexOf(lcstring), wholeTag.IndexOf(">") + 1) XinCompile.Rows(i).Item("cellName") = CellName XinCompile.Rows(i).Item("cellLayer") = CellLayer XinCompile.Rows(i).Item("symbDesc") = SymbDesc XinCompile.Rows(i).Item("symbName") = SymbName If crntTag.Contains("/FeatureStyleCollection>") Then Do Until reader.EndOfStreamĬrntTag = content.Substring(0, content.IndexOf(">") + 1) Both of these collections are in the same line of the file, so I've written code to go tag-by-tag, pick out the information I want, and add it to a temporary data table. xin file that are of interest to me: and. xin file and form an access data table from its code. Sadly, the above is how I do most of my data entry.Įdit: In response to comment, I am using VB to read a. I'm looking to avoid the need of a method along the lines of: For Each row As DataRow in MyTable Later in the VFP program insert into memvarmatches the variables to their respective columns.
Does VB have an equivalent function, or do I need to create each variable with a Dim statement?Įdit: I should have mentioned that I'm looking to use this to propagate datatables, very sorry. Having no experience with FoxPro I asked about a few commands used in the code and found one of particular use: scatter memvar, which made individual variable from columns in a table. I need to take some code written in VisualFoxPro and rewrite it in VB.