Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An OnChange for an AnsiString?

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
I know this may be a stupid question but I figured it might save me a few dozen if statements if I could get it. I've got this global String that I'd love to get a function every time it changed, but I don't recall hearing of anything like that. May be stupid, I know, but as it stands it's early in the morning for me and I haven't had my coffee yet, so I can write it off if I get burned on this one. Thanks guys!

Cyprus
 
How does the String get changed? Is it coming from an EditBox or something similar? If so, use the EditBox's OnChange method.



James P. Cottingham
[sup]
There's no place like 127.0.0.1.
There's no place like 127.0.0.1.
[/sup]
 
naw, just a regular variable... String MyStringName;
The thing is there are multiple threads that can change it so in every one I have to do a case or a few IFs to determine if the string's been changed. I figured it would just be easier to make a function for the string that fired when it changed. Im so rusty at BCB that I can't remember char* from void AnsiString...

Cyprus
 
I know a way for doing that, but I didn't like it very much.

What you should do, is to add an EditBox and set it's property visible to false, then you must to use the Text property and it's OnChange event.

--- LastCyborg ---
 
I agree with lastcyborg and 2ffat, its the easist way to go.
Just set visiable to false if your worried about it showing.

Ruggie
 
aww but that's so sloppy! I'd rather just write a good half dozen if's. Thanks anyways guys

Cyprus
 
Why not use a global object?
It will centerlize managing all global vairables.
All model only use getXXX and setXXX to get or set variable's value.
So I think the setXXX method is what u want an OnChange event.

WENG YAN
 
dear wengyan,

could You explain that with the global object a little more?

I have (in my ABSOLUTELY SLOPPY program
(which I still like ;) ) ) problems with global declarations or availability of global defined objects. what I did around is writing setxy() and deletexy() methods in the form-source, where the variable is located and needed.
These I can call from anywhere to set the flag true or false.

plus I get linker warnings of multiple declarations, just because of my tries to define something globally.

Would You put a global object/variable into the main.h file?
with an "extern" in front?
(Sorry , I did not get that far with cpp programming...)


best regards,

Michael

... Welladay! Welladay!
For the winds of May!
Love is unhappy when love is away!
-excerpt,see my profile- James Joyce,1907
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top