[jawsscripts] Re: Problems with Read and Write Ini functions

  • From: Andrew Hart <ahart@xxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Fri, 09 Mar 2012 15:22:55 -0300

David,

Ok, I know you wrote this a while ago, but I was just wondering if using
IniFlush or IniFlushEx to flush the first write before trying to write
to the second file might help with this problem.  Perhaps the second
write is being made to the write buffer, which is still cached and
consequently the second write is being appendded to the same file
instead of being directed to the new one.  Actually, the whole ini file
system in JAWS is flakey.  It's not JAWS' fault imho, MS really made a
poor implementation of the ini file API.

It's just a thought that might be worth trying if you haven't done so
already.

Also, in case it's of use, Hotspot Clicker includes custom ini file
facilities which I wrote for Jim in the form of a COM server dll a long
time ago.  The JAWS interface to the dll is in HSCIniReplacements.jss.
It's been years since I've looked at it, but it includes all the
standard Ini reading and writing functions plus one very useful funtion
that JAWS does not include, IniWriteSection.  It allows you to put the
key=value pairs for an entire section in a string and write them out in
one go.  This is extremely useful if you are doing a very large quantity
of writes to ini files and Jim and I found it to be the most reliable
method for dealing with masses of updates to ini files and preventing
.ini files from becoming corrupted.  We've never seen it corrupt a file,
whereas it's not too difficult to make IniWriteString and
IniWriteInteger splatter the contents of an ini file.

the functions in HSCIniReplacements do not stop you from using the
regular JAWS ini functions.  The HSCIniReplacement versions have names
beginning with HNI and you use them more or less the same way as the
standard JAWS functions.  You can check out HSCIniReplacements.jss to
see how it all works and it seems Jim has also added some helper
functions for packing and unpacking strings for use with the
HNIReadSection and HNIWriteSection functions.

Cheerio,
Andrew.


