* :--------------------------------------- * ------------------------: Copybook for INI file routines. * : * : See the documentation for details. * :--------------------------------------- * * Functions to create/update initialization (.INI) files. * * ---------------------------------------------------------------- * API-GETPRIVATEPROFILESTRING---- Retrieves a string from the * specified section of an * initialization file. * * API-WRITEPRIVATEPROFILESTRING-- Copies a string into the * specified section of an * initialization file. * * API-WRITEPRIVATEPROFILESECTION- Copies multiple strings into * the specified section of an * initialization file. * ---------------------------------------------------------------- * * The functions are similar. Here's how to save a value: * * COPY WIN32API. * COPY INIFILE. * . * . * ------------------------: Specify the .INI file name. * * MOVE 'TEST.INI' TO INI-FILENAME. * * ------------------------: Specify the [Section] name. * * MOVE 'Section 1' TO INI-FILE-SUBKEY. * * ------------------------: Specify the value name and associated * : data to be stored. * * MOVE 'Value 1' TO INI-FILE-VALUENAME. * MOVE 'My Text Data' TO INI-FILE-DATA. * * ------------------------: Call the API to update the .INI file. * * SET API-WRITEPRIVATEPROFILESTRING TO TRUE. * CALL 'GSWINAPI' USING WIN32API-PARMS * INI-FILE-PARMS * INI-FILE-FILENAME * WIN32API-C * WIN32API-D * WIN32API-E * WIN32API-F. * * ------------------------: If function failed, * : display a textual error message. * * IF WIN32API-FAILED * MOVE WIN32API-ERROR-TEXT TO my-error-message * do whatever to display my-error-message. * * ---------------------------------------------------------------- * * API-WRITEPRIVATEPROFILESECTION is a little different. * * INI-FILE-VALUENAME is not used for this function. * * The data in INI-FILE-DATA consists of one or more LOW-VALUE * terminated strings, followed by a final LOW-VALUE. * * Each string has the following form: Key=Text * * ------------------------: Load multiple strings in one call: * * STRING 'Value 1=My Text Data 1' LOW-VALUE * 'Value 2=My Text Data 2' LOW-VALUE * 'Value 3=My Text Data 3' LOW-VALUE * LOW-VALUE * DELIMITED SIZE INTO INI-FILE-DATA. * ---------------------------------------------------------------- * 01 INI-FILE-PARMS. * : Name of the [Section] 05 INI-FILE-SUBKEY PIC X(254). * : Your name for this data item. You * : can store multiple data items under * : the same [Section] name... * : * : For Write functions: * : If you do not specify a valuename, * : deletes the entire [Section]. 05 INI-FILE-VALUENAME PIC X(32). * : Text data associated with your key. * : Binary values are unsupported; this * : must be TEXT data. If you're storing * : numeric data, save it as DISPLAY, not * : binary (COMP-4 or COMP-5) format. * : * : Function | Use * : -------- --------------------------- * : WRITE Value to store/update; * : If none specified, * : delete key and value. * : * : GET Value retrieved; * : If not found, * : this will be unchanged. 05 INI-FILE-DATA PIC X(1023). * : Number of bytes returned. 05 INI-FILE-DATA-LENGTH PIC S9(9) COMP-5. * : Name of the .INI file. * : * : For Write functions: * : If you do not specify a full path, * : create in the Windows directory. * : * : For Get functions: * : If you do not specify a full path, * : looks in the Windows directory. * 01 INI-FILE-FILENAME PIC X(1023).