#120441 - 2004-06-01 03:45 PM
Readprofilestring Timeout Network?
|
wandan
Getting the hang of it
Registered: 2000-10-05
Posts: 50
|
Hello.
If I use readprofilestring to read from an ini file located on a network drive. Is there a timeout within readprofilestring? I use something like IF readprofilestring(x:\test.ini, "Test", "Test") <> readprofilestring(d:\test.ini, "Test", "Test") ? "test" endif
x: is located on a network drive (Novell File Server). An sometimes, the messagebox test is shown, but the 2 ini Files are the same?
Therefore, I think there could be a timeout the problem?
Using lates Kix version.
Thanks for your help. Danny
|
|
Top
|
|
|
|
#120442 - 2004-06-01 04:13 PM
Re: Readprofilestring Timeout Network?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
You may need to trim the values to ensure that there are no trailing spaces causing a problem.
To check for a read failure you need to test the error values, something like: Code:
$ValueX=ReadProfileString("X:\test.ini","Test","Test") If @ERROR "Cannot check - failed to read value from X:" ? "Error was: "+@ERROR+", "+@SERROR ? Else $ValueD=ReadProfileString("D:\test.ini","Test","Test") If @ERROR "Cannot check - failed to read value from D:" ? "Error was: "+@ERROR+", "+@SERROR ? Else If $ValueX <> $ValueY "Values do not match" ? EndIf EndIf EndIf
|
|
Top
|
|
|
|
#120443 - 2004-06-01 04:30 PM
Re: Readprofilestring Timeout Network?
|
wandan
Getting the hang of it
Registered: 2000-10-05
Posts: 50
|
Hello.
Thanks for your answer. Readprofilestring doesnīt return an error code. I wrote a test script, and if delete the test.ini my value isnīt shown, but @error hasnīt an error number.
It always returns 0 also, if readprofilestring doesnīt find the ini File.
Greetings
Danny
Edited by wandan (2004-06-01 04:32 PM)
|
|
Top
|
|
|
|
#120444 - 2004-06-01 05:08 PM
Re: Readprofilestring Timeout Network?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Pity 
In that case, this should work: Code:
$ValueX=MyReadProfileString("X:\test.ini","Test","Test") If @ERROR "Cannot check - failed to read value from X:" ? "Error was: "+@ERROR+", "+@SERROR ? Else $ValueD=MyReadProfileString("D:\test.ini","Test","Test") If @ERROR "Cannot check - failed to read value from D:" ? "Error was: "+@ERROR+", "+@SERROR ? Else If $ValueX <> $ValueY "Values do not match" ? EndIf EndIf EndIf Function MyReadProfileString($sFile,$sSection,$sValue)
If ReadProfileString($sFile,"","")="" If @ERROR Exit @ERROR Else Exit 2 EndIf EndIf
$MyReadProfileString=ReadProfileString($sFile,$sSection,$sValue) Exit 0 EndFunction
|
|
Top
|
|
|
|
#120446 - 2004-06-02 10:41 AM
Re: Readprofilestring Timeout Network?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
READPROFILESTRING() does not set KiXtart @ERROR codes.
Yet 
Just a bit of forward planning, but the UDF has the catch-all "If @ERROR Exit @ERROR Else Exit 2 EndIf" which caters for the current (no error) implementation.
I have a UDF posted somewhere which emulates ReadProfileString() and responds with error codes for missing sections, values and read errors. However it's really old and probably embarassingly badly coded so I didn't bother to try and dredge it up. This UDF is quick'n'dirty and will do the job just as well.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 623 anonymous users online.
|
|
|