Recent

Author Topic: [SOLVED] Loop Thru Components Setting Visibility And Enableability  (Read 13619 times)

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
[SOLVED] Loop Thru Components Setting Visibility And Enableability
« on: September 09, 2017, 01:28:49 am »
During FormCreate, I want to loop thru all components and enable/disable their visibility & enableability :D based upon parameters and tags. If tag = 22 then it is a private component. If tag = 11 it is a test component. Components with tags 11 or 22 are not of one single type.

This is what I have so far, without success (vPrivate & vTest are true if respective parameter is present):
 
Code: Pascal  [Select][+][-]
  1.  for I:=0 to ComponentCount-1 do
  2.   if Components[I].Tag=22 then
  3.     begin
  4.       FindComponent(Components[I].Name)).Visible:=vPrivate;
  5.       Components[I].Enabled:=vPrivate;
  6.     end
  7.   else if Components[I].Tag=11 then
  8.     begin
  9.       Components[I].Visible:=vTest;
  10.       Components[I].Enabled:=vTest;
  11.     end;
  12.  

TIA

Bazza
« Last Edit: September 13, 2017, 08:22:55 am by Bazzao »
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

ASerge

  • Hero Member
  • *****
  • Posts: 2475
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #1 on: September 09, 2017, 01:50:22 am »
Code: Pascal  [Select][+][-]
  1. procedure SetVisibleByTags(Parent: TWinControl; Visible: Boolean; const Tags: TIntegerSet);
  2. var
  3.   C: TControl;
  4. begin
  5.   for C in Parent.GetEnumeratorControls do
  6.     if C is TWinControl then
  7.       SetVisibleByTags(TWinControl(C), Visible, Tags)
  8.     else
  9.       if Integer(C.Tag) in Tags then
  10.         C.Visible := Visible;
  11.   if Integer(Parent.Tag) in Tags then
  12.     Parent.Visible := Visible;
  13. end;
  14.  
  15. procedure TForm1.FormCreate(Sender: TObject);
  16. begin
  17.   SetVisibleByTags(Self, False, [11, 22]);
  18. end;

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #2 on: September 09, 2017, 03:02:58 am »
Many thanks ASerge.

I had to remove the set and test for the separate private and test values (2 different parameters, 2 different results) .

