Recent

Author Topic: [SOLVED] Verbosity...  (Read 6933 times)

Handoko

  • Hero Member
  • *****
  • Posts: 3188
  • My goal: build my own game engine using Lazarus
Re: [SOLVED] Verbosity...
« Reply #30 on: July 03, 2018, 07:00:17 pm »
I remember you asked about combining console mode with ShowMessage. Not sure on Windows, but this code below seems to work on my Linux computer:

Code: Pascal  [Select]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   Interfaces, Dialogs;
  7.  
  8. begin
  9.   if ParamStr(1) = 'hello' then
  10.     ShowMessage('Hello, there!')
  11.   else
  12.     WriteLn('Unknown parameter.');
  13. end.

Note:
You have to add LCL as the project's required package.

The code is inspired from Thaddy, read here if you want to know more:
http://forum.lazarus.freepascal.org/index.php/topic,37425.msg251457.html#msg251457
« Last Edit: July 03, 2018, 07:06:03 pm by Handoko »

GypsyPrince

  • New Member
  • *
  • Posts: 37
Re: [SOLVED] Verbosity...
« Reply #31 on: July 03, 2018, 09:13:22 pm »
Handoko ~

Thank you for your effort.

After reading a bit further in the documentation I found that graphic dialogs can be shown from console apps for Mac, Unix, and Linux, but not for Windows. However, the reverse can occur. One can open a console window from within a GUI app in Windows.

Also, and I actually like this better, while reading through my book 'Lazarus: The Complete Guide', I found that Lazarus can work with text-based GUI libraries such as "ncurses" for Unix and Linux, and for Windows - a library called Free Vision - derived from Turbo Vision that was the GUI library for Borland's Turbo C++ and Turbo Pascal. I'm doing my happy dance after finding out that bit of info.

Ah... Turbo C++. Fond memories. I miss DOS. LOL
May the mass * acceleration be with you!

GypsyPrince

  • New Member
  • *
  • Posts: 37
Re: [SOLVED] Verbosity...
« Reply #32 on: July 03, 2018, 09:22:58 pm »
Well, now. I performed a search and found that marcov has dabbled a bit with Free Vision.

marcov - were you ever able to get Free Vision to work with Lazarus in any meaningful way? Did anyone come up with a viable editor for it?

I am very nostalgic for old DOS programs and want to dabble a bit with FV in console apps.
May the mass * acceleration be with you!

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7503
Re: [SOLVED] Verbosity...
« Reply #33 on: July 03, 2018, 10:00:22 pm »
Well, now. I performed a search and found that marcov has dabbled a bit with Free Vision.

Yes. Textmode IDE maintenance mostly.

Quote
marcov - were you ever able to get Free Vision to work with Lazarus in any meaningful way? Did anyone come up with a viable editor for it?

IF you mean a lazarus based designer, no, didn't even try, too little time.

Quote
I am very nostalgic for old DOS programs and want to dabble a bit with FV in console apps.

FV  old TP object model and ways of dealing with strings are a bit of a pain.

GypsyPrince

  • New Member
  • *
  • Posts: 37
Re: [SOLVED] Verbosity...
« Reply #34 on: July 03, 2018, 10:43:42 pm »
Ah. Oh well. Twas a good pipe dream while it lasted. LOL
« Last Edit: July 05, 2018, 03:44:12 pm by GypsyPrince »
May the mass * acceleration be with you!

GypsyPrince

  • New Member
  • *
  • Posts: 37
Re: [SOLVED] Verbosity...
« Reply #35 on: September 14, 2019, 09:21:45 am »
@marcov

Revisiting this almost a year and a half later...
I am in total agreement with you. Replacing 'End;' with 'End Procedure;', 'End Function;', etc. should not be mandatory. I was just pondering something more along the lines of a feature where one could create a list of aliases for keywords similar to pointer aliases in C, and type aliases in Kotlin. When the program is compiled, each alias would be replaced with the real keyword it represents.
 
Now... having said this, I don't think, at all, that this should be a feature built into Lazarus/FreePascal. Instead, I prefer it be some sort of add-on or package that would be loaded only when those more comfortable with VB syntax choose to load it. That way, Lazarus/Pascal purists don't have to deal with it if they don't want to. Basically, it would be an add-on that when the coder runs the 'compile' command' it would convert only the most basic of VB-like syntax into its proper Pascal syntax in temp files before the compiler actually executes and compiles those temp files.

