Recent

Author Topic: Best way to exchange data between a form and a unit  (Read 60618 times)

Hansvb

  • Hero Member
  • *****
  • Posts: 799
Re: Best way to exchange data between a form and a unit
« Reply #255 on: April 17, 2025, 06:51:39 pm »
Hmmm a bit early. I don't know how it is in Denmark, but here it is Sunday Easter  ;). I still have to start…  :D

cdbc

  • Hero Member
  • *****
  • Posts: 2124
    • http://www.cdbc.dk
Re: Best way to exchange data between a form and a unit
« Reply #256 on: April 17, 2025, 06:58:08 pm »
Hi Hans
We've started our small holiday today and it runs through to & with Monday  O:-)  Pity with the weather though :(
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Hansvb

  • Hero Member
  • *****
  • Posts: 799
Re: Best way to exchange data between a form and a unit
« Reply #257 on: April 17, 2025, 07:46:51 pm »
I see. I still have to work tomorrow. But have the next week off. We were going to Austria for a week. The laptop with Lazarus on it will of course come along. The weather is also bad there, so maybe the plans will change.

cdbc

  • Hero Member
  • *****
  • Posts: 2124
    • http://www.cdbc.dk
Re: Best way to exchange data between a form and a unit
« Reply #258 on: April 17, 2025, 07:54:00 pm »
Hi
Ouh, that's nice... If the weather plays along, then Austria is very nice indeed.
I lived there in my youth, 8 years worth of ski-instructing   8-)
Lets just hope it turns around to the better =^
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Hansvb

  • Hero Member
  • *****
  • Posts: 799
Re: Best way to exchange data between a form and a unit
« Reply #259 on: April 18, 2025, 10:16:58 pm »
Because of the bad weather in Austria we cancelled the holiday. that is a pity. but next week I will have a lot of time to play with Lazarus Pascal.

Hansvb

  • Hero Member
  • *****
  • Posts: 799
Re: Best way to exchange data between a form and a unit
« Reply #260 on: April 19, 2025, 11:41:40 am »
Hi,
Maybe I'm blind to the solution and I should do something else first, but I'm running into the following. I am using Result a bit more in the transactions and want to send a warning to the view via "the short route". How can I make that language dependent? I can do this:
Code: Pascal  [Select][+][-]
  1. aMgr.Owner.Provider.NotifySubscribers(pr..., nil, @lRec);
and handle the language dependency in the DOfunction in the view, but that seems a bit much for just an error message.

Code: Pascal  [Select][+][-]
  1. function TSomeTransaction.Execute(aMgr : ITransactionManager): Boolean;    
  2. var
  3.   ...
  4. begin  
  5.   Result:= aMgr.Owner.Model.DoesFileExists(FileName);
  6.   If Result then begin
  7.     ... start doing stuff...
  8.   end
  9.   else begin
  10.     aMgr.Owner.Provider.NotifySubscribers(prStatus,nil,Str2Pch('File not found.'));  <--- how to get the right language at this point?
  11.   end;  
  12. end;

cdbc

  • Hero Member
  • *****
  • Posts: 2124
    • http://www.cdbc.dk
Re: Best way to exchange data between a form and a unit
« Reply #261 on: April 19, 2025, 12:01:41 pm »
Hi Hans
Give the transaction its own 'Section' in the /projectX.en/nl/dk -file/ with 'RegisterSection(TSomeTransaction.Classname);' in the 'initialization' part of your transaction-unit...

In the sections file, you just create the section & name the message e.g.:
[TSomeTransaction]
TSomeTransaction.Warning=Waarschuwing: Bestand niet gevonden!

In the transaction you just fetch the section and get the translated message... 'lmsg:= lsl.Values(Classname+'.Warning');'

I believe that would do the trick  8-)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

cdbc

  • Hero Member
  • *****
  • Posts: 2124
    • http://www.cdbc.dk
Re: Best way to exchange data between a form and a unit
« Reply #262 on: April 19, 2025, 12:06:17 pm »
PS.: I'm sorry to hear, you had to cancel your vacation...
It's also pouring down here in Denmark, if that helps a little...  :D
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Hansvb

  • Hero Member
  • *****
  • Posts: 799
Re: Best way to exchange data between a form and a unit
« Reply #263 on: April 19, 2025, 05:09:21 pm »
I went for lRec. Then also you have to put  'RegisterSection(TSomeTransaction.Classname);' in the initialization part.
The proposed method got stuck at lmsg:= lsl.Values(Classname+'. Warning');'  lsl.Values() indicated that an incorrect number of parameters were used. I couldn't fixed that.

In terms of weather, I am good in the Netherlands. I spent almost the whole afternoon outside. The sun is shining brightly.

cdbc

  • Hero Member
  • *****
  • Posts: 2124
    • http://www.cdbc.dk
Re: Best way to exchange data between a form and a unit
« Reply #264 on: April 19, 2025, 05:32:58 pm »
Hi
Hmmm...:
Code: Pascal  [Select][+][-]
  1. function TSomeTransaction.Execute(aMgr : ITransactionManager): Boolean;    
  2. var
  3.   lsl: IStringlist; // HERE
  4.   dummy: integer; // HERE
  5.   ...
  6. begin  
  7.   Result:= aMgr.Model.DoesFileExists(FileName);
  8.   If Result then begin
  9.     ... start doing stuff...
  10.   end
  11.   else begin
  12.     { HERE IS HOW to get the right language }
  13.     lsl:= aMgr.Model.GetStaticTexts(Classname,dummy);
  14.     aMgr.Owner.Provider.NotifySubscribers(
  15.       prStatus,
  16.       nil,
  17.       Str2Pch(lsl.Values[Classname+'.Warning'])
  18.     );
  19.   end;  
  20. end;
  21.  
HTH
Regards Benny
« Last Edit: April 19, 2025, 06:00:15 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

cdbc

  • Hero Member
  • *****
  • Posts: 2124
    • http://www.cdbc.dk
Re: Best way to exchange data between a form and a unit
« Reply #265 on: April 19, 2025, 06:04:24 pm »
Hi Hans
Edited above post, changed
Code: Pascal  [Select][+][-]
  1. lsl.Values()
to
Code: Pascal  [Select][+][-]
  1. lsl.Values[]
Sorry for the nuiscense...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Hansvb

  • Hero Member
  • *****
  • Posts: 799
Re: Best way to exchange data between a form and a unit
« Reply #266 on: April 19, 2025, 06:24:07 pm »
I hadn't looked closely enough. I had tried lsl. Values('[...]').

cdbc

  • Hero Member
  • *****
  • Posts: 2124
    • http://www.cdbc.dk
Re: Best way to exchange data between a form and a unit
« Reply #267 on: April 21, 2025, 06:09:39 pm »
Hi Hans
...and everybody else with an interest in MVP  8)
You told me, you have the week off, so I finished my TODO-list and made some new stuff, for you to play with...  :D
Version 14.21.04.2025 of MVP-Setup is out now, so get it while it's Hot.
-- Just trying to keep you busy --  TiHi ;)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Hansvb

  • Hero Member
  • *****
  • Posts: 799
Re: Best way to exchange data between a form and a unit
« Reply #268 on: April 21, 2025, 08:36:43 pm »
Hi Benny,

I'm going to look at it one of these days. Of course I also have to tinker with my own tool. ( A week is short).
common.consts sounds good. I'm going to check it out. { nifty little manual interface } --> makes me curious.

You're just busy with it. Thanks again for the work.

 

TinyPortal © 2005-2018