Showmessage boxes shows me the flow (I'll remove them when code is good):

Code: Pascal  [Select][+][-]
  1.     if C is TWinControl then
  2.       begin
  3.         Showmessage(C.Name);
  4.         SetVisibleByTags(TWinControl(C),pPrivate,pTest);
  5.       end
  6.  

It appears Menu items (there are 2 popup menus) are not catered for, as the Names do not appear in the Showmessage.

I assume the modification will be to
Quote
if C is TWinControl
and
Quote
Parent:TWinControl

But I am unsure how to test it.

What modification do I need for menu items to be included in the search?

Thanks

B
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #3 on: September 09, 2017, 03:33:55 am »
he is using the method GetEnumeratorControls which uses the Controls property instead of the components. The controls property contains only the controls that have their parent set to the form. You are looking for the controls that have their owner set to the form so remove the method name completely and change the type of C to TComponent. eg
Code: Pascal  [Select][+][-]
  1. procedure SetVisibleByTags(Parent: TWinControl; Visible: Boolean; const Tags: TIntegerSet);
  2. var
  3.   C: TComponent;              //<---- type changed
  4. begin
  5.   for C in Parent do            //<---- Enumerator Changed
  6.     if C is TWinControl then
  7.       SetVisibleByTags(TWinControl(C), Visible, Tags)
  8.     else
  9.       if Integer(C.Tag) in Tags then
  10.         C.Visible := Visible;
  11.   if Integer(Parent.Tag) in Tags then
  12.     Parent.Visible := Visible;
  13. end;
and ofcourse since this is no longer a matter of parenthood remove the recursive call as well it will only bring problems. eg
Code: Pascal  [Select][+][-]
  1. procedure SetVisibleByTags(Parent: TWinControl; Visible: Boolean; const Tags: TIntegerSet);
  2. var
  3.   C: TComponent;              //<---- type changed
  4. begin
  5.   for C in Parent do            //<---- Enumerator Changed
  6. //    if C is TWinControl then
  7. //      SetVisibleByTags(TWinControl(C), Visible, Tags)
  8. //    else
  9.       if Integer(C.Tag) in Tags then
  10.         C.Visible := Visible;
  11.   if Integer(Parent.Tag) in Tags then
  12.     Parent.Visible := Visible;
  13. end;
« Last Edit: September 09, 2017, 03:36:30 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #4 on: September 09, 2017, 03:48:49 am »
Taazz,

Quote
Error: identifier idents no member "Visible"

Same message I got with my original code.

B
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #5 on: September 09, 2017, 03:56:59 am »
Taazz,

Quote
Error: identifier idents no member "Visible"

Same message I got with my original code.
Sorry didn't read back enough, here is a slightly modified version. If you have any components that are not behaving post the component class name and I'll extend the procedure to support them.
Code: Pascal  [Select][+][-]
  1. procedure SetVisibleByTags(Parent: TWinControl; Visible: Boolean; const Tags: TIntegerSet);
  2. var
  3.   C: TComponent;              //<---- type changed
  4. begin
  5.   for C in Parent do            //<---- Enumerator Changed
  6. //    if C is TWinControl then
  7. //      SetVisibleByTags(TWinControl(C), Visible, Tags)
  8. //    else
  9.       if Integer(C.Tag) in Tags then
  10.       begin
  11.         if C is tcontrol then TControl(C).Visible := Visible // most of the controls will fall in this labels, panels, buttons grids etc are all TControl based.
  12.         else if C is TMenuItem then TMenuItem(C).Visible := Visible
  13. //        else if C is TMenuItem then TMenuItem(C).Visible := Visible  // any other kind of control you need to set?? Taction?
  14.         ;
  15.       end;
  16.   if Integer(Parent.Tag) in Tags then
  17.     Parent.Visible := Visible;
  18. end;
by the way why not use actions for this? they are designed for that purpose.
« Last Edit: September 09, 2017, 04:03:21 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #6 on: September 09, 2017, 04:43:55 am »
Thanks taazz,

Somewhere in that there was a slight bug. :o

So I rewrote your latest, chucking in strings to add to a diagnosis showmessage.

It's too painful to show here, as it is full of debug strings.

But the rewrite seems to work.

And the 4 iterations (remember the original request was Private=22 and Test=11, 2 separate values, 2 separate results) now result as desired with TMenuItems showing or not showing).

Now I save it and remove the debug garbage ... and stuff it up.  :D

And after successful garbage removal, I'll post it for future reference.

Thanks

B
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #7 on: September 09, 2017, 05:35:10 am »
    Here is the working version, with all 4 iterations successful.

    * A tag of 22 denotes a private control/menuitem;
    * A tag of 11 denotes a test control/menuitem;
    * A control/menuitem cannot belong to 2 groups unless you modify the code significantly;
    * Interrogation of parameters or a config file controls the visibility of an item.
    * The first Boolean parameter is the private visibility setting (tags=22);
    * The second Boolean parameter is the test visibility setting (tags=11);

Code: Pascal  [Select][+][-]
  1. procedure SetVisibleByTags(Parent: TWinControl; pPrivate,pTest:boolean);
  2. var C:TComponent;
  3. begin
  4.   for C in Parent do
  5.     if Integer(C.Tag)=22 then
  6.       if C is TControl then
  7.         TControl(C).Visible := pPrivate
  8.       else
  9.       if C is TMenuItem then
  10.         TMenuItem(C).Visible := pPrivate
  11.       else
  12.     else
  13.     if Integer(C.Tag)=11 then
  14.       if C is TControl then
  15.         TControl(C).Visible := pTest
  16.       else
  17.       if C is TMenuItem then
  18.         TMenuItem(C).Visible := pTest;
  19.   if Integer(Parent.Tag)=22 then
  20.     if Parent is TControl then
  21.       TControl(Parent).Visible := pPrivate
  22.     else
  23.   else
  24.   if Integer(Parent.Tag)=11 then
  25.     if Parent is TControl then
  26.       TControl(Parent).Visible := pTest;
  27. end;
  28.  
  29. procedure TForm1.FormCreate(Sender: TObject);
  30. var PrivateParDetected,TestParDetected:boolean;
  31. begin
  32.   PrivateParDetected:= (your process here)
  33.   TestParDetected:= (your process here)
  34.   SetVisibleByTags(Self,PrivateParDetected,TestParDetected);
  35. end;
  36.  

And thanks to taazz and ASerge.

