B4J Question Form and LoadLayout in MSACCESS sample

Marc VE

New Member
I have a long VB background (versions 1 through 6). Kudos by the way, B4J looks like a promising sucessor to VB. Here's hoping I can master it.

I'm trying to understand the first argument passed into AppStart.

Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("B4JHowToMSAccess")
MainForm.Show
'
AppInit
'
If initDatabase = True Then
loadDatabase
End If
End Sub

1. What is B4J passing into AppStart as Form1? What is already on Form1? (like controls and such) Is this a blank Form object with nothing on it?

2. When invoking LoadLayout("B4JHowToAccesMSAcess") I don't understand what is already in that layout. When I invoke Designer I get a blank form, however, it's unclear to me if Designer is just opening without any particular context, or if it is opening B4JHowToMSAcess.fxml implicitly (something I didn't even notice was in the project until I discovered the File Manager button on the bottom right of the IDE.

3. It's not possible to even explicitly open an fxml file in designer so I'm very confused--is fxml a layout or isn't it? If it is, why can't I select it? Is it some kind of unspoken "default" that gets loaded into Designer?

Sorry if this is covered in some documentation already, but I've been trying to swallow everything at once and there doesn't seem to be a clear starting place for me. The documentation seems more like a dictionary/encyclopedic reference (understandable starting place for the model of the B4X product line), but I haven't yet found a functional "I know VB basics, talk me through the starting theory so I know where everything is in a project."

I understood how all the parts of a VB project fit together, but getting a grasp of B4J with different the terms is throwing me off. Examples:
  • Maps remind me of perl hashes; until I realized that, those were a bit fuzzy to me
  • I get that there are "classes" but I'm not ready to equate those to my understanding of VB classes yet
  • I still don't have a clear understanding of when certain objects come into existence and what the order of events is
  • I can't seem to find a clear description of an Activity (theory, anatomy, syntax, etc)
  • I still need to separate forms vs layouts, I'm guessing layouts derive from B4J's java foundation
  • The overall logic of the database example is something I'm still trying to understand; I'm DBUtils is something I won't need to touch, but I hope to develop an understanding of the logic I will need to encapsulate for each major object type in the database front end I want to write.
Apologies for length, I spent the last couple weeks scouring the forums and trying to digest everything, and just finally gave in and decided to post.

Thanks to all the existing posters for great contributions and questions, especially @Erel.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. It is an empty form that is created for you. Its size is determined by #MainFormWidth / #MainFormHeight attributes.

2. FXML layouts are deprecated layouts that are based on scene builder. I recommend you to start with newer examples that are based on the internal designer (bjl files).

There are such examples in the beginner's guide and here: https://www.b4x.com/android/forum/threads/getting-started-examples.57537/#content
 
Upvote 0

Marc VE

New Member
1. So it makes sense to use it, but there would be no impact to creating another object, right? I ask only for the purpose of understanding the inner workings of B4.

2. Good, I much prefer the designer. I will work to eliminate the old fxml file.

I've been poking through many of your examples in the past week. I finally made some significant progress yesterday with my database app. I think I'm "in the zone" now. I smiled when I saw your sorting algorithms example. Took me back 25 years. :)
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi Marc!

Your questions are to wide for a simple answer and I do not know much of vb6 I learned from VBA I think they are like relatives.

Form is a window. The window has a base panel that you can invoke: mainform.rootpane

Layout is a template of controls to add to your pane in the window or any other pane.

Then. Dbutils is good but not perfect for access, if you have to stick with access I can help you with some basic steps.

Anyway I suggest to look at SQLite.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Feel free to ask any question, here lands a lot of people with vb 1 - 6, and get used to b4j quite fast.
 
Upvote 0
Top