Wish Create an Alias Attribute for Starter Module

Mahares

Expert
Licensed User
Longtime User
Since most variables are preferably declared in the Starter Service module, how about create an alias attribute for the ‘Starter’ module to tidy up the code. For instance: in the starter we will have:
B4X:
#Alias: S  'or whatever user wants
And in the activity module instead of:
B4X:
If Starter.SQL1.IsInitialized = False Then
    Starter.SQL1.Initialize(Starter.SQLDBPath, Starter.SQLDBName, True)
End If

We will have this:
B4X:
If S.SQL1.IsInitialized = False Then
    S.SQL1.Initialize(S.SQLDBPath, S.SQLDBName, True)
End If
 

Dave O

Well-Known Member
Licensed User
Longtime User
I agree that having to use "Starter" as a prefix is cumbersome.

However, as discussed in this Starter service thread, we can work around this if we declare our Process_Globals variables in another module with a intentionally short name. (I use a "common" code module that I renamed to "c".)

Once it's declared there, I can code the following in Starter > Service_Create:
B4X:
c.SQL1.Initialize(c.SQLDBPath, c.SQLDBName, True)

The prefixing problem itself is nicely solved in other languages by the WITH or USES keywords, as wished for in this post.
 
Last edited:

Dave O

Well-Known Member
Licensed User
Longtime User
I know that this is just an example. However you should initialize SQL1 in Service_Create of the starter service.
Thanks Erel, I've updated my example above to make this a bit more clear.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…