B
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #8 on: September 09, 2017, 06:12:33 am »
lol! you managed to stuff everything in a "single" statement? why not use a begin end? something along the lines of
Code: Pascal  [Select][+][-]
  1. procedure SetVisibleByTags(Parent: TWinControl; pPrivate,pTest:boolean);
  2. var C:TComponent;
  3. begin
  4.   for C in Parent do begin
  5.     if Integer(C.Tag)=22 then begin
  6.       if C is TControl then
  7.         TControl(C).Visible := pPrivate
  8.       else
  9.       if C is TMenuItem then
  10.         TMenuItem(C).Visible := pPrivate;
  11.     end else
  12.     if Integer(C.Tag)=11 then
  13.       if C is TControl then
  14.         TControl(C).Visible := pTest
  15.       else
  16.       if C is TMenuItem then
  17.         TMenuItem(C).Visible := pTest;
  18.   end;
  19.   if Integer(Parent.Tag)=22 then
  20.     if Parent is TControl then
  21.       TControl(Parent).Visible := pPrivate
  22.     else
  23.   else
  24.   if Integer(Parent.Tag)=11 then
  25.     if Parent is TControl then
  26.       TControl(Parent).Visible := pTest;
  27. end;
  28.  
  29. procedure TForm1.FormCreate(Sender: TObject);
  30. var PrivateParDetected,TestParDetected:boolean;
  31. begin
  32.   PrivateParDetected:= (your process here)
  33.   TestParDetected:= (your process here)
  34.   SetVisibleByTags(Self,PrivateParDetected,TestParDetected);
  35. end;
or even cleaner.
Code: Pascal  [Select][+][-]
  1. procedure SetVisibleByTags(Parent: TWinControl; pPrivate,pTest:boolean);
  2.   function GetValue(aComponet:TComponent):Boolean;
  3.   begin
  4.     if aComponent is TControl then  result := TControl(aComponent).Visible
  5.     else if aComponent is TMenuItem then  result := TMenuItem(aComponent).Visible
  6.     else result := true;
  7.     if acomponent.tag = 22 then result := pPrivate
  8.     else if aComponent.Tag = 11 then result := pTest;
  9.   end;
  10.  
  11. var C:TComponent;
  12. begin
  13.   for C in Parent do begin
  14.       if C is TControl then
  15.         TControl(C).Visible := GetValue(C)//pPrivate
  16.       else
  17.       if C is TMenuItem then
  18.         TMenuItem(C).Visible := GetValue(C);//pPrivate;
  19.   end;
  20.   //parent is always TWinControl
  21.   Parent.Visible := GetValue(Parent);
  22. end;
  23.  
Just for fun.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #9 on: September 10, 2017, 01:05:31 am »
Taazz,

While you were recoding, so was I, so I have yet to try yours out, but I will.

I revisited my original code to see where I went wrong.

This now actually works:

Code: Pascal  [Select][+][-]
  1. procedure SetVisi2(pPrivate,pTest:boolean);
  2. const cPrivTag=22; cTestTag=11;
  3. var I:integer; C:TComponent;
  4. begin
  5.   for I:=0 to Form1.ComponentCount-1 do
  6.     begin
  7.       C:=Form1.Components[I];
  8.       if C is TMenuItem then
  9.         with C as TMenuItem do
  10.           if Tag=cPrivTag then
  11.             Visible:=pPrivate
  12.           else
  13.           if Tag=cTestTag then
  14.             Visible:=pTest
  15.           else
  16.       else
  17.       if C is TControl then
  18.         with C as TControl do
  19.           if Tag=cPrivTag then
  20.             Visible:=pPrivate
  21.           else
  22.           if Tag=cTestTag then
  23.             Visible:=pTest;
  24.     end;
  25. end;
  26.  

My original fault was not including this pair:

Code: Pascal  [Select][+][-]
  1.       if C is TMenuItem then
  2.         with C as TMenuItem do
  3.  

and the same for TControl. I remember playing with something similar after creating this topic.

It's been tested on levels of MenuItem, hiding items or submenus as required by tag, and also some temporary buttons (1 private and 1 test).

Also the middle "else else" is extremely important. Miss one and TControl does not get checked.

I also wonder why ASerge and yourself use

Quote
Integer(C.Tag)

Property Tag is longinteger anyway.

Anyway, I'll try your new code.

Many thanks

B
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #10 on: September 10, 2017, 01:21:04 am »
Yes Taazz,

I tried your "cleaner" one. It is nice and compact.

A quick correction to it:

Code: Pascal  [Select][+][-]
  1. function GetValue(aComponent:TComponent):Boolean

