Recent

Author Topic: modules (units) in online compilers  (Read 248 times)

aja_ttara

  • Newbie
  • Posts: 5
modules (units) in online compilers
« on: April 29, 2025, 09:47:35 am »
I am using an online compiler (onlinegdb.com) to learn Pascal but it seems I can't use modules with that - if I put a unit before (or after) the main programme it doesn't work. Does anybody know if it's possible to use modules(units) with online compilers?

P.S. I only use online compilers when I have spare time at work (I'm not allowed to download anything there), at home I use Lazarus of course.

Thanks beforehand and sorry if I posted this in the wrong section of the forum

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12189
  • FPC developer.
Re: modules (units) in online compilers
« Reply #1 on: April 29, 2025, 10:09:22 am »
I got it to work in 2 minutes.

- Go to the left most icon (new file) or press ctrl-M.
- enter a name "unitname.pas"   Note that it must be a filename as you would in lazarus, so it must have an .pp or .pas extension.
- paste your unit source into it.
- add uses unitname; to your main program.
- fix your mainprogram so that it calls the unit.

Done.

aja_ttara

  • Newbie
  • Posts: 5
Re: modules (units) in online compilers
« Reply #2 on: April 29, 2025, 11:35:02 am »
+1

Thank you and sorry for the silly question  :-[

 

TinyPortal © 2005-2018