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

Monday, October 5th 2009, 3:49pm

First 'serious' app, and something's not right

Okay, I'm writing a small app. It takes the following parameters: /TEXT: /SOUND: /TIMEOUT: and /NOTIMEOUT. The ideas is a commandline driven MsgBox with .WAV sounds and optional timeout. So far so good.

What I don't get yet, is
  • why the app stays in memory after it runs, requiring a process kill.
  • why the for loop doesn't work now, but did work before the if/elseif stuff got in there
  • why I tell the OK button to get the focus but it doesn't get it
Also It'd be really nice if the next iteration of Jabaco allowed one to set commandline options in the IDE. It's fine setting a breakpoint and then F8ing but when args contains nothing ...

Project attached. Code below

Thanks in advance,
Bruce.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Public Form1 As New Form1

Public Sub main(ByJava args() As String)
   Dim i As Integer
   Dim s As String
   Dim sCaption As String
   Dim sSound As String
   Dim sTimeout As String
   Dim bNoTimeout As Boolean
   Dim myArgs() As String

   myArgs = args
   Form1.SetDefaultClose()
   Form1.Caption = "Alerter v1"
   Form1.Visible = True
   Form1.Label1.TextAlign = fmTextAlignCenter
   Form1.Label1.FontBold = True
   Form1.Label1.FontSize = 18
   
   bTimeout = False
   For i = LBound(myArgs) To UBound(myArgs)
  	s = myargs(i)
  	MsgBox(s)
  	If BeginsWith(s, "/TEXT:") Then
     	sCaption = UnQuote(Mid(s,7))
  	ElseIf BeginsWith( s, "/SOUND:" ) Then
     	sSound = UnQuote(Mid(s,8))
  	ElseIf beginswith(s,"/TIMEOUT:") Then
     	sTimeout = UnQuote(Mid(s,10))
  	ElseIf beginswith(s,"/NOTIMEOUT") Then
     	bNoTimeout = True
  	End If
   Next
   Form1.Label1.Caption = sCaption & ", " & sSound & ", " & sTimeout & ", " & bNoTimeout
   Form1.bOK.SetFocus
   Form1.Show()
End Sub

Function BeginsWith( Byval sText As String, Byval sPart As String, Optional bCaseInsens As Boolean = True) As Boolean
   If bCaseInsens Then
  	BeginsWith = (LCase(Left(sText,Len(sPart))) = LCase(sPart))
   Else
  	BeginsWith = (Left(sText,Len(sPart)) = sPart)
   End If
End Function

Function UnQuote( ByVal sText As String) As String
   UnQuote = sText
   IF Left(sText,1)= Chr(34) Then
  	UnQuote = Mid(sText, 2)
   End If
   If Right(sText,1) = Chr(34) Then
  	UnQuote = Left(sText,Len(sText)-1)
   End If
End Function


Jabaco Source

1
2
3
Public Sub bOK_Click()
   hide 
End Sub
axtens has attached the following file:
  • Alerter.zip (5 kB - 395 times downloaded - latest: Mar 24th 2024, 10:08am)

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

2

Monday, October 5th 2009, 4:14pm

String.startswith

at first glance:

Have you noticed the function "startswith" of a java#lang#string? A Jabaco string can be casted to a java#lang#string "on the fly". Please write "Option Explicit" in the first line of Module1, start your app, and watch what Jabaco says.

Everything what belongs to the form should be coded inside the form-module, do not use "Form1" from everwhere, but use "Me" inside the form.

regards

OlimilO

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

3

Monday, October 5th 2009, 6:14pm

Quoted

Also It'd be really nice if the next iteration of Jabaco allowed one to set commandline options in the IDE
Yes, good suggestion, please note it under "Suggestions" so hopefully it won't be forgotten :)

Quoted

why the app stays in memory after it runs, requiring a process kill

as already mentioned in the forum at different places, please use System.exit(0)
or VBA#Global.End

Source code

1
2
3
4
Public Sub bOK_Click() 
   Unload Me 
   VBA#Global.End
End Sub


Quoted

why I tell the OK button to get the focus but it doesn't get it
Yes it does

Jabaco Source

1
2
3
Public Sub Form_Load() 
   bOK.SetFocus 
End Sub

regards
OlimilO

This post has been edited 1 times, last edit by "OlimilO" (Oct 5th 2009, 6:54pm)


Rate this thread
WoltLab Burning Board