Recent

Author Topic: Pas2Php (Pascal to Php Translator for Web App's)  (Read 10977 times)

derek.john.evans

  • Guest
Re: Pas2Php (Pascal to Php Translator for Web App's)
« Reply #15 on: November 20, 2014, 04:26:44 pm »
Quote
Does it install? What should be compilded? I mean, how is it used?

Just start with the demo project and go from there. The demo is a standard console app which when executed as a CGI app, acts as a CGI app. But, when it is executed from Lazarus, it runs the code below, which iterates your source from "index.pas", and generates php files for each of the pascal units found in the given paths. ie: via AddUnitPath().

Code: Pascal  [Select][+][-]
  1.       with TPas2Php.Create([{p2pIgnoreFileAge,} p2pNoElementListTitles]) do
  2.       begin
  3.         try
  4.           AddUnitPath(ProgramDirectory);
  5.           AddUnitPath(ProgramDirectory + DirectorySeparator + 'rtl');
  6.           AddUnitPath(ProgramDirectory + DirectorySeparator + 'inc');
  7.           TranslatePackage('index.pas');
  8.         finally
  9.           Free;
  10.         end;
  11.       end;    
  12.  

Therefore, your best starting point is to hack "index.pas". Find the function WriteDocument(), and write some simple pascal. eg:

Code: Pascal  [Select][+][-]
  1. procedure WriteDocument;
  2. begin
  3.   WriteLn('<H1>Hello Lazarus Forum</H1>');
  4. end;
  5.  

Run the project, and you will see that "index.pas" will be translated to "index.php". So, open up "index.php" to see what was created. There are lots of example functions and coding methods in the RTL folder to show how to call PHP functions, or access PHP superglobals. You can look at "P2PClasses.pas" and "P2PBuzz.pas" to see how much of the pascal language is currently supported. ie: Look at the results found in "P2PClasses.php" and "P2PBuzz.php".


« Last Edit: October 02, 2015, 03:39:23 am by Geepster »

xinyiman

  • Hero Member
  • *****
  • Posts: 2140
    • Lazarus and Free Pascal italian community
Re: Pas2Php (Pascal to Php Translator for Web App's)
« Reply #16 on: December 02, 2014, 10:47:51 am »
i created a mylibrary.pas how convert this in mylibrary.php?! thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1072
    • Burdjia
Re: Pas2Php (Pascal to Php Translator for Web App's)
« Reply #17 on: December 02, 2014, 12:06:06 pm »
Quote
Does it install? What should be compilded? I mean, how is it used?

Just start with the demo project and go from there. The demo is a standard console app which when executed as a CGI app, acts as a CGI app. But, when it is executed from Lazarus, it runs the code below, which iterates your source from "index.pas", and generates php files for each of the pascal units found in the given paths. (...)
  :o No way.  You're kidding me... How is it possible!?!?

Anyway, I've downloaded it, extracted, opened the "project" with Lazarus, compiled and executed, the "index.cgi" file was created and Lazarus keeped minimized (I had to stop it).  I've also removed the "index.php" file and so, I've repeated but no new file were created.  %)  I'm using Linux (Fedora 20-64bit), by the way.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

 

TinyPortal © 2005-2018