Forum > Beginners
[SOLVED] dependency initialization problem
ndrx:
Hello,
I have a problem with the initialization of a variable in a constructor of a class.
The variable is a TDateTime and I want to initialize it with value Now (from unit DateUtils) but it is not possible, the compiler is complaining :'( :
Error: Identifier not found "now"
I know it's a basic problem but I already searched for information on the web and I don't find anything.
Thank you for your help.
tudi_x:
hi,
if you could share some code.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Form1.Caption:= FormatDateTime('hh',now);
works for me.
balazsszekely:
@ndrx
Add sysutils to the uses clauses.
ndrx:
@tudi_x
here is my code :
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit myunit;{$mode objfpc} {$codepage UTF8} interface uses Classes, dateutils, sysutils; var INITIAL_DATE : TDateTime; type Test1 = class private time : Int64; public constructor create();end; implementation constructor Test1.create(); begin time = MilliSecondsBetween(INITIAL_DATE, now); end; initializationbegin INITIAL_DATE := scanDateTime('DDMMYYYY', '01011900');end; end.
@GetMem
I added sysutils but I have the same problem.
balazsszekely:
No! You don't have the same problem. Before sysutils the error was: "Identifier not found: now". After you add sysutils the error is "Illegal expression". You need ":=" instead of "=".
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---constructor Test1.create();begin time := MilliSecondsBetween(INITIAL_DATE, now);end;
Navigation
[0] Message Index
[#] Next page