mdTypes

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Re: mdTypes

Post by MOD »

Code: Select all

*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)
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Re: mdTypes

Post by MOD »

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.

For more information please check out the tutorial: http://www.freebasic-portal.de/tutorial ... 08-s9.html
PeterHu
Posts: 161
Joined: Jul 24, 2022 4:57

Re: mdTypes

Post by PeterHu »

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.

Code: Select all

#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

Would like to see this project is updating.
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Re: mdTypes

Post by MOD »

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:

Code: Select all

Output 1: -- for loop
 0
 1
 2
 3
 0

Output 2: -- foreach loop
 0
 1
 2
 3
 0

Output 3: -- mdIterator
 0
 1
 2
 3
 0

Output 4: sublist
 1
 2
 3

Output 5: clone all from list
 0
 1
 2
 3
 0

Output 6: --foreach with newlist
 0
 1
 2
 3
 0
Compiler 1.10.1
Did I miss something? You have mentioned the version 1.02.0, which is 9(!) years old. Please try to update to a current version.
PeterHu
Posts: 161
Joined: Jul 24, 2022 4:57

Re: mdTypes

Post by PeterHu »

Thank you for the reply.

I mean fbc version 1.2.0 ,both 32 bit and 64 bit.The most recent version (April 7,2024).
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Re: mdTypes

Post by MOD »

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.

The official releases are listed here: https://freebasic.net/forum/viewforum.php?f=1
PeterHu
Posts: 161
Joined: Jul 24, 2022 4:57

Re: mdTypes

Post by PeterHu »

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.

The official releases are listed here: https://freebasic.net/forum/viewforum.php?f=1
Yes,I mean the most recent git-builds,that's 1.20.0,sorry for the mistake.
PeterHu
Posts: 161
Joined: Jul 24, 2022 4:57

Re: mdTypes

Post by PeterHu »

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.

The official releases are listed here: https://freebasic.net/forum/viewforum.php?f=1
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?
Avata
Posts: 107
Joined: Jan 17, 2021 7:27

Re: mdTypes

Post by Avata »

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?
PeterHu
Posts: 161
Joined: Jul 24, 2022 4:57

Re: mdTypes

Post by PeterHu »

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.
MOD
Posts: 558
Joined: Jun 11, 2009 20:15

Re: mdTypes

Post by MOD »

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.
Post Reply