Forum > General

Incorrect Proc being called ???

<< < (2/10) > >>

J-G:

--- Quote from: dseligo on September 23, 2022, 09:03:06 pm ---One thing I usually do when something strange as this is going on, is to do project 'Clean up and Build' (but I must admit that doesn't help in most cases, because the reason is my error somewhere in the project).

You mention you changed from static to dynamic arrays.
But your code is like this:

--- 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";}};} ---for i := 1 to MaxERec do
Dynamic arrays goes from 0 to array length - 1. Check if you didn't make some error with array indexing.

And I usually use CloseFile instead of Close.

--- End quote ---
I haven't yet tried a 'Clean up and Build'  -  It's taken me all this time to recover from the silly error that you pointed out :-[  @dseligo

I HAD taken account of the fact that dynamic arrays are Zero based EXCEPT when it came to the [Save] section !!  D'oh!   -  I've had to 'knife and fork' my code to recover the data (I did lose a couple of records but I have a separate note of those so can re-enter the info).

It occured to me that the 'shift' in the array addressing might have been responsible for the incorrect calling (possibly due to some memory being over-written)  but now I'm back to the position where the 'Electric' Array needs to be saved I find that it is still calling the 'Gas' save proc.

I've never needed to do anything other than use [F9] to compile & run a project and looking at the options under [Run] I'm still a little unsure about my next test. Should it be [Run][Clean up and Build],  [Ctrl][F9]  or [Shift][F9]  -  that may sound naïve but I'm being ultra cautious  :)

wp:

--- Quote from: J-G on September 24, 2022, 12:55:07 pm ---I've never needed to do anything other than use [F9] to compile & run a project and looking at the options under [Run] I'm still a little unsure about my next test. Should it be [Run][Clean up and Build],  [Ctrl][F9]  or [Shift][F9]  -  that may sound naïve but I'm being ultra cautious  :)

--- End quote ---

I normally I use [F9]. When I change something and it seems that the compiler did not notice it (for example, when I only change a property in the OI, or when I change an included resource) --> [Shift][F9] (Build)

I rarely use the others (sometimes [Clean up and Build] mainly out of dispair...).

MarkMLl:

--- Quote from: wp on September 24, 2022, 01:09:07 pm ---I normally I use [F9]. When I change something and it seems that the compiler did not notice it (for example, when I only change a property in the OI, or when I change an included resource) --> [Shift][F9] (Build)

I rarely use the others (sometimes [Clean up and Build] mainly out of dispair...).

--- End quote ---

There are definitely poorly-understood situations where one needs to do a File -> Clean Directory... (and accept the defaults) before a Compile or even a Build. When this has been discussed in the past it's been hypothesised to be related to unit names with a relative path.

https://forum.lazarus.freepascal.org/index.php/topic,59512.msg444219.html#msg444219 https://forum.lazarus.freepascal.org/index.php/topic,53028.0.html plus a few other places. Seems to need a "nuke from space" to fix.

MarkMLl

J-G:
After some further testing - - - -   Still no 'joy'  :(

I opened the project in Laz 1.6 and again (naturally) walked through the code and it correctly called the SaveElec proc. - rather than continuing with the [save], which would have destroyed the means of testing further, I aborted the run and re-opened in Laz 2.2.  This told me that a change had occured  -  probably due to a time stamp rather than an edit  -  and I allowed a re-open (clutching at straws!)  -  Stepping through again the call from SaveElec still goes to Save Gas  %)

Next test was    [Shift][F9]  -  [F9]  -  no change

Next     [Run][Clean up and Build]  - [F9]  -  no change

 ::)  ::)

Now I can complete the conversion to Dynamic Arrays under Laz 1.6 because this part of the code normally only [Reads] the data (I've added the call to [Save] simply for the conversion) - the [Writing] part is normally there only for a first run, to create the data files -  but naturally I'm somewhat reluctant to trust that there won't be some issue still lurking.

The problem does seem to be connected with something in Laz 2.2 but I cannot hazzard a guess as to where.

J-G:
Curiouser and Curiouser !!

The section of code which I'm updating is concerned with reading the data but naturally I also need to [Edit] the data as and when rates change. This means that I also have a [Save button] which has an 'Event' attached and this simlpy calls the approriate [Save] proc.

Changing the update code to call this 'Event' does work (though I did have to fathom what TObject needed to be sent  ???  -  Self & Sender failed but Form1 was acceptable,  why ?  I have no idea :) )  but the call then again goes to SaveGas !!  ???   %)

If I put the [Save] code directly in the [Save button] 'Event' the ElecFile IS saved!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version