* * *

Author Topic: $I or $INCLUDE : Include compiler info  (Read 2030 times)

joho

  • Jr. Member
  • **
  • Posts: 69
  • Joaquim Homrighausen
    • ~/JoHo
$I or $INCLUDE : Include compiler info
« on: September 26, 2017, 12:17:31 am »

Could we have %FUNC% or %FUNCTION% here too?

https://www.freepascal.org/docs-html/prog/progsu41.html

Almir.Bispo

  • Jr. Member
  • **
  • Posts: 66
  • CSV Comp DB is the Best NoSQL
    • CSV Comp DB (NoSQL)
Re: $I or $INCLUDE : Include compiler info
« Reply #1 on: September 26, 2017, 04:04:37 am »
Yes ! You can put a full proggram there (and function too) like this:
This is on txt file
Code: Pascal  [Select]
  1. procedure Hello;
  2. begin
  3. showmessage('Hello !');
  4. end;
  5.  

on your main program call so:
Code: Pascal  [Select]
  1. begin
  2. {$i fullpath\your_hello_code.txt}
  3. end;
  4.  

My project (Nosql database manager) uses ILDE-Pascal like this:
{$i cql_to_pascal.txt}
 and it calls all function on ILDE-Pascal
To know more :http://adltecnologia.blogspot.com.br/p/macros.html
CSV Comp DB Developer {Pascal Lover}

molly

  • Hero Member
  • *****
  • Posts: 2343
Re: $I or $INCLUDE : Include compiler info
« Reply #2 on: September 26, 2017, 10:28:04 am »
@joho:
Did you mean like the name of the procedure or function ?

That already exists in trunk, see here it is used with %CURRENTROUTINE%


molly

  • Hero Member
  • *****
  • Posts: 2343
Re: $I or $INCLUDE : Include compiler info
« Reply #3 on: September 26, 2017, 11:13:21 am »
@Almir.Bispo
Excellent example on how to get frustrated with include files   ;D

joho

  • Jr. Member
  • **
  • Posts: 69
  • Joaquim Homrighausen
    • ~/JoHo
Re: $I or $INCLUDE : Include compiler info
« Reply #4 on: September 26, 2017, 05:35:29 pm »
@joho:
Did you mean like the name of the procedure or function ?

That already exists in trunk, see here it is used with %CURRENTROUTINE%

Yes, the name of the procedure/function.

__LINE__
__FILE__
__CLASS__
__FUNC__
__CAR__
__DRINK__


and other current life variables ;)

molly

  • Hero Member
  • *****
  • Posts: 2343
Re: $I or $INCLUDE : Include compiler info
« Reply #5 on: September 27, 2017, 09:30:46 am »
Well... line is already present (twofold), file (unit name) and class could probably be solved with rtti. Procedure/function name as well as line number can be obtained at runtime as well.

Now, car and drink.... That would be an interesting statistic... what was the programmer drinking and/or eating at the time the code was implemented and what vehicle (if any) was used during that process. That would give some managers a severe headache :D
« Last Edit: September 27, 2017, 09:34:23 am by molly »

joho

  • Jr. Member
  • **
  • Posts: 69
  • Joaquim Homrighausen
    • ~/JoHo
Re: $I or $INCLUDE : Include compiler info
« Reply #6 on: September 27, 2017, 10:48:24 am »
Well... line is already present (twofold), file (unit name) and class could probably be solved with rtti. Procedure/function name as well as line number can be obtained at runtime as well.

Now, car and drink.... That would be an interesting statistic... what was the programmer drinking and/or eating at the time the code was implemented and what vehicle (if any) was used during that process. That would give some managers a severe headache :D

1) But this requires RTTI to be "enabled", yes? A static, at-compile-time-method, may be preferred at times.

2) It would explain a lot of things I think :)


marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6097
Re: $I or $INCLUDE : Include compiler info
« Reply #7 on: September 27, 2017, 10:51:43 am »
Well... line is already present (twofold), file (unit name) and class could probably be solved with rtti. Procedure/function name as well as line number can be obtained at runtime as well.

Now, car and drink.... That would be an interesting statistic... what was the programmer drinking and/or eating at the time the code was implemented and what vehicle (if any) was used during that process. That would give some managers a severe headache :D

Read the help, if not a known builtin, it is assumed to be an environment variable. Make sure your drinking status and vehicle choice are correctly entered into the relevant environment variables. One could create a small lazarus extension to do so and update them before executing the compiler to make it easier.

p.s. class is hard to do statically, unless you mean only current scope.

joho

  • Jr. Member
  • **
  • Posts: 69
  • Joaquim Homrighausen
    • ~/JoHo
Re: $I or $INCLUDE : Include compiler info
« Reply #8 on: September 27, 2017, 10:59:14 am »
(Current scope)

Almir.Bispo

  • Jr. Member
  • **
  • Posts: 66
  • CSV Comp DB is the Best NoSQL
    • CSV Comp DB (NoSQL)
Re: $I or $INCLUDE : Include compiler info
« Reply #9 on: September 27, 2017, 04:09:31 pm »

"Excellent example on how to get frustrated with include files "

This include file function was created for this purpose.
CSV Comp DB Developer {Pascal Lover}

molly

  • Hero Member
  • *****
  • Posts: 2343
Re: $I or $INCLUDE : Include compiler info
« Reply #10 on: September 27, 2017, 05:46:01 pm »
@Almir.Bispo:

I think you misunderstood me.

Your example expands to:

Code: Pascal  [Select]
  1. begin
  2.   procedure Hello;
  3.   begin
  4.     showmessage('Hello !');
  5.   end;
  6. end;
  7.  

.. and which doesn't compile as was intended.  :'(

Code: [Select]
your_hello_code.inc(1,1) Error: Illegal expression
your_hello_code.inc(1,11) Fatal: Syntax error, ";" expected but "identifier HELLO" found
Fatal: Compilation aborted
« Last Edit: September 27, 2017, 05:52:18 pm by molly »

molly

  • Hero Member
  • *****
  • Posts: 2343
Re: $I or $INCLUDE : Include compiler info
« Reply #11 on: September 27, 2017, 06:06:20 pm »
Read the help, if not a known builtin, it is assumed to be an environment variable.
Thank you for reminding me to that.

Quote
Make sure your drinking status and vehicle choice are correctly entered into the relevant environment variables. One could create a small lazarus extension to do so and update them before executing the compiler to make it easier.
You are right, i did not considered that. That could indeed work, although perhaps a bit clumsy because eating and traveling habits changes during a hard-days work.

So what to put where exactly ? Would be nice to pinpoint whatever was consumed or traveled during the implementation and/or changing of a routine. Perhaps a small db where user can keep track of what is currently consumed or what travel-method is being used. Date and time could then f.i. linked to svn commits .... wasn't there someone working on statistics integration for Lazarus ?  8-)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus