[Gambas-user] tip to make it better

Budi Arief Gusandi budi at ...415...
Thu Apr 22 04:49:48 CEST 2004


On Wed, 21 Apr 2004 21:53:35 +0200, Fabien Bodard <abidoo.too at ...11...> 
wrote:

> Le mercredi 21 Avril 2004 07:01, Frank Berg a écrit :
>> 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 ...................
>
> You have something like that in the gambas ide... I think the ide conf 
> file
> are better to read than ini file....
>
> Look :
> 'util' code for that in this project, you have the parse code for gambas 
> conf
> file.
>
> Fabien
>
>


As benoit says, the util config system will be replaced later above v1.0 
with something much better. Unless u can copy paste the util module into 
your module, modify it a little bit to fit your need.

Regards,

Budi




More information about the User mailing list