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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile time Defined Constant not acting like a constant.

Status
Not open for further replies.

jpstafford

Technical User
Nov 13, 2000
19
0
0
US
I have a form that is used to display my applications Logo and the last time it was updated/compliled. Thinking that the #Define line of code is only read during Compile time I define a constant 'DATECOMPILED' and then used this constant in a label to display the last time the application was updated. My problem is that the date changes every day instead of staying constant to the date I compiled the application. What am I missing in the following code or doing wrong?

Form ETS_logo.scx
Init Method
Code:
#Define DATECOMPILED DtoC(Date())
Thisform.LblUpdate.Caption="Last Update "+;
		DATECOMPILED+Chr(13)+;
		"Server Build Team"+Chr(13)+;
		"Routing (xxxx) "+Chr(13)+;
		"Att: ETS Application Manager"+Chr(13)+;
		"Phone Ext: 4357 (Help Desk)"
#Undef DATECOMPLILED
 
#define doesn evaluate anything. During the compilation compilator just replace left part of expression with right part. So finaly you have:
Code:
Thisform.LblUpdate.Caption="Last Update "+;
        DtoC(Date())+Chr(13)+;
        "Server Build Team"+Chr(13)+;
        "Routing (xxxx) "+Chr(13)+;
        "Att: ETS Application Manager"+Chr(13)+;
        "Phone Ext: 4357 (Help Desk)"

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Untested, but perhaps this would work for you?
Code:
cDate = DTOC(DATE())
#DEFINE DATECOMPILED cDate
Regards,
Jim
 
Nope :) It wouldn't works also because you'll get:
Code:
Thisform.LblUpdate.Caption="Last Update "+;
        cDate+Chr(13)+;
        "Server Build Team"+Chr(13)+;
        "Routing (xxxx) "+Chr(13)+;
        "Att: ETS Application Manager"+Chr(13)+;
        "Phone Ext: 4357 (Help Desk)"

and cDate is always curent date :)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Thanks Jim and Borislav but I am looking for a way to display the Compile Date automatically and not have it change until I compile the application again. All the above dates are alway the current date. If someone has an example of what they have done to accomplish this task, please show me? ...John Stafford
 
Great Suggestion DSummZZZ, this works as advertised.
The following Code is how I accomplished this task:
Code:
Local ldircount
m.lDircount=Adir(cDir,"EQUIP.APP")
If m.lDircount>0
	Thisform.LblUpdate.Caption="Last Update "+;
				DtoC(cDir[1,3])+Chr(13)+;
				"Server Build Team"+Chr(13)+;
				"Routing (xxx) "+Chr(13)+;
				"Att: ETS Application Manager"+Chr(13)+;
				"Phone Ext: 4357 (Help Desk)"
Else  &&Don't show the Compiling Date
	Thisform.LblUpdate.Caption="Server Build Team"+Chr(13)+;
				"Routing (xxx) "+Chr(13)+;
				"Att: ETS Application Manager"+Chr(13)+;
				"Phone Ext: 4357 (Help Desk)"
Endif
Release cDir
 
?
Mike which element is compile date?
That was my first thought but when I checked HELP there is no compile date in elements of returned array. Or you mean "in addition"?

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Code:
DtoC(FDate(Sys(16,0),1))

or

Code:
TtoC(FDate(Sys(16,0),2))

might be the easiest way to go.

But then there is the way an unzip or file manipulation might change that file date. So best way to have it stored inside the exe might be using the projecthook class.

I'd define a property of the application class holding the last build date, setting that in the projecthook.BeforeBuild() method.

After the build the project also holds the last build date in _vfp.ActiveProject.BuildDateTime, but that won't help much.

By, Olaf.
 
Or store in a file in the exe.

Brian

Code:
CLOSE ALL

SET TEXTMERGE ON 
SET TEXTMERGE TO TEST_DT_VERSION.PRG
\PUBLIC form1
\form1= CREATEOBJECT("form1")
\form1.Show
\READ EVENTS 
\RETURN
\
\DEFINE CLASS form1 AS form
\    ADD OBJECT label1 AS Label WITH ;
\    	name="label1", ;
\    	visible =.t., ;
\    	width = 400, ;
\    	height = 20
\  ADD OBJECT command1 AS commandbutton WITH ;
\       Caption = [Quit] ,;
\       left = 10,;
\       top = 50
\	PROCEDURE Init
\		thisform.label1.caption=FILETOSTR("compile.info")
\		thisform.Visible=.t.
\		DOEVENTS
\
\    PROCEDURE command1.Click
\    	thisform.release 
\    
\    PROCEDURE QueryUnload
\   	thisform.Release 
\	PROCEDURE Release
\		QUIT 
\		ON SHUTDOWN
\		CLEAR EVENTS
\	ENDPROC 
\ENDDEFINE

SET TEXTMERGE TO TEST_DT_EXE.prg
\BUILD PROJECT TEST_DT_VERSION from TEST_DT_VERSION
\MODIFY PROJECT TEST_DT_VERSION nowait 
\STRTOFILE("resource=off"+CHR(13)+CHR(10),"config.fpw")
\_vfp.ActiveProject.Files.Add("config.fpw")
\STRTOFILE(TTOC(DATETIME()),"compile.info")
\_vfp.ActiveProject.Files.Add("config.fpw")
\_vfp.ActiveProject.Files.Add("compile.info")
\_vfp.ActiveProject.Close
\BUILD EXE TEST_DT_VERSION FROM TEST_DT_VERSION
\ERASE "config.fpw"
\ERASE "compile.info"
SET TEXTMERGE TO
SET TEXTMERGE OFF

DO TEST_DT_EXE
MESSAGEBOX("Try TEST_DT_VERSION.EXE",0,"Thank you",2500)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top