Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Dec 11, 2019 4:51 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Newby question on registry
PostPosted: Wed Dec 30, 2009 10:16 pm 
Offline

Joined: Mon Oct 02, 2006 7:19 pm
Posts: 40
I am having trouble learning how to create registry entries. I want to store the location of the database for my app. I use Preferences on the Mac and I assume the registry is the right place for Windows. Any demos out there?

I already checked out the documentation and the Examples that download with RB. No help so far.

Thanks.

Bill


Top
 Profile  
Reply with quote  
 Post subject: Re: Newby question on registry
PostPosted: Thu Dec 31, 2009 12:14 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
If you want a cross-platform solution.... I have a RealBasic Class that emulates the Windows INI style of storing Preferences.... It works on Mac and OSX both...



http://www.rdsisemore.com/classini_file.rbo


and best of all.. Its FREE :)

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Newby question on registry
PostPosted: Thu Dec 31, 2009 3:20 am 
Offline

Joined: Mon Oct 02, 2006 7:19 pm
Posts: 40
Thanks for the class. Do you have a demo somewhere of how to use it? Thanks for your help.

Bill


Top
 Profile  
Reply with quote  
 Post subject: Re: Newby question on registry
PostPosted: Thu Dec 31, 2009 9:19 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Is really easy.....

First define a GLOBAL variable in a MODULE .. INI_FILE AS classINIFILE

I then usually create 3 methods

First define all the DEFAULT values, in case the INI file is not there, or you have added new options, or
the user manually changed the file. "option_variable" can be INTEGER, SINGLE, BOOLEAN, COLOR, STRING types
Sub OPTIONS_DEFAULT
option_variable=<some default value>
// as many more as you need
END SUB


This is called at the beginning of you APP... usually in APP.OPEN
SUB LOAD OPTIONS
INI_File=new classINI_FILE(Get_Folder_Root.child("Config.INI"))
INI_File.Load

option_varaible=INI_FILE.GET("section","key",option_variable)
// as many more as you need
END SUB


Finally to Save Options... usually called in APP.CLOSE or your main WINDOW close
SUB SAVE_OPTIONS
INI_FILE.PUT("section","key",option_variable)
INI_File.Save
END SUB


"section" and "key" are just like in a WINDOWS INI file.... and you can have as many as you need to

Look at the class code.. there are a two other METHODS there as well

INI_FILE.REMOVE_SECTION("section") - will remove all keys in that section

INI_FILE.REMOVE("section","key") - will remove a single key in a section

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Newby question on registry
PostPosted: Mon Aug 16, 2010 5:41 pm 
Offline
User avatar

Joined: Thu Mar 01, 2007 2:02 pm
Posts: 237
Location: Sunny (generally!) Southern California
Dave,

I just looked at the rbo file and there seems to be one problem (other than a few deprecated functions). You have the following line

section=Slash_Add_Trailing(Trim(Uppercase(Section)))


without the function code or a description of what it should do. I would be interested in this info.

Thanks,
- Dale

_________________
-----
Real Studio 2012r1 on Windows 7 (64 bit)
-----
It has been said that politics is the second oldest profession.
I have learned that it bears a striking resemblance to the first.
- Ronald Reagan


Top
 Profile  
Reply with quote  
 Post subject: Re: Newby question on registry
PostPosted: Mon Aug 16, 2010 7:11 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
:) yeah I keep forgetting that is in a public area of most of my programs....
but it is a REALLY complex function too..... [just kidding]

[code]
FUNCTION Slash_Add_Trailing(s as string) as string
if right(s,1)<>"/" then s=s+"/"
return s
END FUNCTION
[/code[

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Newby question on registry
PostPosted: Fri Aug 27, 2010 3:26 am 
Offline

Joined: Thu Mar 16, 2006 4:38 am
Posts: 37
Location: A far flung corner of the planet
In the Load_Options, what is the "Get_Folder_Root.child" trying to do? The reason I ask is that I have entered your methods above and get an error here saying "This method or property do not exist".


Top
 Profile  
Reply with quote  
 Post subject: Re: Newby question on registry
PostPosted: Fri Aug 27, 2010 7:54 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
The code posted above in this topic is just an EXAMPLE of how to use the INI class....

Those particular functions are not IN the class itself.

INI_File=new classINI_FILE(<you supply a folderitem object here>)

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Newby question on registry
PostPosted: Sat Aug 28, 2010 5:08 am 
Offline

Joined: Thu Nov 09, 2006 2:41 pm
Posts: 90
I prefer to use a small REALSQLdatabase to store a program's data. I typically store the position and size of windows, paths to other information needed (such as other databases), user names, passwords, etc. The database can be encrypted to keep passwords more secure, if necessary. This database is kept in the same folder as the program, which makes it easier for a user to move it elsewhere by copying (or deleting) everything in that folder. Not using the Windows registry also makes it cross-platform (I develop for Windows and Linux) and in any case the registry is a mess which, rumour has it, may disappear in Win 8 anyway. Personally, I avoid it like the plague.


Top
 Profile  
Reply with quote  
 Post subject: Re: Newby question on registry
PostPosted: Tue Nov 30, 2010 5:28 pm 
Offline

Joined: Sun Nov 18, 2007 11:19 am
Posts: 140
Location: New Brunswick, Canada
Thanks for this code! Exactly what i was looking for to make my app a little more portable.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group