Disappointed with Module Support

epsharp

Member
Licensed User
Longtime User
I waited patiently for module support in trying to convert my JAVA Regatta Management System into Basic4PPC. Tablet PC vs Pocket PC!

I had gotten around some of the difficulty of common routines by replacing the >.< with >_< and placing them in a .txt file but was constantly making "code" mistakes habitually using the >.<.

So I fired up v6.5, used Notepad to change "underscores" back to "dots", renamed ".txt" to ".bas" (which logically it should have been anyway) and clicked "Load Existing Module". :( ERROR: "Input String not in a correct format"

Tried to Add a New Module using the same name. :(:( ERROR: "Module File with this name already exists.

Renamed back to ".txt", went into to Notepad for a big copy/paste and Clicked Add New Module: :confused: There was the obsequious Sub Globals. Pasted code, saved module, checked with NotePad. :confused: Front end looks identical to any normal ".sbp" program.

Figured by now, I'd better stop and check the new Help File for Modules and then got the really BAD NEWS! :sign0148: The new Basic4PPC has, in its infinite wisdom, decided to embrace the word "PUBLIC"!

One of the overwhelming reasons for using modules is for sharing both global variables and common code routines and to access anything, anywhere by simply prefixing the request with the module name. To achieve this objective, one would logically make "PUBLIC" the DEFAULT and for those instances where one DID NOT want sharing, use "PRIVATE".

So now I have to create a blank.sbp for every module, then cut & paste code, then REPLACE all Dim's with Public and THEN add Public to each and every Sub! :sign0137:

Yep! Disappointed! But at least I've got my Module support! :sign0060:

Regards,

Ed Sharp
 

agraham

Expert
Licensed User
Longtime User
One of the overwhelming reasons for using modules is for sharing both global variables and common code routines and to access anything, anywhere by simply prefixing the request with the module name.
Hmm, depending upon ones philosophy you could equally well say

"One of the overwhelming reasons for using modules is for encapsulation and hiding of superflous detail and provision of simple interfaces to the main code body".

Your statement assumes the use of a module as a sort of hidden region of public code whereas I would regard it as more of a step to a simple class structure with public interfaces and private implementations. Both are of course equally valid points of view but I guess Erel chose his way because it makes modules behave, by default, like external libraries. It also better mirrors the object oriented way of programming that is pervasive nowadays.

However as an old transisor era computer pioneer I still don't fully buy into this approach and tend to write a few large classes which I can understand rather than lots of small classes which I find distracting and confusing. Still, we old have to step aside for the young and let them do as they seem fit. Pity there isn't much call for Ferranti Argus 300 Assembler programmers any more :(
 

epsharp

Member
Licensed User
Longtime User
Agraham, I totally agree with your post, especially since I started programming in 1960 by entering octal machine language instructions via the computer keyboard and saving the program (as far as you had gotten) to punched paper tape.

And as a committed application programmer, I tend to see programs as having a beginning, a middle and an end. It took me a looooooong time with my first JAVA application to be able to visualize "objects" and allow a computer and threads to run my programs.

So yes, we step aside!

.....but since I can't include code snippets with a compiler "include" instruction, I'll still stick every tedious, repetive code segment into my "subroutine" Module {SR} and use SR.Strip(t) whenever I need to clear white space on both ends of a string.

Thanks for your reply.
 

agraham

Expert
Licensed User
Longtime User
SR.Strip(t) whenever I need to clear white space on both ends of a string.
Have you found my StringsEx library? http://www.b4x.com/forum/additional-libraries/2022-stringsex-library.html It implements almost all the .NET stringy stuff that isn't exposed in Basic4ppc.

It's worth exploring the Additional Libraries forum for such gems :) as my Collections library http://www.b4x.com/forum/additional-libraries/1682-collection-library.html Some of the most useful, if they haven't been posted to for a while, may be a way back as a download doesn't bring them forward again.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I admit that I'm pretty used to object oriented programming languages and information hiding / encapsulation is one of the core principles of such languages.
Still I don't think that there is only one "correct answer" about the default scope of global variables and subs.
I think that in both cases their were some users who would have been disappointed from the decision.

And eventually it is not too hard to declare all variables and subs as public fields.
 

LineCutter

Active Member
Licensed User
Longtime User
It's worth exploring the Additional Libraries forum for such gems :) as my Collections library http://www.b4x.com/forum/additional-libraries/1682-collection-library.html Some of the most useful, if they haven't been posted to for a while, may be a way back as a download doesn't bring them forward again.
For Erel:

A thought - could we not have a forum (or similar browsable download area) with the only posts being the most up to date versions for each of the libraries? With links to their original posting thread.

It can be a pain trying to find the most recent version of something when v1.0 is in the first post & v3.7 (the most recent) is 2/3 of the way through the thread. agraham obviously excepted since he always edits the top post.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
For Erel:

A thought - could we not have a forum (or similar browsable download area) with the only posts being the most up to date versions for each of the libraries? With links to their original posting thread.

It can be a pain trying to find the most recent version of something when v1.0 is in the first post & v3.7 (the most recent) is 2/3 of the way through the thread. agraham obviously excepted since he always edits the top post.

That is not something that's supported by vBulletin. It is the responsibility of each developer to edit his first post and at put the latest file or a link to the latest post.
 

klaus

Expert
Licensed User
Longtime User
Hello,

I would also give my opinion and feeling on B4PPC and the new Module feature.

I find that the need to add to each public routine or variable the module name where it was declared as a disadvantage.
From my user point of view, when a routine or variable is public it is public with it's name whatever module it was declared in. I don't see the need to 'privatize' it again with it's module name when accessed from outside.
It should be the same principle as with the global module variables and the private subroutine variables, just one layer above. If one would have the module name in a routine or variable this would still be possible, but only if someone wants it, not as default need for everybody. I can understand that is's easier for the language developper, but it's more combersome for the language user.

Another missing feature for me is that the comlementary files 'belonging' to the module are not automatically copied with the module file. So I can load a given module in a project, the module file is copied to the program's folder, and then I must look in the modules folder, if the module is saved in a specific folder, or somewhere else, and copy all the complementary files, mainly image files for buttons. I declare the image files in an ImageList in the IDE to take advantage of the image embedding feature for the exe file. I find this not yet really userfriendly.

There are of course also recent new features I find really beeing big improvements.
- the image embedding in the exe file
- the dll embedding in the exe file
- the autocomplete feature with Ctr and Space
- and the new libraries

Best regards.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I find that the need to add to each public routine or variable the module name where it was declared as a disadvantage.
From my user point of view, when a routine or variable is public it is public with it's name whatever module it was declared in. I don't see the need to 'privatize' it again with it's module name when accessed from outside.
It should be the same principle as with the global module variables and the private subroutine variables, just one layer above. If one would have the module name in a routine or variable this would still be possible, but only if someone wants it, not as default need for everybody. I can understand that is's easier for the language developper, but it's more combersome for the language user.

Maybe an "Import module" option will be available in the future.
I think that the module prefix is important and it makes the code less tangled and easy to follow.

Another missing feature for me is that the comlementary files 'belonging' to the module are not automatically copied with the module file. So I can load a given module in a project, the module file is copied to the program's folder, and then I must look in the modules folder, if the module is saved in a specific folder, or somewhere else, and copy all the complementary files, mainly image files for buttons. I declare the image files in an ImageList in the IDE to take advantage of the image embedding feature for the exe file. I find this not yet really userfriendly.
I agree on that and I wanted to add it in version 6.50. However it was more complicated than expected and it will have to wait for the next release.
 

epsharp

Member
Licensed User
Longtime User
Thanks a second time to Agraham.

I hadn't come across your string library and when I looked at your source, I thought I was looking at my original "subroutine library" that I wrote as the first step in trying to code in JAVA.

When I started with Basic4ppc it just seemed logical to convert this first so that I could use the the same commands. In JAVA, the class was named SR so all string commands were prefixed with >SR.< as were others, CSV both in and out, DB for database commands, AU for audio, etc. I needed to replace the >.< with >_< but when writing programs, you tend to forget the little things (like >_<). That's why I was happy to see module support.

Back to the point. Is it possible to compile your .CS file (or any CS for that matter) to a new .DLL using only the CSC.exe that is in the Microsoft.NET folder? If so, could you kindly give me the command line parameters for the compile?
 

agraham

Expert
Licensed User
Longtime User
Is it possible to compile your .CS file (or any CS for that matter) to a new .DLL using only the CSC.exe that is in the
Microsoft.NET folder?
In principle yes as Visual Studio Basic4ppc use that to compile with but if you want to compile for the device you would need the device SDK for the Windows Mobile version you wanted to target installed on your PC - but you need that anyway to optimise compile for a device with Basic4ppc.
If so, could you kindly give me the command line parameters for the compile?
I don't know as I have never done it. I let Visual Studio 2005 take care of that side of things. The command line string would be horrendously long with all the references as paths, you would need a response file to avoid mistakes. If you want to play then try SharpDevelop SharpDevelop @ic#code it is free and it too will front-end csc.exe for you. You still need the device SDK for device compilation. If you are only interested in desktop stuff then the Microsoft Visual C# Express Editions 2005 and 2008 are also free but can't do devices although (I believe) can produce dlls.
 
Top