*list.get(i) = 1 ' retreives the value of the pointer at index i in the list and compares it to "1" - this line will not work unless used in an if-statement or assignment..because of syntax rules
list.set(i) = 2 'sets the pointer at index i to "2" - don't use this pointer afterwards as "2" is not a valid address!
*list.set(i) = 3 'sets the value of the pointer at index i to "3"
list.get(i) = b 'compares the pointer at index i to whatever "b" is - same syntax problem like in the first case
list.get(i) = NULL 'like the case above but wiht comparision to NULL instead of "b"
PRINT list.contains(NULL) 'if any of the pointers in the list is NULL, this will print TRUE (=-1)
PRINT list.contains(NOT NULL) 'if any of the pointers in the list is not NULL, this will print TRUE (=-1)
mdTypes now has a persistence api which allows you to store data and lists of data in databases. For now it supports MySQL, SQLite, and a simple text-based mdTypesPersistence.
MOD wrote: ↑Sep 21, 2013 14:32
The goal of this project is to create a class structure, that is almost similar to Java.
Noteworthy are the collection classes. These allow you to add almost all FreeBASIC datatypes (except Integer - use Long or mdInteger instead) and own types into generic lists and maps.
Example code for a mdList with own class:
May I ask whether the mdTypes collections is still under maintenance? With most recent fbc 1.2.0 64bit/32 bit,I has tried a lot of the examples,the vast majority has been well compiled and runs perfect,except that usages like below.The output 5 & output 6 just print empty.
#include once "md/util/mdList.bi"
type MyClass
declare constructor()
declare operator cast() as string
as integer myVar
end type
constructor MyClass()
end constructor
operator MyClass.cast() as string
return str(myVar)
end operator
operator = (byref lhs as MyClass, byref rhs as MyClass) as integer
return lhs.myvar = rhs.myvar
end operator
mdListDeclare(MyClass)
dim as mdList(MyClass) list
dim as MyClass foo
foo.myVar = 0
list.add(foo)
foo.myVar = 1
list.add(foo)
foo.myVar = 2
list.add(foo)
foo.myVar = 3
list.add(foo)
foo.myVar = 0
list.add(foo)
print "Output 1: -- for loop"
for i as integer=0 to list.size()-1
print list.get(i).myvar
next
print
print "Output 2: -- foreach loop"
dim as MyClass element
ForEach(MyClass, element In list)
print element.myVar
NextEach
print
print "Output 3: -- mdIterator"
dim as mdIterator(MyClass) it = list.iterator
while it.hasNext()
print it.nex().myVar
wend
print
dim as mdList(MyClass) subList = list.subList(1, 3)
print "Output 4: sublist"
ForEach(MyClass, element In subList)
print element.myVar
NextEach
print
dim as mdList(MyClass) newlist1
newlist1.addAll(0, list)
print "Output 5: clone all from list"
for i as integer=0 to newlist1.size()-1
print newlist1.get(i).myVar
next
print
print "Output 6: --foreach with newlist"
ForEach(MyClass, element In newlist1)
print element.myVar
NextEach
print
sleep
Well, it's not really maintained anymore. Lots of years ago I've tried to "pass" it to the FreeBASIC community by renaming all modules to create a "generic" version, but it was never added.
I almost don't use FreeBASIC these days, so I'm not improving or testing the code with new versions, but I'm still looking into replys to my threads.
In this case I've tested the posted code (with the additional line 'Print "Compiler " + __FB_VERSION__') with the latest 1.10.1 for Windows (fbc32 and fbc64). The output looks fine for me:
1.2.0 or 1.20.0? Are you talking about the Recent-Git-Builds? These are inofficial builds from the current state of the repository. These might have bugs or something has changed (breaking changes) so that the mdTypes code doesn't work anymore.
MOD wrote: ↑Apr 19, 2024 11:33
1.2.0 or 1.20.0? Are you talking about the Recent-Git-Builds? These are inofficial builds from the current state of the repository. These might have bugs or something has changed (breaking changes) so that the mdTypes code doesn't work anymore.
MOD wrote: ↑Apr 19, 2024 11:33
1.2.0 or 1.20.0? Are you talking about the Recent-Git-Builds? These are inofficial builds from the current state of the repository. These might have bugs or something has changed (breaking changes) so that the mdTypes code doesn't work anymore.
I am sorry to bother you again.But with 1.10.1 I tried to build the example,the result is the same,that's output 5 and 6 are blank.
Was I missing something?
In this case I've tested the posted code (with the IDE VisualFBEditor https://github.com/XusinboyBekchanov/VisualFBEditor ) with the latest 1.20.0 for Windows (fbc32 and fbc64). The output looks fine for me also.
Someone could be do something to add the code "mdCollection.bi" to the frameworks MFF?
Avata wrote: ↑Apr 25, 2024 12:49
In this case I've tested the posted code (with the IDE VisualFBEditor https://github.com/XusinboyBekchanov/VisualFBEditor ) with the latest 1.20.0 for Windows (fbc32 and fbc64). The output looks fine for me also.
Someone could be do something to add the code "mdCollection.bi" to the frameworks MFF?
Excited to know.
It is weird.VisualFBEditor+fbc1.20.0(the latest fbc32 and fbc64) and WinFBE are what I am using daily.All examples in mdTypes package works great except a couple of examples like this one:making a new list from an existing list.Either 1.10.1 or 1.20.0 just doesn't output proper result with this.
Why I am expecting to make it work properly with fbc is I feel mdTypes ( it seems ported from Java core library) provides a lot of very useful package besides container libraries,logging,persistence,security,and other utilities like to manipulate database.
Maybe you are using an outdated version of mdTypes... Do you remember the download url? Maybe you can try to update it from one of the provided sources.
MOD wrote: ↑May 01, 2024 13:29
Maybe you are using an outdated version of mdTypes... Do you remember the download url? Maybe you can try to update it from one of the provided sources.