Example:
If the coder typed  "End Procedure;", "End Function;", "End Try;", etc., each instance would be replaced simply with "End;" right before being compiled. Yes, the coder would still need to terminate the keyword aliases with a semi colon where one is required.

I certainly don't want to change the Pascal language into the VB language. I just want to make it a little bit more familiar and comfortable for VB users by aliasing a few basic keywords while we lure them over and they learn Pascal.

A major con to this, and it is a major one, is that such an undertaking require a small team of experienced volunteer coders to create such an add-on, and doing so without bothering either the Lazarus or FPC development teams. It would also be very tricky to make the converter work correctly and I myself do not have anywhere near the experience to take on that kind of project. So, I know this won't ever be a reality. But like I said before... t'was a nice pipe dream. LOL
 
To the folks who get upset at such a prospect and say "This isn't VB, it's Pascal."... is the purpose of either Lazarus or this forum to prove how much of a fanboy you are by viciously defending your chosen language, or is it about providing users with an open, powerful, productive development environment?
 
Someone mentioned that if I am more comfortable with the VB syntax then I should stay with VB. In addition to my losing faith in Microsoft's business and software sunset decisions, I have other reasons for wanting to drop VB/.NET.

1. VB/C#/.NET is compiled to CIL and runs on a virtual machine. It just can't deliver the performance I like getting when I use C/C++ - Pascal can.

2. Though VB is moving to cross platform, only console apps will be cross-platform, even in the upcoming .NET Core 3.0. GUI apps using WinForms and WPF will remain Windows only. Any Xamarin support for VB to allow for cross-platform GUI apps will be implemented only by opensource volunteers and won't be supported (officially, anyway) or promoted by Microsoft.

3. VB/C#/.NET applications are bloated and app portability is difficult without compiling to native code which can currently only be done with apps created on the Universal Windows Platform.

So, this is a chance for Lazarus to steal away the multitudes of folks like myself who are looking to jump the Microsoft and Windows ship.
May the mass * acceleration be with you!

glorfin

  • Jr. Member
  • **
  • Posts: 66
Re: [Feature Request] Verbosity...
« Reply #36 on: October 28, 2019, 03:57:36 pm »
Well, how about:
Code: Pascal  [Select]
  1. {$macro on}{$Define End_Function:=end}{$Define End_Procedure:=End}
  2. {$Define End_If := End}{$Define End_Try:= End}{$Define End_Case := End}
  3. [/quote]
  4.  
  5. This is not quite the same as to have really different ends for for each construct, because in the latter case compiler would be able to help finding mismatches. Personally I like how it works in fortran, where no "begin" is needed, but "end"s are specific.
  6. Having said this, I think, adding this feature would draw us too far from pascal language. In case of really complex constructs, I am using simply comments, as was here supposed several times.

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: [SOLVED] Verbosity...
« Reply #37 on: October 28, 2019, 06:12:31 pm »
If the coder typed  "End Procedure;", "End Function;", "End Try;", etc., each instance would be replaced simply with "End;" right before being compiled.
That's exactly what Thaddy has shown you how to do with use of macros. The only difference is using underscore instead of space. It is also debugger friendly, unlike preprocessor that you would prefer to see as an IDE plugin.

You might be interested in some VB to Delphi convertors, which can produce pascal code you can use in Lazarus as a start:
http://www.marcocantu.com/tools/vb2delphi.htm
https://cc.embarcadero.com/item/17064
http://www.vbto.net/

Do not expect miracles on complex projects. Lot of manual work will be needed. I used such converters just as time savers when there was a VB header for some C DLL when Pascal header didn't exist. It gives mostly 100% automatic conversion of VB DLL headers.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

GypsyPrince

  • New Member
  • *
  • Posts: 37
Re: [SOLVED] Verbosity...
« Reply #38 on: November 03, 2019, 10:18:31 am »
@avra

Thank you for that info. However, I finally decided it is time for me to put on my "big boy" pants and use the language as was intended. It never really occurred to me before that "End" really isn't any different than using the closing curly bracket in C "}". I've been using that for decades, now. So, I guess I can stop being a cry-baby and use End without complaint, as well. LOL  :-[
May the mass * acceleration be with you!