SM> static TMyApp* theApp = 0;
Why do you need this? Get rid of it. ;-)
SM> struct TimeStruct {
SM> TimeStruct();
SM> char day[3];
SM> char month[3];
SM> char year[5];
SM> char hour[3];
SM> char min[3];
SM> char sec[3];
SM> };
Each part of your struct is a string, right?
SM> class TMyApp : public TApplication {
SM> public:
SM> TMyApp();
SM> TMyApp* App;
This pointer is useless - toast it, too.
All of your references to "theApp" or "App" should be "this". Anyone outside
of the class should be able to use their own pointer to your class.
SM> TimeStruct TimeDate;
This is internal data - make it private. ;-)
SM> protected:
SM> TMyApp* GetAppPtr(){return theApp;}
Not needed whatsoever.
SM> };
SM> void TMyApp::CmTiming()
CmTiming is not a member function of TMyApp. (There should be a definition
of this within the TMyApp class braces as there is[was] for GetAppPtr.)
SM> {
SM> SprTimingEditor(GetMainWindow(), DIALOG_1, TimeDate,
SM> GetAppPtr()).Execute();
SM> }
GetAppPtr() will (once CmTiming is a member function) be able to use "this"
instead of "GetAppPtr()".
Warning: this creates a SprTimingEditor object on your stack. When this
function terminates, the object goes out of scope and is destroyed. Either
the SprTimingEditor must be a member variable, or created on the heap to
ensure it has a lifetime longer than this function call.
SM> void
SM> SprTimingEditor::SetTime()
SM> {
SM> while (continueTime == 1)
SM> {
SM> TTime* TimePtr = new TTime();
SM> ******* theApp->TimeDate.sec = (int)TimePtr-
>Second();*** LValue needed ****
SprTimingEditor was passed a TMyApp* - save it and use it instead of theApp.
Better yet, it was also passed a TimeDate&, save THAT and use it. Further,
TimeDate.sec is not an LValue because it is an array. You need to strcpy
(or, in this case, sprintf) into its data space:
sprintf(theApp->TimeDate.sec, "%02d", (int)TimePtr->Second());
(Object Oriented: Use stringstream to generate the string. More OO: Use
string instead of char arrays.)
SM> TransferData(tdSetData);
SM> delete TimePtr; //I think this deletes the TTime object
Yup. You might be better off creating the TTime on the stack:
TTime currentTime;
sprintf(...);
TransferData(tdSetData);
// no need to delete now.
SM> }
SM> }
Hope this helps, Steve!
[Warning: I've never programmed OWL - so I'm assuming your other function
calls exist and will work the way you call 'em :-)]
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|