Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Save program settings ( file or registry ?)


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-2008, 10:22 AM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default Save program settings ( file or registry ?)

Hello,

i've got a question regarding how i can save my app's settings/preferences.

I want so save my app/user settings to somewhere ( file, registry), so i can read them after program start to save the user from doing the settings all the time over and over.

1. Do you need to save settings in your programs.. ?

2. How do you do this..?

2. has anyone a piece of code - or possibly a lib - ready that is handling the settings ( create/read/save)..?

i personally tend not to use the registry, for certain reasons, but if one has already something similar in place, i could be persuaded :-))


cheers

TWELVE
Reply With Quote
  #2 (permalink)  
Old 05-11-2008, 11:02 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 707
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Hello TWELVE,

I save the values of the setting variables in a simple text file when leaving the program. And load this file at startup and set the settings.

I do this in all my programs.
You can have a look in the Wine Cellar Manager program.
Wine cellar manager
The routines are SaveInit and LoadInit where I save the Language index, last file used and the table column widths. But anyway there is really nothing special in there.

You can also have a look in alfcen's B4ppctemplate.
Basic4ppc Program Template

Best regards
__________________
Klaus
Switzerland
Reply With Quote
  #3 (permalink)  
Old 05-11-2008, 11:04 AM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 650
Default

Hello Twelve,

maXin has provided a "db2000 - INI" dll in the italian forum (db2000 - INI). A short english translation can be found here in post 6 (Reading config file).

For my own programs I often use just an internal (invisible) table to store the settings/preferences because with this you don't have to code some extra lines for the file handling.

specci48
Reply With Quote
  #4 (permalink)  
Old 05-11-2008, 11:36 AM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Quote:
I save the values of the setting variables in a simple text file when leaving the program. And load this file at startup and set the settings.
This was also my plan.i looked into your code, the way you do this is just plain saving of the values.I thought about something like this here:

COMPort = COM8
Server = "a server"

This is not that hard to program, but it is harder than it appears to be..:-)

Is some advanced string processing because you don't know where the equals are and the parameter name also could contain some spaces.

Quote:
Hello Twelve,

maXin has provided a "db2000 - INI" dll in the italian forum
Thx..i will have a look at this stuff.

Quote:
For my own programs I often use just an internal (invisible) table to store the settings/preferences because with this you don't have to code some extra lines for the file handling.
How does this work if you exit the program, where is the table being stored..?


cheers

TWELVE
Reply With Quote
  #5 (permalink)  
Old 05-11-2008, 04:03 PM
Junior Member
 
Join Date: May 2007
Posts: 37
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi,
Do take note that ""db2000 - INI" dll" is not compatible with the Beta 2.62 if compiled with optimised option enabled.. as it reported an error.. even when running from IDE mode.
Reply With Quote
  #6 (permalink)  
Old 05-11-2008, 04:26 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by TWELVE View Post
This was also my plan.i looked into your code, the way you do this is just plain saving of the values.I thought about something like this here:

COMPort = COM8
Server = "a server"

This is not that hard to program, but it is harder than it appears to be..:-)

Is some advanced string processing because you don't know where the equals are and the parameter name also could contain some spaces.

TWELVE
Since the Format of the parameters are setted BY YOU, then, you can use that to make sure the settings are "Original" and read the important lines and the trimm them so that only the needed info is kept...

Here's an aboandoned project of mine, but in wich, a full basical ini file reading/wtng is implemented...
Attached Files
File Type: zip sample.zip (21.0 KB, 12 views)
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #7 (permalink)  
Old 05-11-2008, 06:06 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 650
Default

Quote:
Originally Posted by TWELVE View Post
How does this work if you exit the program, where is the table being stored..?
Before exiting the program I'll copy every data to be stored into the table. After that I'll just use SaveCSV to export the data to the current folder of the program. As the filename I'll use something like AppPath & "\MyProgram.cfg"


specci48
Reply With Quote
  #8 (permalink)  
Old 05-11-2008, 07:12 PM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Quote:
Originally Posted by Cableguy
Here's an aboandoned project of mine, but in wich, a full basical ini file reading/wtng is implemented...
Thx a lot..i will have a look into your code and see what's usuable for my project..!



Quote:
Originally Posted by specci48
Before exiting the program I'll copy every data to be stored into the table. After that I'll just use SaveCSV to export the data
That's pretty nice and easy at the same time.I didn't take notice of the table.control because i didn't have a use for it.

Since cableguy recommended to use the table.control for prefs file manipulation, this little table thingy appears to be very useful.

The table.control solution is easy and done very quickly, but the resulting cfg file is not the style i was thinking of.

I wrote now a routine, which removes all spaces at the start and end of each line and returns config key and it's value.That's working with an existing file from the windows version of my application, and this was what i was looking for primarily.


Unfortunately now i've got some issues in saving the prefs file.I believed i could just replace a single line within the existing file, but that doesn't work that easy.I opened up a new thread for that, but answers to this were also welcomed here.

cheers

TWELVE

Last edited by TWELVE : 05-11-2008 at 07:15 PM.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
GetFile to save to other DIR tcgoh Questions & Help Needed 9 08-09-2008 06:17 AM
Settings for User's selected 'theme' willisgt Questions & Help Needed 2 02-21-2008 05:06 PM
Port & Baud GPS settings for TytnII colin9876 Questions & Help Needed 9 11-17-2007 11:54 AM
Retreive file associations from Registry mwaite Code Samples & Tips 0 06-13-2007 01:28 AM
Regional Settings: Error loading program. Exception mtse Bug Reports 0 05-24-2007 02:40 AM


All times are GMT. The time now is 01:55 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0