The Executioner Is In
Some Access Tools IV : The Essential File Reading Code
Do While Not EOF(iScript)
Line Input #iScript, sLine
sSQL = ""
If (Left$(sLine, 2) = "//") Or (sLine = "") Then
' Comment or empty line, Do nothing
Else
If UCase(sLine) Like "[#]INCLUDE*" Then
' Check for an include file reference
sInclude = Trim$(Right$(sLine, Len(sLine) - 8))
If giUseTokens Then
' Tokens may be used to specify filename or part thereof
sInclude = ResolveTokens(sInclude)
End If
If Dir$(sInclude) Then
' Return the updated index value
iCurrProc = ReadProcs(sInclude, sSQLProcs(), iCurrProc)
End If
Else
If Right$(Trim$(sLine), 1) <> ";" Then
' Multiple line expression
Do
' Get all the lines of the statement
Line Input #iScript, sLine
sSQL = sSQL & " " & sLine
Loop Until Right$(Trim$(sSQL), 1) = ";"
Else
' Single line of SQL
sSQL = sLine
End If
End If
End If
' If we have something add it to the array
If sSQL <> "" Then
If giUseTokens Then
' Resolve token references if tokens are turned on
sSQL = ResolveTokens(sSQL)
End If
iCurrProc = iCurrProc + 1
ReDim Preserve sSQLProcs(1 To iCurrProc) As String
sSQLProcs(iCurrProc) = Left$(sSQL, Len(sSQL) - 1) ' remove ;
End If
Loop
Again, quite simple. If you read my Access Tools article from last AVDF issue you will have noticed that some of syntax for the script file has changed. I am now using '//' to indicate a comment instead of ';'. Also, I now use ';' as a statement terminator to better support multi-line SQL statements.
![]()