Visual Basic "Space" Function returns a string consisting of the specified number of spaces.
Visual Basic Example:
Property Get Sections() As String
Dim sBuf As String
Dim iSize As String
Dim iRetCode As Integer
sBuf = Space$(8192)
iSize = Len(sBuf)
iRetCode = GetPrivateProfileString(0&, 0&, m_sDefault, sBuf, iSize, m_sPath)
If (iSize > 0) Then
Sections = Left$(sBuf, iRetCode)
Else
Sections = ""
End If
End Property
What is the Delphi equivalent for "Space"? Thanks.
To answer the direct question, the closest equivalent is StringOfChar:
sBuf := StringOfChar(' ', 8192);
Although if you were translating the code in the question to Delphi you would not fill the string with spaces. The VB code is not actually interested in what the string contains when it allocates it, it just uses Space$ as a simple way to allocate a string of certain length. The spaces are overwritten by the string returned from the API call.
In Delphi you would allocate a string of length 8192 by writing:
SetLength(sBuf, 8192);
And indeed in Delphi you would use TIniFile to read from an INI file. So if you are actually trying to translate the code in the question, I suggest that you don't do so and instead use Delphi's built-in libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With