("aComponent").

And it works beautifully for iterations of private and test.

Two working solutions. Well future readers can take their pick.

Thanks

B
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #11 on: September 10, 2017, 04:48:47 am »
here a bit more compact
Code: Pascal  [Select][+][-]
  1. procedure SetVisibleByTags(Parent: TWinControl; pPrivate,pTest:boolean);
  2.   function GetValue(aComponent:TComponent; aDefault:Boolean=True):Boolean;inline;//<-I have no idea if it helps but ...
  3.   begin
  4.     case aComponent.Tag of
  5.        22 : Result := pPrivate;
  6.        11 : Result := pTest;
  7.     else
  8.        Result := aDefault;
  9.     end;
  10.   end;
  11.  
  12. var C:TComponent;
  13. begin
  14.   for C in Parent do begin
  15.       if C is TControl then
  16.         TControl(C).Visible := GetValue(C,TControl(C).Visible)//pPrivate
  17.       else
  18.       if C is TMenuItem then
  19.         TMenuItem(C).Visible := GetValue(C,TMenuItem(C).Visible);//pPrivate;
  20.   end;
  21.   //parent is always TWinControl
  22.   Parent.Visible := GetValue(Parent,Parent.Visible);
  23. end;
« Last Edit: September 10, 2017, 04:52:02 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #12 on: September 10, 2017, 06:21:40 am »
For those of you who have just looked at this thread, here is a synopsis:

1) Bazza requested code fixing to hide components based upon Tag value (1 of 2 values);
2) Aserge replied with code;
3) taazz improved the code to a working state;
4) Bazza looked at his original code, and based upon what he learned from Aserge & taazz, came up with working code;
5) taazz shortened his working code;
6) Bazza set his parameters to match taazz's. He doesn't know as much as taazz or Aserge.
7) taazz shortened his working code even more. Bazza now says taazz cannot do it in less than 8 lines.
8 ) Bazza tidied up his working code even more. He now claims his is less processing.

Here is the latest code (incorporating all [well most] working verions):
SetVisibleByTags1: Authored by taazz.
SetVisibleByTags2: Authored by Bazza.
SetVisibleByTags3: Authored by taazz.
SetVisibleByTags4: Authored by Bazza.

