Page 1 of 1 1
Topic Options
#120441 - 2004-06-01 03:45 PM Readprofilestring Timeout Network?
wandan Offline
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 Offline
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 Offline
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 Offline
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
#120445 - 2004-06-02 05:14 AM Re: Readprofilestring Timeout Network?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
READPROFILESTRING() does not set KiXtart @ERROR codes.
_________________________
There are two types of vessels, submarines and targets.

Top
#120446 - 2004-06-02 10:41 AM Re: Readprofilestring Timeout Network?
Richard H. Administrator Offline
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
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 623 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.058 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org