You are not logged in.

axtens

Trainee

  • "axtens" is male
  • "axtens" started this thread

Posts: 37

Date of registration: Mar 16th 2009

Location: Perth, WA, Australia

Occupation: Software/Test Engineer

Hobbies: be a husband and a dad, play ukulele, sing

  • Send private message

1

Tuesday, October 6th 2009, 8:13am

Set commandline in IDE

In the next iteration of Jabaco, please provide a mechanism to set commandline options in the IDE. When one is testing apps that use the command line, the current inability is frustrating.



Kind regards,

Bruce.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Saturday, October 10th 2009, 9:31pm

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.

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

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

3

Tuesday, February 2nd 2010, 4:17pm

In the meantime, I've managed to solve the "isInIDE()" riddle:

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)


Rate this thread
WoltLab Burning Board