
Dim a string to a fixed size during runtime
Get does NOT require fixed length strings. It only requires that the
buffer(string) be set to the correct size beforehand. The example below will
do what you want.
Function OpenFile (byref strFile as string, byref RecSize as integer) as
boolean
Dim iFile As Integer
Dim strSomething as string
strSomething = String$(RecSize, " ")
iFile = FreeFile
Open strFile For Binary Access Read As #iFIle
Get #iFile, , strSomething
Close #iFile
End Function
HTH, Rocky Clark (Kath-Rock Software)
Quote:
> Is there a way of dimensioning a string to a fixed length using a
> variable during runtime instead of declaring the length as a constant
> during design time. The GET and PUT commands require fixed length
> variables, but I want to create a dll to for simple file manipulation
> with different record lengths.
> This works
> dim strSomething as string * 100
> This also works
> const RECSIZE=100
> dim strSomething as string * RECSIZE
> What I want to do is something like the following
> function OpenFile (byref strFile as string, byref RecSize as integer) as
> boolean
> dim strSomething as string * RecSize
> Thanks.