Type Identifyer not allowed ??? lazarus / 21-General ---------------------------------------------------------------------- J-G · 2024-02-03 18:00 It's quite some time since I did any programming - so much so that I can't recall the last time that I viewed this forum (which I used to do religiously every day  Some time ago (2017!) I was helped immensely by a number of contributors here when I wrote a 'Transparent' Clock including a Calendar - I even contributed to the developement of CalLite at the time! The program has been working (is STILL working) perfectly on a number of my customers' PCs where it is considered useful but I now have a new customer who has two monitors and I'd like to be able to [Save] the location of the clock to be recalled the next time the PC is swiched on. I'll leave the detail about that 'til later but I have an associated small problem which doesn't make any sense (to me).  The position of the hands is calculated using this code : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure Calc_Hand_Angles;begin  Alpha := 30 * ((Time_Now.H Mod 12) + Time_Now.M/60 + Time_Now.S/3600);  Beta  := 6 * (Time_Now.M + Time_Now.S/60);  Gamma := 6 * (Time_Now.S);  Delta := Alpha + (Bias*30);   H_Hand :=  Time_Now.H;   Bias_AM := (H_Hand + Bias) < 13;   If Time_Now.M > 29 then    inc(H_Hand);   if H_Hand > 24 Then  H_Hand := 0;end;  . . .  and the previous compilation (naturally) worked faultlessly. None of this code has been changed but initially the reported error was clock_b.pas(629,19) Error: Identifier not found "Time_Now" Now,  I have not 'deleted' a type ie. "Time_Now"  so couldn't fathom why this error appeared. Notwithstanding that, I then added the 'Type' Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Type   Time_Now = Record                 H,M,S : Byte;               end; . . . anticipating that would solve the issue - - -    No - - - -  I now get the error : clock_b.pas(629,28) Error: type identifier not allowed here I've added some code in readiness for the saving & reading of a Location file but nothing to this procedure.  I've also updated  a couple of packages (CalLite & BGRABitmap) since I hadn't used those since updating to Laz 2.2. I'd be grateful for any pointers as to why the .H identifier (or .M & .S) is not allowed or more specifically why 'Time_Now' is no longer valid. ---------------------------------------------------------------------- bytebites · 2024-02-03 18:13 Variable expected, not type. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure Calc_Hand_Angles;var Time_Now : Record                 H,M,S : Byte;             end;begin ---------------------------------------------------------------------- J-G · 2024-02-03 18:38 D'oh!  -  If I had a brain, I might become dangerous         Thanks ByteBites In my defence, I haven't looked at Pascal code for the past couple of years  It's solved some of the problem but there will be more questions I'm sure. To continue the question about the real issue - -  ie. Why I need to make changes - -  I can easily [save] the location to a simple file when the program is terminated; but that will sedom be the case.  It is started when the PC is switched on (short-cut in 'StartUp') and would not normally ever be closed - though there is an option to do so.  The display can be moved about the screen at will, since even though it is [Transparent], there are times when parts might obscure a small Windows 'Button' in third party programs. What I would like to be able to do is [Save] the location whenever it is manually moved but I don't see an 'Event'   [OnMove]   or anything else that I think might be useful. I can of course set a timer event so that the routine to save the location is triggered every 5 minutes (say) but that seems extraordinarily inefficient - I know it might only take milliseconds, but is quite inellegant. Can anyone point me to a means of knowing that the location has been changed . . . . . . Hmmm. . . .  I suppose I could compare the 'Top' each time I update the time and if not what it was the last time checked, THEN the [Save] could be triggered  . . . . . . ---------------------------------------------------------------------- J-G · 2024-02-03 18:58 EUREKA! Again a self-inflicted problem due to 'the passage of time'  I have a [Unit] to deal with Time related procedures and for some reason I seem to have had a 'tidy up' of that some time after I last needed to tweek the Clock Program. Part of that 'Tidy' was the removal of the Underscore between Time & Now so naturally [Time_Now] is not equal to [TimeNow]  This came to light when the next 'error' appeared which was due to a call to 'Format_Time' which again naturally didn't exist for the same reason - - -  but  being a function that I know existed, was easier to find than a 'variable'. ---------------------------------------------------------------------- KodeZwerg · 2024-02-03 19:22 I do not know your source but within pascal it is all about scopes (visibility of definitions/structures/types/variables etc inside methods) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure foo;var  bar: Integer; // bar has the scope of "foo"begin  bar := 123;end; // here is bar not reachable anymore procedure foobar;begin  bar := 456; // error, bar is unknownend; ...and saving a position i prefer to use the OnClose event. ---------------------------------------------------------------------- J-G · 2024-02-03 19:36 Thanks for your input KodeZwerg, yes the 'OnClose' may well do the job. Naturally I'm reviewing the code (I am aware of the 'scope' - I just didn't have my brain in gear  ) and I've now found the procedure that handles the relocation of the image. I was thinking that 'Windows' handled that but in this case it's part of the BGRA package so I DO have total control and have now implimented the save only when the 'Move' routine is called. Haven't fully tested with a PC close down yet but that's on the cards for the next test. ---------------------------------------------------------------------- J-G · 2024-02-03 19:51 I now have a suplimentary question - - - -  I updated the CalLite package and it seems that some functionality has been removed  There used to be four buttons that allowed the user to jump foreword or backward a month or a year but they no longer feature. Am I missing a setting or do I now have to create my own buttons? Further - it used to show the Month & Short Day-names which are both also missing. ---------------------------------------------------------------------- KodeZwerg · 2024-02-03 19:57 Quote from: J-G on February 03, 2024, 08:36:21 pmI DO have total control and have now implimented the save only when the 'Move' routine is called.In my humble opinion that is one of the worst places I would put a "save position to disk" place but as long you are happy, I be too ---------------------------------------------------------------------- J-G · 2024-02-03 20:26 I've now found the [Option] to show day names in CalLite but cannot see a switch for the Month - and the consequent Foreward/Backward buttons. Found it  -  Option is coShowTopRow  -  it's a great package but understanding the thought process of A.N.Other programmer is sometimes a challenge ---------------------------------------------------------------------- J-G · 2024-02-04 12:01 Quote from: KodeZwerg on February 03, 2024, 08:57:43 pmQuote from: J-G on February 03, 2024, 08:36:21 pmI DO have total control and have now implimented the save only when the 'Move' routine is called.In my humble opinion that is one of the worst places I would put a "save position to disk" place but as long you are happy, I be too  I've now fully tested the program (after a total close down - which I do very infrequently) and the location save and retrieve works as anticipated, but I'd be interested as to your reservations - or it seems rather more than 'reservations'. ---------------------------------------------------------------------- KodeZwerg · 2024-02-04 13:17 Quote from: J-G on February 04, 2024, 01:01:55 pmQuote from: KodeZwerg on February 03, 2024, 08:57:43 pmQuote from: J-G on February 03, 2024, 08:36:21 pmI DO have total control and have now implimented the save only when the 'Move' routine is called.In my humble opinion that is one of the worst places I would put a "save position to disk" place but as long you are happy, I be too  I've now fully tested the program (after a total close down - which I do very infrequently) and the location save and retrieve works as anticipated, but I'd be interested as to your reservations - or it seems rather more than 'reservations'. Because I still was not able do have a look on your source I do assume you are meaning some OnMove event. Based on that assumption, OnMove will trigger and trigger and trigger while you move the form (or some kind of object in your particular case) while the OnClose event is just fired once, when you close your application / widget ... So what is more efficient, continues open write close a file while you drag or just do that action just once in the right spot? I hope I could enlighten you my worries a little but also I could be total wrong because of lack about your actual code. At least I did expained why I do think that OnMove is the absolute wrong place to save location data. Have a wonderful sunday! ---------------------------------------------------------------------- J-G · 2024-02-05 11:47 Quote from: KodeZwerg on February 04, 2024, 02:17:54 pmBecause I still was not able do have a look on your source I do assume you are meaning some OnMove event. Based on that assumption, OnMove will trigger and trigger and trigger while you move the form (or some kind of object in your particular case) while the OnClose event is just fired once, when you close your application / widget ... So what is more efficient, continues open write close a file while you drag or just do that action just once in the right spot? I hope I could enlighten you my worries a little but also I could be total wrong because of lack about your actual code. At least I did expained why I do think that OnMove is the absolute wrong place to save location data. Have a wonderful sunday! Thanks for your concern and explanation. I do appreciate your point about the OnMove event and I am, of course, guilty of  providing limited (and probably misleading) information. Here is the specific code which handles the 'Move' - or better still 'Drag' : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TScaleClock.BGRAGraphicControl1MouseDown(Sender: TObject;   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);       // Left  Click = Drag                                                                                              // Right Click = TimeZonebegin                                                             if Button = mbLeft then    begin      ReleaseCapture;      SendMessage(ScaleClock.Handle, LM_SYSCOMMAND, 61458, 0);    end  else    begin      ScaleClock.ZoneList.Visible := true;    end;  SaveLocation;end;  Because I was 'gifted' some of this code I cannot be sure that your argument is equally valid but hope that the 'SaveLocation' is not executed until such time as the 'Move' or 'Drag' has completed by the Left Mouse Button being released. The difficulty with the OnClose Event is that it would seldom, if ever, be performed since the Clock normally requires on interaction by the user. It would, I assume, be executed during the Windows 'clean up during a normal PC close down' but this again may seldom happen. ---------------------------------------------------------------------- KodeZwerg · 2024-02-05 12:07 Based on what I see, create a OnMouseUp event and put there the SaveLocation into, the save operation is done anyway just once but the Up is my opinion the more better choice To make your source a little better readable/understandable, here is the number as a const: Quote from: J-G on February 05, 2024, 12:47:34 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TScaleClock.BGRAGraphicControl1MouseDown(Sender: TObject;   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);       // Left  Click = Drag                                                                                              // Right Click = TimeZoneconst   SC_MOVE = 61456;   HTCAPTION = 2;   SC_DRAG = SC_MOVE + HTCAPTION;begin                                                             if Button = mbLeft then    begin      ReleaseCapture;      SendMessage(ScaleClock.Handle, LM_SYSCOMMAND, SC_DRAG, 0);    end  else    begin      ScaleClock.ZoneList.Visible := true;    end;  SaveLocation;end; //edit Ps: The reason why Up is the better choice: In the Down event you have X/Y from the time you pressed mousebutton, ie the old position. In the Up event you have the X/Y from when you stopped pressing button. ---------------------------------------------------------------------- J-G · 2024-02-05 12:57 Hmmmm..... I'm not sure that your [Edit] is relevant. It may well be that the Mouse X/Y figures at the time of the MouseDown event are historic but (again I haven't shown you all the code!) in the SaveLocation Proc. I don't use the Mouse XY but the Top & Left of the BGRAGraphicControl which of course at that time is the new position. Thanks also for the further explanation of the origin of the number 61458  -  I don't fully understand - nor could I derive the numbers from first principles, since I have not needed to study 'LM_SYSCOMMAND'   -  but do now have a marginally better appreciation of what's going on. You are welcome to a full copy of the scource if you might find it interesting ---------------------------------------------------------------------- KodeZwerg · 2024-02-05 13:32 Quote from: J-G on February 05, 2024, 01:57:25 pmI'm not sure that your [Edit] is relevant. It may well be that the Mouse X/Y figures at the time of the MouseDown event are historic but (again I haven't shown you all the code!) in the SaveLocation Proc. I don't use the Mouse XY but the Top & Left of the BGRAGraphicControl which of course at that time is the new position.It is just luck that before the actual Save happen you execute a blocking operation. You can easily find out on your own by placing the SaveLocation as first command and not as last. (Thats why I prefer an event where is no doubt about such) That Self.Left/Self.Top is used when saving is of course the right way to do! Quote from: J-G on February 05, 2024, 01:57:25 pmThanks also for the further explanation of the origin of the number 61458  -  I don't fully understand - nor could I derive the numbers from first principles, since I have not needed to study 'LM_SYSCOMMAND'   -  but do now have a marginally better appreciation of what's going on.You are welcomed - and it is not about WM_SYSCOMMAND, its a sub feature that you access over it Quote from: J-G on February 05, 2024, 01:57:25 pmYou are welcome to a full copy of the scource if you might find it interesting  Sure, last time I did a graphical multi-purpose (segment style) Watch is long ago and had features that I needed at that point. - first of all show current time & date lol - hour format per option 24h or am/pm based - calendar with reminder - stopwatch Lets see what yours can do ---------------------------------------------------------------------- J-G · 2024-02-05 14:36 Quote from: KodeZwerg on February 05, 2024, 02:32:49 pmQuote from: J-G on February 05, 2024, 01:57:25 pmYou are welcome to a full copy of the scource if you might find it interesting  Sure, last time I did a graphical multi-purpose (segment style) Watch is long ago and had features that I needed at that point. - first of all show current time & date lol - hour format per option 24h or am/pm based - calendar with reminder - stopwatch Lets see what yours can do  'Features that are needed at that point' is why programs occasionally need 'tweeking'  The main 'feature' that I was attempting (succeded) is 'Transparency' which I had been told was impossible. But multi Time Zone (inc. language), Analog & Digital were also important, as you'll see when you view the PM I've sent you. I've used a unique method to get around the Analog 12/24 hour issue  -  the dial has hour dots following an involute curve with the hour hand growing & shrinking accordingly.