You are not logged in.

Giasone70

Beginner

  • "Giasone70" started this thread

Posts: 8

Date of registration: May 7th 2011

  • Send private message

1

Monday, June 13th 2011, 1:24am

"Dir" command

Forgive me for my ignorance, but i'm rather a beginner.
i'm trying to port this under Jabaco, but it doesn't work:

Source code

1
2
3
4
5
6
Dim s as String
s = Dir ("c:\data\*.dat")
   Do While s <> ""
  	cmbUtente.AddItem (s)
  	s = Dir
   Loop


I get an error in compilation!
May someone help me?
Thanks in advance.
Alex

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

Tuesday, June 14th 2011, 10:08pm

Yes, "Dir()" is not fully VB6 compliant.

The following code might inspire you:

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
Option Explicit

Import java#io#File 

Public Sub Command1_Click()
   Dim s As String   
   Dim childFolders() As File
   Dim item As File
   
   childFolders() = New File("c:\tmp").listFiles()
   
   For Each item In childFolders
      If (item.isDirectory()) Then
         Debug.Print "Dir " & item.getName()
      Elseif (item.isFile()) Then
         If WildCardMatch(item.getName(), "*.tmp") Then
            Debug.Print "Temp File " & item.getName()
         Else
            Debug.Print "File " & item.getName()
         End If
      Else
         Debug.Print "??? " & item.getName()
      End If
   Next
End Sub

'  cf.  http://www.adarshr.com/papers/wildcard

Private Function WildCardMatch(text As String, pattern As String) As Boolean
   ' Create the cards by splitting using a RegEx. If more speed 
   ' Is desired, a simpler character based splitting can be done.
   Dim cards() As String 
   Dim card As String
   Dim idx As Integer 
   Dim ret As Boolean = True
   
   cards = Split(pattern, "\*")

   ' Iterate over the cards.
   For Each card In cards
      idx = InStr(text, card)
         
      ' Card Not detected In the text.
      If (idx < 1) Then        
         ret = False
         Exit For
      End If
         
      ' Move ahead, towards the right of the text.
      text = Mid(text, idx + Len(card))
   Next
        
   WildCardMatch = ret
End Function


Greetings

A1880

Rate this thread
WoltLab Burning Board