Sample project using classes

So you are still not using the classes?

This is a small example of a project that uses a bitvector class.

You can use this class to set/reset bits (not logicals, but really on the level of the bits), do some bit operation between bitvectors (AND, OR, XOR, NEGATE), turn the bitvector into a string using your own chosen characters, e.g. YNNNYNNNY (Y means bit on and N means bit off). You can test if a bit is on or off and finally you can also clone an existing bitvector.

I have built this example in a very short time, so don’t expect too much from it. It’s just an example.

The sources have been taken from Natural for Windows, but it should also work on the mainframe.

Please have a look at the example program (a very small unit test) to get an idea.

Have fun,
Rudolf
BITVECTOR.zip (7.47 KB)

Here is a new version (there were a few bugs and probably there still are. So make the changes and donate the sources back to the community).

I extended the test and changed the call to the methods using the good habit (the reason why functional programs are getting more popular) to avoid side effects (which happens if you use by reference).

Have fun and more importantly learn object programming (try to apply patterns for example).

Cheers,
Rudolf
BITVEC.V0.2.zip (7.98 KB)