AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Zugriff auf Environmental-Variablen mit compiler directives (Pre-Compile-Script) ?
Thema durchsuchen
Ansicht
Themen-Optionen

Zugriff auf Environmental-Variablen mit compiler directives (Pre-Compile-Script) ?

Ein Thema von Rollo62 · begonnen am 29. Apr 2020 · letzter Beitrag vom 30. Apr 2020
 
Rollo62

Registriert seit: 15. Mär 2007
4.170 Beiträge
 
Delphi 12 Athens
 
#1

Zugriff auf Environmental-Variablen mit compiler directives (Pre-Compile-Script) ?

  Alt 29. Apr 2020, 10:51
Delphi-Version: 5
Hallo zusammen,

der FPC hat ein schönes Feature, gibt es vielleicht was Vergleichbares bei Delphi Pascal ?
! Wohlgemerkt, mir geht es um die Auswertung VOR dem eigentlichen Code-teil,
um die Ergebnisse in einem conditionalen Code benutzen zu können, ohne Include "{I 'MyInc.inc'}".
Wie der Zugriff im Code funktioniert ist mir klar.

Zitat:
1.1.23 $I or $INCLUDE : Include compiler info

In this form:

{$INCLUDE %xxx%}

where xxx is one of TIME, DATE, FPCVERSION or FPCTARGET, will generate a macro with the value of these things. If xxx is none of the above, then it is assumed to be the value of an environment variable. It's value will be fetched, and inserted in the code as if it were a string.

For example, the following program

Program InfoDemo;

Const User = {$I %USER%};


begin
Write ('This program was compiled at ',{$I %TIME%});
Writeln (' on ',{$I %DATE%});
Writeln ('By ',User);
Writeln ('Compiler version : ',{$I %FPCVERSION%});
Writeln ('Target CPU : ',{$I %FPCTARGET%});
end.

Creates the following output :

This program was compiled at 17:40:18 on 1998/09/09
By michael
Compiler version : 0.99.7
Target CPU : i386

Sowas naheliegendes "Const User = '$(MyVar)';" hatte ich schon probiert, geht leider nicht.

Geändert von Rollo62 (29. Apr 2020 um 15:33 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz