#81932 - 2002-03-23 05:55 AM
Re: File Input/Output Primer
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
File Input/Output Primer part 3
WriteProfileString() Action: Copies a string to an initialization file. Syntax: WRITEPROFILESTRING ("file name", "section", "key", "string") Parameters: File name - String identifying the initialization file.
Section - String containing the name of the section of the initialization file where string is copied. If the section does not exist, it is created. The section name is not case-sensitive, and can contain any combination of uppercase and lowercase letters.
Key - String containing the name of the key to associate with string. If the key does not exist in the specified section, it is created. If this parameter is empty, the entire section, including all entries within the section, is deleted.
String - String to write to the file. If this parameter is empty, the key identified by key is deleted.
Returns: 0 Profile string written Error code Function failed
Example:
$Error ="Download of vpcur.lst failed!" GoTo ExitError ... $RC = WriteProfileString($WorkDir + "\PatternUpdater.ini","NAV","Updated",@Date + " - " + @Time) $Error ="" :ExitError $RC = WriteProfileString($WorkDir + "\PatternUpdater.ini","NAV","Error",$Error) Exit 1
While INI files were primarily for 16-bit apps, they still exist today. WriteProfileString() can be used not only to manipulate existing application INI files, but also to create your own to store all manner of data efficiently. The APIs used for WriteProfileString() and ReadProfileString() include everything you may need to write of enumerate data in an organized fashion without duplication or the need to read in entire files and parse them line by line. Also, since the API handles all the I/O, including opening and closing of the file, contention is pretty much eliminated.
Be aware that Windows 9x/ME has a 64k limit on INI file size. It is therefor advisable to split up the data into multiple files. Admin scripts can then be utilized to consolidate the data into CSV files, MDB or SQL tables.
Note: Portions of this were taken from the HTML help file created and compiled by ScriptLogic Corporation.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
Top
|
|
|
|
Moderator: Jochen, Radimus, Glenn Barnas, Allen, Arend_, ShaneEP, Mart
|
0 registered
and 542 anonymous users online.
|
|
|