You are not logged in.

scGuy

Beginner

  • "scGuy" started this thread

Posts: 40

Date of registration: Jan 12th 2011

  • Send private message

1

Thursday, January 20th 2011, 10:44pm

Dir() and wildcards

Experimenting with Dir(). If a file "c:\test.txt" exists, Dir() seems to only partly work:

sFile=dir("c:\test.txt") returns "test.txt" meaning the file's existance was found.

sFile=dir("c:\*.txt") returns blank, when VB would have returned "test.txt" (applying the wildcard.)



Is it possible Jabaco uses a different wildcard character than "*" (asterisk)?

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

2

Friday, January 21st 2011, 2:31am

Currently wildcards are not supported. Dir() is currently only a raw implementation. Have a look at its code:
http://code.google.com/p/jabacoframework…System.jsrc#321

But if you download the svn, there is an example program included, where you can browse throw the directorys.

Here a part of it a little bit changed for you. Possible it helps ypu:

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
Public Sub Command1_Click()

  Dim myDirectory As String
  Dim myHidden As Boolean

  myDirectory = "C:"
  myHidden = True
  
  Dim MsgString As String = ""
  Dim tmpString As String 
  Dim myFile As New java#io#File(myDirectory)
  Dim myList = myFile.listFiles
  Dim myItem As String
  For i = 0 To Ubound(myList)
    myItem = myList(i).getName()
    If (myList(i).isFile()=True) Then
      IF (NOT (myHidden=False AND myList(i).isHidden()=True)) Then
        tmpString = myList(i).getName()
        MsgString = MsgString + tmpString + Chr$(13) + Chr$(10)
      End If
    End If
  Next
  
  MsgBox MsgString
End Sub

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

Friday, January 21st 2011, 2:53pm

This sample raises the question of how to define a genuine Java array in Jabaco code.

"Dim myList" does not specify a variable type. The return value to myFile.listFiles, however, is an array of File.

Is there any proper way in Jabaco to define array variables like "myList" with an explicit variable type?
Out of a similar reason I have not managed to call a Java function out of Jabaco which requires an array of char parameter.
Any ideas?

Greetings!

A1880

scGuy

Beginner

  • "scGuy" started this thread

Posts: 40

Date of registration: Jan 12th 2011

  • Send private message

4

Friday, January 21st 2011, 3:14pm

In VB it would be "Dim myArray() as Byte" (etc), you can redim later to set bounds, but starts as an empty array--I tried this with Jabaco at one point and it seemed to work...

Rate this thread
WoltLab Burning Board