C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 20th, 2003, 11:09 AM
AGibel's Avatar
AGibel AGibel is offline
Bad Andy
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: OH
Posts: 275 AGibel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 55 sec
Reputation Power: 10
BCB 6 global variables

BCB has alot of event handlers when you get into bigger programs. There are many values which I need to use throughout all of them. I need to find out where you can globalize variables. In the header? You can declare them there but cannot set a value. Any help would be appreciated. Thanks

Reply With Quote
  #2  
Old June 20th, 2003, 01:54 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,172 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 29
Once solution using a header file was discussed a few days ago:
http://forums.devshed.com/showthread.php?threadid=64656

Another solution that can work in BCB is to use a DataModule. The original concept behind a data module was to put all of your connection controls, client datasets, etc. into a global class that could be accessed by all the forms. Since there is only one copy of this object created at program start, it can also be used to store global values. For example in my program under Project->Option->Forms, I Auto-Create my main MDI form and my DataModule. I store constants at the top of the .h file. I store global variables as public properties of the class. I also have some global functions which are methods of the class. Any initialization can be done in the DataModule constuctor. Then from my code I can call them like:

UserName->Text = GlobalDM->UserName;

Or I can have a central error logging routine I can call from any form:

GlobalDM->ProcessError(ErrType, ErrNbr, ErrDescription, FormName, FormRoutine);

I don't know if one method is better than the other. They have both worked for me.

Last edited by dcaillouet : June 20th, 2003 at 01:56 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > BCB 6 global variables

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap