Recent

Author Topic: Moving to Free Pascal from Visual Basic  (Read 691 times)

Wilko500

  • New Member
  • *
  • Posts: 13
Moving to Free Pascal from Visual Basic
« on: November 13, 2020, 11:18:30 pm »
Hi,
I am an experienced VB6 programmer now retired but hobby programming.  I have been looking for an alternative to VB6 because VB6 (32bit) is getting difficult to run on windows.

Free Pascal/Lazarus seem like a very good candidate but I am wondering whether FP can achieve what I want.  I am not asking how to migrate, I would expect to rewrite code, nor how to do it, I expect to have to put effort into finding out, maybe with a little help.

My VB6 application draw a flowchart which can optionally be printed.  Please look at the attachment.  The output form is scaled to fit available screen space and all graphics are drawn in real world units, in my case mm's.  In VB6 the form has a scale property so that output is drawn scaled to fit the form size.  The same code produces both form output and printed output simply by changing an output director.

My question is can this be done in FP?  Comments, ideas, suggestions welcomed.

edit: I should have added that I want to develop in MacOs environment so I can junk my virtual Windows
Thanks
Richard
« Last Edit: November 13, 2020, 11:33:24 pm by Wilko500 »

dbannon

  • Hero Member
  • *****
  • Posts: 1261
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Moving to Free Pascal from Visual Basic
« Reply #1 on: November 14, 2020, 12:11:13 am »
Yes Richard, superficially, quite easy.  In Lazarus (thats the graphic tool kit) most components have a canvas. You draw on the canvas to display on the screen. And the printer also has a canvas, the same drawing tools will draw on the printers canvas.

Join us, do not be afraid....

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

jamie

  • Hero Member
  • *****
  • Posts: 4038
Re: Moving to Free Pascal from Visual Basic
« Reply #2 on: November 14, 2020, 01:13:52 am »
for real world transforms I think the best solution would be to create a helper for the canvas which is what I did..

in fpc you can create helpers for existing classes to extend their use. This means you can have MMLineto, MMREctangle, etc..

 by referencing the DPI which in most cases is 96 dots per inch but could be different on other systems of course, you can perform the math needed.

 but in any case if you are doing vector graphics then it's a simple matter of referencing the dpi as the scaler..
The only true wisdom is knowing you know nothing

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1200
  • Former Delphi 1-7, 10.2 User
Re: Moving to Free Pascal from Visual Basic
« Reply #3 on: November 14, 2020, 06:51:16 am »
You might find the following FPC + Lazarus Wiki pages of help:

* Mac Portal;
* Pascal for VB users.

o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

avra

  • Hero Member
  • *****
  • Posts: 2081
    • Additional info
Re: Moving to Free Pascal from Visual Basic
« Reply #4 on: November 14, 2020, 07:42:42 pm »
For VB code conversion there are tools which work to some extent:
https://forum.lazarus.freepascal.org/index.php/topic,41742.msg337651.html#msg337651
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Wilko500

  • New Member
  • *
  • Posts: 13
Re: Moving to Free Pascal from Visual Basic
« Reply #5 on: November 20, 2020, 02:18:44 pm »
Thank you all for replies and sorry for delay in responding. I thought I'd ticked to receive notifications and was waiting but none arrived! I must have got it wrong.

So far I've managed to create a form, draw lines and text in various colours and move/resize it to user supplied coordinates.  I feel encouraged.

Avra, thanks for the link to conversion tools.  I try to code in self contained modules so trying a conversion on some might give me a head start with code to learn on.

Trev,  thanks for the links.  I had already viewed the Pascal for VB users.  Many years ago I wrote a OS NTF to DXF conversion program in Turbo Pascal so I'm ok with the (very) basics of Pascal.  The Mac Portal link may prove more useful.  In the first instance I tried a Mac install without the benefit of the guidance in the link , it failed miserably. Libraries missing although I could navigate to them! Will need to try again.

Jamie,  Thanks for the tip on helpers.  I'll research this topic.

Davo, Thanks for encouragement. I think I'm trying to run before I can walk.  Probably need to spend time looking at more straightforward tutorials rather than attempting to duplicate what I have already developed over many, many months.

Looks like I'll be joining your community. With out for questions lol

Richard

 

TinyPortal © 2005-2018