Jump to content

Dave Novo

Members
  • Content Count

    151
  • Joined

  • Last visited

  • Days Won

    1

Dave Novo last won the day on March 12 2021

Dave Novo had the most liked content!

Community Reputation

52 Excellent

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Dave Novo

    New to Delphi and to the forum - with questions

    Welcome to the Delphi world. There are lots of tools available for many of the questions your asked. Have a look at the subforum on this site and search for various tools and you will see many examples. Most of the tools have been around for a long time, and are very feature complete and differ by subtleties of usage etc. Delphi Third-Party - Delphi-PRAXiS [en] -for the diagrams, I know both TMS Software and Developer Express have flowcharting tools you can leverage. There are other lesser known ones that are available. Just google "delphi flowchart component" -Similar with Help tools. We used Help and Manual and liked it, but there are many other tools equally as valid. These do not even have to be delphi specific. -Please describe what "font oddities" you are seeing in more details. -Without knowing in more detail what you want, recommending a database is just throwing darts against the wall. All have their pros and cons.
  2. Dave Novo

    CreateObservableList example in Spring4D

    ok, perfect, I got that working. thanks!
  3. Is there an example anywhere of properly hooking up events to a newly created Observable list in order to be notified if items are added/removed to from the list
  4. Dave Novo

    Get Index of enumeration in spring4D

    thanks. I did not realize I had an older version. Just updated....
  5. Dave Novo

    Get Index of enumeration in spring4D

    By the way, I tried the code, based on @Stefan Glienke example above var foo:=TCollections.CreateList<string>; var indexedColl := TEnumerable.Select<string, Tuple<Integer,string>>(foo, function(const item: string ;const index: Integer): Tuple<Integer,string> begin Result := Tuple<integer,string>.Create(index, item); end); and it does not compile. I think the problem is that TEnumerable.Select expects a TFunc<T,TResult> The following seems to be okay var foo:=TCollections.CreateList<string>; var idx:=0; var indexedColl := TEnumerable.Select<string, Tuple<Integer,string>>(foo, function(item: string): Tuple<Integer,string> begin Result := Tuple<integer,string>.Create(idx, item); inc(idx); end);
  6. Dave Novo

    Get Index of enumeration in spring4D

    I guess I could wrap the above code into something like TEnumerateHelper<T>=class function CreateIndexEnumerator(list:IList<T>):<result is whatever the type of the .Select statement is> also, define a type TIndexedEnumItem<T>=Tuple<Integer,T> and consolidate that all to make somewhat simpler code to use on a day to day basis. I think different logic is needed though if the .Where predicate has an integer enumerator passed in.
  7. Dave Novo

    Get Index of enumeration in spring4D

    Hi Stefan, Firstly, I would like to say I think the Spring4D library is amazing, and you have done an amazing service for the Delphi community. Please take anything I write merely as a suggestion, not criticism in any way!!!!!! There seems to be little you cannot do in Spring4D if you are clever. I have been coding in Delphi for decades and recently had occasion to start programming a bit in Python. What I am amazed by is how little code I have to type in Python for common things. Of course, there are pros and cons to other aspects of Python (speed etc - that can be dealt with in a variety of other ways) but for the point I am making here it is just about code simplicity and clarity. I love IShared<T> because it removes hundreds of lines of boilerplate try..finally blocks that on one hand are simple, but the other clutter up the code with useless crap that distracts you from what you are trying to do. The python syntax of new_list = [expression for item in iterable if condition] where new_list is in and of itself an enumerable object that can be plugged into other lists makes the code so simple and clear. Comparing the code var indexedColl := TEnumerable.Select<TMyClass, Tuple<Integer,TMyClass>> (myColl, function(const item: TMyClass; const index: Integer): Tuple<Integer,TMyClass> begin Result := Tuple<integer,TMyClass>.Create(index, item); end) .Where( function(const tuple: Tuple<Integer,TMyClass>): Boolean begin Result := Odd(tuple.Value1); end); to the Python Version indexedColl = [y for x,y in enumerate(myColl) if x%2 != 0] Explanation for non-python people. x is the index, y is the element in myColl at that index. the if statement at the end filters for odd numbers. Of note, indexedColl can be passed as the enumerator directly into anything that accepts an enumerator. I 100% understand that of course Delphi syntax cannot be as simple as Python we have to be specify the types in the generic specialization somehow, but any way that can be moved towards a more simplistic syntax (at least for common use cases) would be helpful. Working with Python has been a real eye opener in the fact that you don't have to break your brain with generics to do everything. (you do have to break your brain in other ways, if people don't use type annotations for example and you spend 1 hour figuring out what type a method is expecting - but that is a different story). Even knowing what you are trying to do in the example above, I would really have to study the code diligently to understand exactly how all the pieces fit together to make it work.
  8. Dave Novo

    Get Index of enumeration in spring4D

    Hi Stefan, Sorry, I did not notice the .Where gets an index. But .Where does not seem to satisfy the first requirement. I guess I would have to create my own enumerator and capture it in the .Where method.
  9. Dave Novo

    Get Index of enumeration in spring4D

    As a follow up, another key nice addition would be able to do something like this for var curItem in myColl.EnumerateWithIndices([1,5,7,9]) which would return the "indexed enumerator record" for only indexes 1,5,7,9 For this example, you should be able to pass in any IEnumerator/IEnumerable<integer> or something like for var curItem in myColl.EnumerateWithIndices( function (zIdx:integer):Boolean begin result:=IsOdd(zIdx) end ); which would return an "indexed enumerator record" for only odd numbered indexes I will see if I can get a working example over the holidays....
  10. It would be cool if the enumerator supported pointer access to the underlying element. Something like for var curPtr in List.Pointers<PRecord> do begin curPtr.SomeValue:=1; end In the case above, the Pointers record would return a pointer to the underlying item, cast to the pointer type passed in as T. This can be useful for records (and maybe other) to deal with a pointer to the underlying items
  11. Hello, If I make a list<T> where T is a record, what is the best way to get access to the actual records in the list to make modifications to them? If I was using the built in TList<T> I would use the .List<T>, but Spring4D.IList<T> does not have a property to access the raw list. Is there another way to get access to the actual record instance in the list in order to modify it. calling .Items makes a copy of the underlying record it seems and if I try to enumerate through the list using the enumerator and set a property on the variable in the enumerator I get an error that I cannot set a control loop variable.
  12. Hello, Does spring4D have a similar method as the Python enumerate() method? I feel this should be possible, if the "standard enumerator" that is returned now was wrapped inside an enumerator that returned a record that contained the index and the original <T> itself. In fact, this special record could implement record based conversion methods to convert automatically to both an integer and T. I imagine coding something like this var myColl:=TCollections.CreateList<TSomeClass>; // add some stuff to the list for var curItem in myColl.EnumerateWithIndices do begin // at this point, curItem is really a record, with fields Index, TSomeClass someArrayOfInt[i]:=curItem; // implicit conversion to integer SomeClassList.Add(curItem); // adds the TSomeClass that is returned to another list, implicit conversion to TSomeClass end; Does something like this exist?
  13. Dave Novo

    ISet<T> in spring4D

    The reason I was thinking of using ISet is just that Delphi is very verbose: if myEnum in myset then is not so bad but if [enum1,enum2] * myset <> [] then is obscure and if you dont use this syntax frequently you are constantly reminding yourself what the intention was, particularly for more complex set operations. I feel that if mySet.DoesNotContainAny([enum1,enum2]) then is much easier to understand the intention. Not as performant of course.
  14. Dave Novo

    ISet<T> in spring4D

    Oh thanks. I did not think to go all the way up to enumerable, as I am used to that interface just being for enumeration. I will investigate that further....
  15. I am a bit new to spring 4D, and am attempting to use ISet<T> as a replacement of the standard set of <type> in Delphi. How do you easily check if an value is in a ISet<T> The use case I have is with an enum. Where TEnumSet = set of enum; In Delphi I would do if myEnumToCheckFor in MySet then ..... I had expected to see a method ISet<T>.Contains<T>:Boolean, or something along those lines, but I don't see anything. It seems like ISet<T> has lots of helpful methods for dealing with other sets, but I cannot find anything to check if an individual item is in the set. Of course, I can create a new set that contains 1 item and use that, but it seems overkill to do presuming Myset:=ISet<some enum> if MySet.InsersetsWith(TCollections.CreateSet([myenumTocheckFor])) do.... am I missing something? note: sorry, I meant to put this in 3rd party, but somehow it ended up here. I cannot seem to find a way to move it to the 3rd party subforum.
×