Discussion:
Why this code is bad
(too old to reply)
Lance Edmonds
2003-07-10 14:51:29 UTC
Permalink
Are you sure JVMD? that code works ok for me (I put some text into the
TEXTBOX control, and clicked EXIT which saved it successfully to the
CONFIG.INI file.

However, chances are that the file writing code is failing for you,
but this is not being detected as there is no error testing in the
WriteConfig() routine, and I believe that is the cause of the
confusion.

For example, the code will likely fail if the CONFIG.INI file is
already open by another program (such as NOTEPAD), as the other
application will likely place a lock on the file while it has it open,
and hence your code will not be able to open the file.

Basically, In this situation, your code makes no attempt to detect the
error, and regardless of whether the OPEN statement was successful or
not, it continues on trying to write to a file that may not be open,
which creates yet another run-time error.

In summary, I believe that adding error testing code to your
WriteConfig() routine will help here. Please refer to "Errors and
error testing" in the documentation for more info on run-time error
detection.

Thanks!
If you select c:\windows\notepad.exe and clic exit, the Config.ini
file is not created or modify.
If you write any text in Textbox and clic exit or just clic exit with
textbox empty the file is created and/or modify.
I passe 4hours on this code and i not understand !!
Please help me !
Thanks
Lance
PowerBASIC Support

-------------------------------------------------------------------------
PowerBASIC, Inc. | 800-780-7707 Sales | "We put the Power in Basic!"
316 Mid Valley Center | 831-659-8000 Voice | http://www.powerbasic.com
Carmel, CA 93923 | 831-659-8008 Fax | mailto:***@powerbasic.com
Peter Manders
2003-07-10 19:16:24 UTC
Permalink
On Fri, 11 Jul 2003 02:51:29 +1200, Lance Edmonds
<***@xtra.com> wrote:

Lance,

I was having problems with INI files on some sites, and I was unable
to get to the bottom of it. Just recently I found out that McAfee is
default setup to scan *.INI files. Along with the Windows system of
writing to these files, this can cause delays of upto 30 seconds
before a file actually gets written.

The cure is to add "*.INI" to McAfee's "do not scan" settings. An INI
file is unlikely to contain a virus on its own anyway. Instead McAfee
should detect attacks that affect INI files by scanning the
executables involved.

My bet is that JVMD is running this anti virus software in default
setup.

I hope this helps. Of course you're absolutely right about error
checking your code.

Peter.
Post by Lance Edmonds
Are you sure JVMD? that code works ok for me (I put some text into the
TEXTBOX control, and clicked EXIT which saved it successfully to the
CONFIG.INI file.
However, chances are that the file writing code is failing for you,
but this is not being detected as there is no error testing in the
WriteConfig() routine, and I believe that is the cause of the
confusion.
For example, the code will likely fail if the CONFIG.INI file is
already open by another program (such as NOTEPAD), as the other
application will likely place a lock on the file while it has it open,
and hence your code will not be able to open the file.
Basically, In this situation, your code makes no attempt to detect the
error, and regardless of whether the OPEN statement was successful or
not, it continues on trying to write to a file that may not be open,
which creates yet another run-time error.
In summary, I believe that adding error testing code to your
WriteConfig() routine will help here. Please refer to "Errors and
error testing" in the documentation for more info on run-time error
detection.
Thanks!
If you select c:\windows\notepad.exe and clic exit, the Config.ini
file is not created or modify.
If you write any text in Textbox and clic exit or just clic exit with
textbox empty the file is created and/or modify.
I passe 4hours on this code and i not understand !!
Please help me !
Thanks
Lance
PowerBASIC Support
-------------------------------------------------------------------------
PowerBASIC, Inc. | 800-780-7707 Sales | "We put the Power in Basic!"
316 Mid Valley Center | 831-659-8000 Voice | http://www.powerbasic.com
--
Peter Manders.

"There's only one way to have a happy marriage and as soon as I learn what
it is I'll get married again." Clint Eastwood

Please remove the 'u' to reply.
Loading...