[Gambas-user] tip to make it better
Frank Berg
frankberg at ...390...
Wed Apr 21 07:01:36 CEST 2004
Hi,
i try to make an module, witch can work with ini files like getPrivateProfileString(...) in VB
my first try is to read the ini file in an string array..
an question to the CodeMasters: what can i make better??
snip .....................
PRIVATE iniFile AS String[]
PRIVATE iniFileName AS String
PUBLIC iniErrorCode AS Integer
PUBLIC iniErrorText AS Integer
' read the hole File in an string array,
PRIVATE FUNCTION read_ini_File(myFileName AS String ) AS String[]
DIM f AS File
DIM s1 AS String
DIM s2 AS String
IF myFileName<>iniFileName THEN
DO
TRY OPEN myFileName FOR READ LITTLE AS #f
SELECT CASE Error()
CASE 0 ' open command is OK
' OPEN myFileName FOR READ LITTLE AS #f ' open the TRY line correct??
WHILE NOT Eof(f)
READ #f,s1,1
IF s1<>Chr(13) THEN s2=s2 & s1
WEND
CLOSE #f
iniFile=Split(s2,Chr(10))
iniFileName=myFileName
iniErrorCode=0
iniErrorText="OK"
RETURN iniFile
CASE 45 ' file not found
OPEN myFileName FOR CREATE AS #f
CLOSE #f ' must i close??
CASE ELSE
iniFileName=""
TRY CLOSE #f ' will it close if it can??
TRY iniFile.Clear ' will it clear the array if it can??
iniErrorCode=Error()
iniErrorText="Unknown Error for me" ' where can i read obout the error code numbers..
EXIT
END SELECT
LOOP
ENDIF
CATCH
iniFileName=""
TRY CLOSE #f
TRY iniFile.Clear
iniErrorCode=Error()
iniErrorText="Unknown Error for me"
END
snap ...................
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20040421/d9ce8231/attachment.html>
More information about the User
mailing list