B4J Question multi param in non UI app

paul fredrick

Member
Licensed User
Longtime User
is possible send from batch file more of one parameter at non UI application ?
i have tested with one parameter and works, but i don't know how to setting other ARGS() in code.
B4X:
#Region  Project Attributes
    #CommandLineArgs: test
#End Region

Sub Process_Globals
       Dim p1 As String
End Sub

Sub AppStart (Args() As String)
        p1 = Args(0)
End Sub

and i call myapp.jar myparam

p1 is equal 'myparam'

i would like p2,p3...

thanks
 

stevel05

Expert
Licensed User
Longtime User
Arguments are space delimited:
B4X:
#CommandLineArgs: test1 test2

args() will contain 2 string elements
 
Upvote 0

paul fredrick

Member
Licensed User
Longtime User
thanks... works :)
i have another problem because the second string have words that are not contiguous, then they are viewed as parameters, so the second parameter would be a string with multiple words ... can you solve this?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs: Test1 "Test2 param1"
    #MergeLibraries: True
#End Region

Sub Process_Globals
   
End Sub

Sub AppStart (Args() As String)
    For Each S As String In Args
        Log(S)
    Next
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

You will need to parse the string to get the parameters
 
Upvote 0
Top