Recent

Author Topic: [SOLVED] Using Write, Writeln in GUI app  (Read 7568 times)

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: [SOLVED] Using Write, Writeln in GUI app
« Reply #15 on: October 31, 2016, 05:22:42 pm »
This solution does not do exactly the same, ie. what I needed, but it can be useful for others.
From your original Q it was not entirely clear what functionality you sought (e.g. how exactly to write into the memo).

Note that afaik the solution as showed is the most identical to the original write/writeln combination, without having to go into detailed coding yourself.

Quote
Btw. I tried similar thing via the StreamIO but forgot to call Rewrite and got some IO error.
Yups, a common mistake i make often myself as well  :)

Quote
EDIT: Actually this solution can be persuaded to do the same, ie. not to rewrite entire memo content after each call:
I did wrote _poor person's_ solution. That was with reason  :D

You can make it do whatever you'd like it to do, which includes filling the memo only and not write to the stringstream at all.

However and as stated before. It is awkward with regards to supporting write and writeln as you'd have to keep track when the last write was terminated with a cr/lf or not and depending on the answer fall back to the previous line and concat to that line first (again, if wanting to support write + writeln combination).

Glad that you could make things work the way you'd liked them to be. Thanks for having checked my (well, heavily inspired by one of our other forum members, unfortunately can't remember who it was exactly) solution and reporting back.
« Last Edit: October 31, 2016, 06:04:03 pm by molly »

Graeme

  • Hero Member
  • *****
  • Posts: 1430
    • Graeme on the web
Re: [SOLVED] Using Write, Writeln in GUI app
« Reply #16 on: October 31, 2016, 06:25:43 pm »
Wow, you guys are making it overly complicated. Introduce a new function called Log(...), preferably in it's own unit so it can be reused. Define as many overloaded version of Log() as you want for all the parameter counts you want. Then inside the top level Log() that only takes a single string parameter add a IFDEF...ELSE... One part uses WriteLn(), and the other adds the contents to the Memo. All the other overloaded Log() calls will eventually format there parameters to a single string parameter which reaches the top level Log() call.

A better solution is simply to use the tiOPF's tiLogXXX units. There you have the option to Log-to-file, log-to-console, log-to-GUI (a separate popup window) etc. These tiLogXXX units can be used indepedently from the rest of the tiOPF framework. ps: These units are multi-threaded enabled too, and support cached logging so as not to slow down your application.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Thaddy

  • Hero Member
  • *****
  • Posts: 9142
Re: [SOLVED] Using Write, Writeln in GUI app
« Reply #17 on: November 01, 2016, 10:12:14 am »
Over- complicating the fact that we could improve on the macro language? >:D 8-) >:(
tiOPF is nice, but...
also related to equus asinus.