Code: Pascal  [Select][+][-]
  1. procedure SetVisibleByTags1(Parent: TWinControl; pPrivate,pTest:boolean);
  2. var C:TComponent;
  3.   function GetValue(aComponent:TComponent):Boolean;
  4.   begin
  5.     if aComponent is TControl then  result := TControl(aComponent).Visible
  6.     else if aComponent is TMenuItem then  result := TMenuItem(aComponent).Visible
  7.     else result := true;
  8.     if acomponent.tag = 22 then result := pPrivate
  9.     else if aComponent.Tag = 11 then result := pTest;
  10.   end;
  11. begin
  12.   for C in Parent do begin
  13.       if C is TControl then
  14.         TControl(C).Visible := GetValue(C)//pPrivate
  15.       else
  16.       if C is TMenuItem then
  17.         TMenuItem(C).Visible := GetValue(C);//pPrivate;
  18.   end;
  19.   //parent is always TWinControl
  20.   Parent.Visible := GetValue(Parent);
  21. end;
  22.  
  23. procedure SetVisibleByTags2(Parent:TWinControl; pPrivate,pTest:boolean);
  24. const cPrivTag=22; cTestTag=11;
  25. var I:integer;
  26.   procedure SetVis(C:TComponent);
  27.   begin
  28.     if C is TMenuItem then with C as TMenuItem do
  29.       if Tag=cPrivTag then
  30.         Visible:=pPrivate
  31.       else
  32.       if Tag=cTestTag then
  33.         Visible:=pTest
  34.       else
  35.     else
  36.     if C is TControl then with C as TControl do
  37.       if Tag=cPrivTag then
  38.         Visible:=pPrivate
  39.       else
  40.       if Tag=cTestTag then
  41.         Visible:=pTest;
  42.   end;
  43. begin
  44.   for I:=0 to Parent.ComponentCount-1 do
  45.     SetVis(Parent.Components[I]);
  46. end;
  47.  
  48. procedure SetVisibleByTags3(Parent: TWinControl; pPrivate,pTest:boolean);
  49.   function GetValue(aComponent:TComponent; aDefault:Boolean=True):Boolean;inline;//<-I have no idea if it helps but ...
  50.   begin
  51.     case aComponent.Tag of
  52.        22 : Result := pPrivate;
  53.        11 : Result := pTest;
  54.     else
  55.        Result := aDefault;
  56.     end;
  57.   end;
  58. var C:TComponent;
  59. begin
  60.   for C in Parent do begin
  61.       if C is TControl then
  62.         TControl(C).Visible := GetValue(C,TControl(C).Visible)//pPrivate
  63.       else
  64.       if C is TMenuItem then
  65.         TMenuItem(C).Visible := GetValue(C,TMenuItem(C).Visible);//pPrivate;
  66.   end;
  67.   //parent is always TWinControl
  68.   Parent.Visible := GetValue(Parent,Parent.Visible);
  69. end;
  70.  
  71. procedure SetVisibleByTags4(Parent:TWinControl; pPrivate,pTest:boolean);
  72. const cPrivTag=22; cTestTag=11;
  73. var I:integer; vThatOne:TComponent;
  74.   procedure SetVis(pValue:boolean);
  75.   begin
  76.     if vThatOne is TMenuItem then with vThatOne as TMenuItem do
  77.       Visible:=pValue
  78.     else
  79.     if vThatOne is TControl then with vThatOne as TControl do
  80.       Visible:=pValue;
  81.   end;
  82. begin
  83.   for I:=0 to Parent.ComponentCount-1 do
  84.     begin
  85.       vThatOne:=Parent.Components[I];
  86.       with vThatOne do
  87.         if Tag=cPrivTag then
  88.           SetVis(pPrivate)
  89.         else
  90.         if Tag=cTestTag then
  91.           SetVis(pTest);
  92.     end;
  93. end;
  94.  
  95. procedure TForm1.FormCreate(Sender: TObject);
  96. var I:integer; vPrivate,vTest:boolean;
  97. begin
  98.   vPrivate:=true; // Replace with your test, eg parameters.
  99.   vTest:=true; // Replace with your test, eg parameters.
  100.   I:=Random(4); // Let's use one at random.
  101.   case I of
  102.     0: SetVisibleByTags1(Self,vPrivate,vTest); // taazz.
  103.     1: SetVisibleByTags2(Self,vPrivate,vTest); // Bazza.
  104.     2: SetVisibleByTags3(Self,vPrivate,vTest); // taazz.
  105.     3: SetVisibleByTags4(Self,vPrivate,vTest); // Bazza.
  106.   end;  
  107. end;
  108.  
                                                                 

taazz, your #3 works. You wanna try for the challenge above?

Bazza
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #13 on: September 10, 2017, 06:41:35 am »
taazz, your #3 works. You wanna try for the challenge above?
here is the shortest version I can come up with.
Code: Pascal  [Select][+][-]
  1.  uses typinfo, .....
  2.  
  3. procedure SetVisibleByTags(Parent: TWinControl; pPrivate,pTest:boolean);
  4.   function GetValue(aComponent:TComponent; aDefault:Boolean=True):Boolean;inline;//<-I have no idea if it helps but ...
  5.   begin
  6.     case aComponent.Tag of
  7.       22 : Result := pPrivate;
  8.       11 : Result := pTest;
  9.     else
  10.       Result := aDefault;
  11.     end;
  12.   end;
  13.  
  14. var C:TComponent;
  15. begin
  16.   for C in Parent do
  17.     SetPropValue(C, 'Visible', GetValue(C, GetPropValue(C,'Visible'));
  18. end;//parent is not needed here at all since it will always be visible.
  19.  
  20.  
keep in mind that it is processing heavy and I would never use it in production code, so my previous version is the best one in my opinion.
« Last Edit: September 10, 2017, 06:51:53 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Bazzao

  • Full Member
  • ***
  • Posts: 178
  • Pies are squared.
Re: Loop Thru Components Setting Visibility And Enableability
« Reply #14 on: September 10, 2017, 07:14:37 am »
It is interesting your coding style of placing variables after a nested procedure.

I am self-taught as pascal goes (Apple ][ + ...) [I shall have to reply to that other new member] and learned that variables (and constants) of a mother procedure are available to a child. So I place them first. Hence my #4.

Anyway I think we've cooked it enough. I shall honour you by putting the #5 in my application and adjust the random accordingly.

B
Bazza

Lazarus 2.0.10; FPC 3.2.0; SVN Revision 63526; x86_64-win64-win32/win64
Windows 10.

 

TinyPortal © 2005-2018