This limitation of Jabaco could be circumvented if there were a reliable way to determine if code is executed from within the IDE or not.
But I have not been able to write a good "isInIDE()" function.
One approach could be to evaluate System.getProperty("User.Dir").
A compiled executable typically is run somewhere else outside the source code directory.
In good old VB6 the trick was to combine "on error resume next" and "debug.assert 1/0".
But this dow not work in Jabaco for the time being.
Any suggestions?
A1880
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
Public Form1 As New Form1 Public Sub main(ByJava args() As String) Dim myArgs() As String Dim myTestArgs() As String = ("Abra", "cadabra!" ) Dim i As Integer Dim s As String = "" If isInIDE Then myArgs = myTestArgs Else myArgs = args End If For i = LBound(myArgs) To UBound(myArgs) s = s & myArgs(i) & vbCrLf Next i If s = "" Then s = "<no arguments>" End If MsgBox s Form1.SetDefaultClose() Form1.Show() End Sub |
But I have not been able to write a good "isInIDE()" function.
One approach could be to evaluate System.getProperty("User.Dir").
A compiled executable typically is run somewhere else outside the source code directory.
In good old VB6 the trick was to combine "on error resume next" and "debug.assert 1/0".
But this dow not work in Jabaco for the time being.
Any suggestions?
A1880
In the meantime, I've managed to solve the "isInIDE()" riddle:
If a program gets started from within the IDE, the upper bound of "args" evaluates to "-1".
However, a new problem came up:
If you pass a filename with blanks ("a file with blanks.txt") to your program,
the following arguments arrive inside:
args(0): name of the executable
args(1): a
args(2): file
args(3): with
args(4): blanks.txt
Obviously, it would be better to get:
args(0): name of the executable
args(1): a file with blanks.txt
Any ideas?
A1880
p.s.: I've found out that this problem is only present for *.exe files created by Jabaco.
If you start a Jar file via "java -jar my.jar", blank-separated parameters in quotes will be handled properly.
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
Public Sub main(ByJava args() As String) Dim myArgs() As String myArgs = args Dim i As Integer Dim s As String Dim isInIDE As Boolean = (UBound(myArgs) < Lbound(myArgs)) If isInIDE Then s = "we are in IDE!" Else s = "we are outside the IDE!" End If s = s & vbCrLf For i = Lbound(myArgs) To Ubound(myArgs) s = s & i & ": '" & myArgs(i) & "'" & vbCrLf Next i If s = "" Then s = "(no arguments!)" End If MsgBox s End Sub |
If a program gets started from within the IDE, the upper bound of "args" evaluates to "-1".
However, a new problem came up:
If you pass a filename with blanks ("a file with blanks.txt") to your program,
the following arguments arrive inside:
args(0): name of the executable
args(1): a
args(2): file
args(3): with
args(4): blanks.txt
Obviously, it would be better to get:
args(0): name of the executable
args(1): a file with blanks.txt
Any ideas?
A1880
p.s.: I've found out that this problem is only present for *.exe files created by Jabaco.
If you start a Jar file via "java -jar my.jar", blank-separated parameters in quotes will be handled properly.
This post has been edited 1 times, last edit by "A1880" (Feb 2nd 2010, 4:28pm)
Similar threads
-
General topics, questions and discussions »-
First 'serious' app, and something's not right
(Oct 5th 2009, 3:49pm)
-
General topics, questions and discussions »-
Java and memory usage
(Sep 16th 2009, 10:15pm)