On 21/01/2012 2:04 AM, David Pinto wrote:
> Dang,
> 
> The failure occurs when you have 2 instances of a same-named ini file. And 
> one file is one directory, and the other in another directory. For instance, 
> 2 files named Students.ini. Where the path to the first one is, 
> C:\HighSchool\Students.ini. And the path to the second one is, 
> C:\Elementary\Students.ini.
> If you follow the steps below, you will encounter 2 failures. First, there 
> will be the failure to create the second folder and file. But then we'll 
> reboot JAWS, and successfully create that second folder. But then the second 
> failure will be a failure to write to one of the 2 existing ini files. But 
> once again, we'll reboot JAWS, and successfully write to the ini file.  So, 
> Here's how to duplicate the above.
> 
> 1. Create the first folder and file via IniWriteString (aSectionName, aKey, 
> theKeysValue, HighSchoolPath)
> 2. Now try creating the second folder and file via IniWriteString 
> (aSectionName, aKey, theKeysValue, ElementaryPath).
> 3. Now open Explorer. You will not find the Elementary folder and its file. 
> You will only find the HighSchool folder there.
> 4. Now reboot jaws, and again run IniWriteString (aSectionName, aKey, 
> theKeysValue, ElementaryPath).
> 5. Now open Explorer and you will see that the Elementary folder and its 
> Students file were successfully created.
> 6. OK. Now that you have created both folders and files, you're about to see 
> once again how a path gets stuck in JAWS, or Windows, memory. So, in the 
> file in the Elementary folder that you just created, write a value to the 
> key.
> 7. In Explorer, open the file, and you will see that the value was written 
> successfully.
> 8. But now in the HighSchool Folder, write a different value to the key in 
> the Students file.
> 9. Now in Explorer, open up the Students file in the HighSchool folder, and 
> you will not see that new value. It failed to write.
> 10. Here's the worst part. Go check out the file in the Elementary folder, 
> and lo and behold! you will find that the second write that was aimed for 
> the Students file in the HighSchool folder, was actually written to the 
> students file in the Elementary folder.
> 11. Reboot JAWS, and once again write to the File in the High school folder. 
> You will find success.
> 
> David
> 
> ----- Original Message ----- 
> From: "Dang Manh Cuong" <dangmanhcuong@xxxxxxxxx>
> To: <jawsscripts@xxxxxxxxxxxxx>
> Sent: Friday, January 20, 2012 7:36 PM
> Subject: [jawsscripts] Re: Problems with Read and Write Ini functions
> 
> 
>> Could you give your script here? I always use ini functions to add, remove 
>> hotkey for alot of jkm files and didn't see any errors like that
>> ________________
>> Dang Manh Cuong
>> HCMC University of Pedagogy:
>> The Psychology and education
>> Mobile: +84 902-572-300
>> E-mail: dangmanhcuong@xxxxxxxxx
>> Yahoo ID: manhcuong0312
>> Skype name: dangmanhcuong
>> facebook: http://facebook.com/dangmanhcuong
>> Blog: http://vi.netlog.com/Cuong_littlecat
>> Website: http://ngoisaodanduong.com
>> http://www.saomaicenter.org
>> Projec-Website: http://code.google.com/p/dangmanhcuong
>>  ----- Original Message ----- 
>>  From: David Pinto
>>  To: jawsscripts@xxxxxxxxxxxxx
>>  Sent: Friday, January 20, 2012 8:36 AM
>>  Subject: [jawsscripts] Problems with Read and Write Ini functions
>>
>>
>>  There have been discussions on this list about different circumstances 
>> where
>>  JAWS ini functions are unreliable. I recently scoped out one particular
>>  circumstance where these functions fail entirely, or actually write to 
>> the
>>  wrong file. The problem occurs when the following 2 conditions are met.
>>  1. The ini functions are called 2 or more times consecutively but on
>>  different files. And 2. The different files have the exact same name, but
>>  they are in different folders. Here are the details along with some
>>  examples:
>>
>>  If you write to an existing INI file in an existing folder path, and then
>>  try writing to a same-named INI file in a different folder path, there 
>> will
>>  be a failure to write to that second same-named INI file. Instead, what
>>  happens is that the first written INI file is written to.  For instance:
>>  1. Write to the file <Anatomy.ini> in the path <C:\Girls\Anatomy.ini>. 
>> THIS
>>  WORKS JUST FINE.
>>  2. Next try writing to the same-named file <Anatomy.ini> that's in the 
>> path:
>>  <C:\Boys\Anatomy.ini>. THIS CONSISTENTLY FAILS. What happens is that 
>> instead
>>  of the Boys' INI file being written to, the Girls' INI file is written 
>> to.
>>
>>  The exact same failure occurs if the folders don't exist and you're using
>>  IniWriteString () to both create them and write to the INI file. For
>>  instance:
>>  1. Create and write to <C:\Girls\Anatomy.ini.>. THIS CREATES AND WRITES 
>> JUST
>>  FINE.
>>  2. Next try to create and write to <C:\Boys\Anatomy.ini.>. THIS 
>> CONSISTENTLY
>>  FAILS TO CREATE THE NEW FOLDER PATH.
>>  Instead, what happens is that the Anatomy.ini in the Girls folder is 
>> written
>>  to.
>>
>>  Finally, if you're merely wanting to create folders, the same behaviour
>>  holds. If the last folder in the second path is the same name as the last
>>  folder in the first path, then you can't create the second group of 
>> folders.
>>  For instance
>>  1. Create and write to <C:\Parents\Students>. THIS CREATES THE FOLDERS 
>> JUST
>>  FINE.
>>  2. Next try to create  <C:\Teachers\Students>. THIS CONSISTENTLY FAILS TO
>>  CREATE THE NEW FOLDER PATH.
>>
>>  Note that this behaviour is not corrected by including the IniFlush ()
>>  function, but it temporarily goes away by reloading JAWS.
>>
>>  On a different but related note. Sometimes when trying to manually delete
>>  one of those newly JAWS' created folders, Windows says "You need 
>> permission
>>  to perform this action" But if you shut down JAWS, deletion is 
>> successful. I
>>  haven't rigourously tested this out yet, so I can not duplicate the 
>> failure
>>  every time.
>>
>>  David Pinto
>>
>>
>>  __________�
>>
>>  View the list's information and change your settings at
>>  //www.freelists.org/list/jawsscripts
>>
>> __________�
>>
>> View the list's information and change your settings at
>> //www.freelists.org/list/jawsscripts
>>
>>
> 
> 
> __________�
> 
> View the list's information and change your settings at 
> //www.freelists.org/list/jawsscripts
> 
> 
> 


__________�

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: