[Gambas-user] Interesting Problem

Leo Barnhoorn leo.barnhoorn at ...246...
Tue Sep 14 23:08:04 CEST 2004


Hello Mr. Duval,

I use something like this to make a .conf file for my own projects.
To create a .conf file.

PUBLIC SUB CreateConfigFile()
   DIM hSettings AS Settings

   hSettings = NEW Settings (System.Home &/ ".phpedit/phpedit.conf") 

   hSettings["/HomeDirWebServer"] = "/srv/www/htdocs"
   hSettings["/UseHomeDirWebServer"] = TRUE
   hSettings["/HomeDirVirtualServer"] = System.Home &/ "www"
   hSettings["/UseHomeDirVirtualServer"] = FALSE   
   hSettings["/CurrentProject"] = "unknown"
   hSettings["/CurrentProjectDir"] = "unknown"
   
   hSettings.Save
END

This i use set values in the .conf file.

PUBLIC SUB SetConfigValue(Key AS String, Value AS Variant)
   DIM hSettings AS Settings

   hSettings = NEW Settings (System.Home &/ ".phpedit/phpedit.conf") 

   hSettings[Key] = Value
   
   hSettings.Save
END

This i use to get values from the .conf file.

PUBLIC FUNCTION GetConfigValue(Key AS String, OPTIONAL Value AS Variant) AS 
Variant
   DIM hSettings AS Settings

   hSettings = NEW Settings (System.Home &/ ".phpedit/phpedit.conf") 

   IF NOT IsNull(Value) THEN
      RETURN hSettings[Key, Value]
   ELSE
      RETURN hSettings[Key]
   ENDIF
END

This i use to make .project files.

sDir is the path to your project. Be sure that the project dir exist.

PUBLIC SUB CreateProjectFile(sDir AS String)
   DIM hProject AS Settings

   hProject = NEW Settings (sDir &/ ".project")
   
   hProject["/ProjectName"] = File.Name(sDir)
   hProject["/ProjectTitle"] = "Imported project."
   hProject["/ProjectDescription"] = "Imported project."
   hProject["/ProjectVersion"] = "0.0.0"
   hProject["/ProjectDir"] = sDir
   
   hProject.Save
END

Just use the GB Settings class, no neat to do it your self.

I hope you can use this examples for your project.

Regards,
Leo Barnhoorn.



On Tuesday 14 September 2004 17:32, Mr JH Deval wrote:
> Let me start by saying I may have found a bug I am not
> sure but I am posting this to find out.
>
> Let me give some background. I was not satisified with
> the location of the .conf file in a .gambas directory
> so I proceed to write my own using a similiar syntax
> as getsetting and savesetting in VB. Here is the code
> but the problem is when the loop runs to read the conf
> file in each consequtive round put a character in the
> first location first line. Which obviously causes me
> some problems.
>
>   IF ConfFileExists = TRUE THEN
>     confOutput = ""
>     OPEN AppHomeDir & AppTitle & ".conf" FOR READ AS
> #confFile
>       DO WHILE NOT Eof(confFile)
>         LINE INPUT #confFile, strExisting
>           IF strExisting <> "" THEN
>             OldSetting = Split(strExisting,"=")
>             IF UCase(OldSetting[0]) = UCase(Setting)
> THEN
>               OldSetting[1] = SettingToSave
>             END IF 'Oldsetting[0] = Setting
>             IF OldSetting[0] <> "" THEN
>               confOutput = confOutput &
> Trim(OldSetting[0]) & "=" & Trim(OldSetting[1]) &
> GB.NewLine
>             ENDIF 'OldSetting[0] <> ""
>           ENDIF 'StrExisting <> ""
>       LOOP
>     CLOSE #confFile
>   ENDIF
>
>
>
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!
> http://promotions.yahoo.com/new_mail
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: thawte's Crypto Challenge Vl
> Crack the code and win a Sony DCRHC40 MiniDV Digital Handycam
> Camcorder. More prizes in the weekly Lunch Hour Challenge.
> Sign up NOW http://ad.doubleclick.net/clk;10740251;10262165;m
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user





More information about the User mailing list