About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Troubleshooting
Problem
This technote provides an example of using an API function GetPrivateProfileString within a GUI script. The GetPrivateProfileString function reads a string value from an RSP file and displays the return string value in the SQABasic message box
Resolving The Problem
Below is the SQABasic code example, which uses GetPrivateProfileString API function.
GetPrivateProfileString reads a string value from an RSP file. The parameters passed to the function specify which values will be read. The function returns the length of the value that was stored as the string variable, lpReturnedString. If the function was successful, the string read from the RSP file will be put into lpReturnedString. If not, it will instead receive the string given as lpDefault.
lpApplicationName:
The header of the section in the RSP file that the value is in - [General]
lpKeyName:
The name of the value to read - " TestDatastorePath "
lpDefault:
The value to return if a valid value cannot be read. Make the value something that would definitely not be read, such as "Error".
lpReturnedString:
A fixed-length string that will receive either the string read from the file or lpDefault.
nSize:
The length in characters of lpReturnedString.
lpFileName:
The filename of the RSP file to read from.
Example:
' Read the " TestDatastorePath " value under the [General] section of
' the RSP file "\\CompName\TestProjectDir\UserProject.rsp". The default value is "Error".
_______________________________________________________________________
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As Any, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Sub Main
Dim tdspath As String ' receives the value read from the RSP file
Dim slength As Long ' receives length of the returned string
tdspath = Space(255) ' provide enough room for the function to put the value into the buffer
' Read from the RSP file
slength = GetPrivateProfileString("General", "TestDatastorePath","Error", tdspath, 255, "\\CompName\TestProjectDir\UserProject.rsp")
tdspath = left(tdspath, slength) ' extract the returned string from the buffer
msgbox slength & chr(13) & tdspath
End Sub
[{"Product":{"code":"SSSHDX","label":"Rational Robot"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Scripting","Platform":[{"code":"PF033","label":"Windows"}],"Version":"2001a;2001a.04.00;2002;2002.05.00;2002 Release 2;2002.05.20;2003;2003.06.00;2003.06.12;2003.06.13;2003.06.14;2003.06.10","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]
Historical Number
23045
Was this topic helpful?
Document Information
More support for:
Rational Robot
Software version:
2001a, 2001a.04.00, 2002, 2002.05.00, 2002 Release 2, 2002.05.20, 2003, 2003.06.00, 2003.06.12, 2003.06.13, 2003.06.14, 2003.06.10
Operating system(s):
Windows
Document number:
334451
Modified date:
16 June 2018
UID
swg21151595