Hey all... I rewrote the "passing.bas" (which I'm able to compile) from the examples\manual\proguide\arrays folder, but I'm getting errors.
Would anyone be willing to tell me what I'm doing wrong?
' FreeBasic
' =============================================================================
#Define UNICODE
#Define _WIN32_WINNT &h0602
#Include Once "windows.bi"
#Include Once "file.bi"
#Include Once "vbcompat.bi"
#Include Once "win\shobjidl.bi"
#Include Once "win\TlHelp32.bi"
#Include Once "crt\string.bi"
#Include Once "win\Shlobj.bi"
'#Include Once "Afx\CWindow.inc"
'#Include Once "Afx\AfxFile.inc"
'#Include Once "Afx\AfxStr.inc"
'#Include Once "Afx\AfxTime.inc"
'#Include Once "Afx\AfxGdiplus.inc"
'#Include Once "Afx\AfxMenu.inc"
'#Include Once "Afx\AfxCom.inc"
'#Include Once "Afx\CXpButton.inc"
'#Include Once "Afx\CMaskedEdit.inc"
'#Include Once "Afx\CImageCtx.inc"
'#Include Once "Afx\CAxHost\CWebCtx.inc"
'#Include Once "Afx\CWinHttpRequest.inc"
'Using Afx
' =============================================================================
ReDim Shared rgwszPaths(0) AS WSTRING * MAX_PATH
Dim Shared rgwszPathsTot As Long
' =============================================================================
function repl(byref replSource As String, replTheWhat As String, replTheNew As String, replCount As Long = 9999 ) as string
Dim As String replDestination = replSource ' must be above the x=instr
Dim As Long x = Instr(replDestination, replTheWhat) ' must be below dest=src
Dim As Long y, nWhatLen, nNewLen, lineCounter
nWhatLen = len(replTheWhat)
nNewLen = len(replTheNew)
lineCounter = 0
do while x
y = x + nWhatLen
if y > len(replDestination) then
replDestination = Left(replDestination, x-1) + replTheNew
else
replDestination = Left(replDestination, x-1) + replTheNew + Mid(replDestination, y)
end if
lineCounter += 1
if lineCounter >= replCount then
exit do
end if
x = Instr(x+nNewLen,replDestination, replTheWhat)
loop
return replDestination
End Function
' =============================================================================
Function splitString(ByVal source As WString, destination(Any) As WString, ByVal delimiter As WString) as Long
Do
Dim As Integer position = InStr(1, source, delimiter)
ReDim Preserve destination(UBound(destination) + 1)
If position = 0 Then
destination(UBound(destination)) = source
Exit Do
End If
destination(UBound(destination)) = Left(source, position - 1)
source = Mid(source, position + Len(delimiter))
Loop
Return UBound(destination)
End Function
' =============================================================================
Function ListFiles(wszFolder as WString) as Long
Dim hSearch as HANDLE
Dim WFD AS WIN32_FIND_DATAW
Dim wszPath AS WSTRING * MAX_PATH
Dim wszCurPath AS WSTRING * MAX_PATH
Dim wszFullPath AS WSTRING * MAX_PATH * 2
if right(wszFolder,1) <> "\" then
wszFolder += "\"
end if
wszPath = wszFolder
wszCurPath = wszPath + "*.*"
' Find the files ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
hSearch = FindFirstFile(wszCurPath, @WFD)
IF hSearch <> INVALID_HANDLE_VALUE THEN
DO
IF (WFD.dwFileAttributes AND FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY THEN
' found a folder
ELSE
wszFullPath = wszPath & WFD.cFileName
' Store the full path in the array
rgwszPathsTot += 1
ReDim Preserve rgwszPaths(rgwszPathsTot) AS WSTRING * MAX_PATH
rgwszPaths(rgwszPathsTot) = wszFullPath ' zero-based array
END IF
LOOP WHILE FindNextFile(hSearch, @WFD)
FindClose(hSearch)
END IF
Return rgwszPathsTot
End Function
' =============================================================================
Function WinMain( _
ByVal hInstance As HINSTANCE, _
ByVal hPrevInstance As HINSTANCE, _
ByVal szCmdLine As ZString Ptr, _
ByVal nCmdShow As Long _
) As Long
Dim wszFolder AS WSTRING * MAX_PATH
Dim sArray(Any) As WString * MAX_PATH
Dim As Long x, y, lineCount, splitCount
rgwszPathsTot = 0
wszFolder = "c:\download"
lineCount = ListFiles(wszFolder)
for x = 1 to lineCount
? rgwszPaths(x)
splitCount = splitString( rgwszPaths(x), sArray(), " - " )
if splitCount then
for y = 1 to splitCount
? sArray(y)
next y
end if
next x
Return 0
End Function
' =============================================================================
End WinMain( GetModuleHandle(Null), Null, Command(), SW_NORMAL )
' =============================================================================