In Delphi is it possible to use enviroment variables in include statement? - delphi

I need to include StyleUtils.inc and StyleAPI.inc in my source file, but I don't want to copy the files to my project folder, or reference the files directly, as the contents and location could change on newer versions of Delphi, although I can see the files under C:\Program Files (x86)\Embarcadero\Studio\22.0\source\vcl.
The BDS environment variable points to C:\Program Files (x86)\Embarcadero\Studio\22.0, so I was wanting to include the files as below, but I have tried escaping with $(), ${}, %%, but the variable is not being referenced.
{$I $(BDS)\Source\Vcl\StyleUtils.inc}

No, you cannot use environment variables in {$I} directive. What you need to do instead is use a relative path in the directive, and then specify the root folder in the project's Search path configuration, per the documentation:
https://docwiki.embarcadero.com/RADStudio/en/Include_file_(Delphi)
If the filename does not specify a directory path, then, in addition to searching for the file in the same directory as the current module, Delphi searches in the directories specified in the Search path input box on the Delphi Compiler page of the Project > Options dialog box (or in the directories specified in a -I option on the command line compiler).

Related

How to set output directory for QMake generated vcproj files

Is there anyway to modify the path where *.vcproj (and *.vcxproj, *.sln...) files generated by QMake are written ?
I do not want to modify the path of the generated *.exe or *.dll file. I'm looking for a way to create the *.vcproj file out of my sources directory, to keep it clean from any generated file.
I'm using Qt 5.5.
Thanks
EDIT :
By default, QMake generate a .sln/.vcproj file next to the *.pro file (in the same directory). I'm looking for a way to generate the .sln/.vcproj file elsewhere.

Inno Setup (How to get dynamically path to file)?

I'm making a setup script in Inno and I was wondering, how can I get non "hardcoded" path. Here is example:
Thanks in advance!
SOLUTION:
You can get .iss folder by using predefined variable
SourcePath
Usage would be like: {#SourcePath}\???\bin\x86\Release\???.exe
Thanks all who contributed!
The reference about the source directory says (emphasized by me):
By default, the Setup Compiler expects to find files referenced in the script's [Files] section Source parameters, and files referenced
in the [Setup] section, under the same directory the script file is
located if they do not contain fully qualified pathnames. To specify
a different source directory, create a SourceDir directive in the
script's [Setup] section.
This includes also option to specify relative path to the files. So let's assume that you have the following file structure and you didn't specify a different path in the SourceDir directive:
C:\Deploy\Script.iss
C:\Deploy\MyProg.exe
C:\Deploy\SubFolder\MyOtherProg.exe
C:\Folder\SomeFile.txt
Now if you'd like to include the MyProg.exe into the setup compiled from the Script.iss script, you could specify just the file name without the path, since the MyProg.exe file is stored in the same folder as the script, so you could write just:
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
And you can use a relative path to the MyOtherProg.exe which is stored in the subfolder of the folder where the Script.iss script is stored this way:
[Files]
Source: "SubFolder\MyOtherProg.exe"; DestDir: "{app}"
As well as you can use a relative path to include the SomeFile.txt stored in a subfolder of the parent folder where the script is stored:
[Files]
Source: "..\Folder\SomeFile.txt"; DestDir: "{app}"
More about relative path conventions you can read in this chapter.
Like OP has said in his own question,
You can get .iss folder by using predefined variable
SourcePath
Usage would be like: {#SourcePath}\???\bin\x86\Release\???.exe

Sublime 2 can not find file in the path (LaTeX plugin)

I have a project in directory A and files that I use in all my projects are in directory B.
When I moved a .sty file from A to B, the main .tex file does not compile anymore.
The error is that the .sty file was not found. I am puzzled because:
Directory B is included in the path of the project.
I cleaned (deleted manually) all the auxiliary files used in the previous compilations.
I refreshed the project folders .
Did anyone had similar problems? Suggestions?
The file LaTeX.sublime-build, within the Sublime Text folder . . . /Packages/LaTeXTools, contains a $PATH for different operating systems.
For example, Sublime Text 2 on an OSX operating system, has a file located at ~/Library/Application Support/Sublime Text 2/Packages/LaTeXTools/LaTeX.sublime-build. The relevant line of code for a MacTeX TexLive 2012 installation is "path": "$PATH:/usr/texbin:/usr/local/bin",. The plugin LaTeXTools looks in that path for *.sty files that are a part of the TexLive installation. While it may be possible (under some circumstances) to place the *.sty files within the working directory of the *.tex file, this particular plugin looks to the path mentioned hereinabove. So one option would be to add additional locations to the $PATH to suit the needs of the user, or simply place the *.sty files within the path that is pre-defined by the plugin developer.

LuaEdit can't find module when Lua files all in the same folder

I downloaded LuaEdit to use as an IDE and debug tool however I'm having trouble using it for even the simplest things. I've created a solution with 2 files in it, all of which are stored in the same folder. My files are as follows:
--startup.lua
require("foo")
test("Testing", "testing", "one, two, three")
--foo.lua
foo = {}
print("In foo.lua")
function test(a,b,c) print(a,b,c) end
This works fine when in my C++ compiler when accessed through some embed code, however when I attempt to use the same code in LuaEdit, it crashes on line 3 require("foo") with an error stating:
module 'foo' not found:
no field package.preload['foo']
no file 'C:\Program Files (x86)\LuaEdit 2010\lua\foo.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\lua\foo\init.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\foo.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\foo\init.lua'
no file '.\foo.lua'
no file 'C:\Program Files (x86)\LuaEdit 2010\foo.dll'
no file 'C:\Program Files (x86)\LuaEdit 2010\loadall.dll'
no file '.\battle.dll'
I have also tried creating these files prior to adding them to a solution and still get the same error. Is there some setting I'm missing? It would be great to have an IDE/debugger but it's useless to me if it can't run linked functions.
The issue is probably that your Lua files are not on the path in package.path (for C files this is package.cpath).
My guess is that the LuaEdit program is not launched in the directory you have your files in, and hence does not have a match for eg .\foo.lua.
You have 3 simple solutions to this (from dumb to smarter):
Find out what path LuaEdit considers as ./ and put your files there.
Open up a terminal in the right directory (the one containing your files), and run LuaEdit from there.
Add the path the files are on to package.path and package.cpath before doing any require's
You may need to put:
lua
package.path = package.path..";c:/path/to/my/files/?.lua"
at the beginning of your files before any require (as jpjacobs indicated). I couldn't find any way to provide this from LuaEdit itself. It appears it runs the script using its full path, but keeps its current dir set to whatever it was when the IDE was started. If you run LuaEdit using full path from your application folder, it should work fine even without package.path changes.
While the IDE itself works fine with its own modules/libraries, it doesn't mean it makes them available to the application it runs.
(shameless plug) If you're still not happy with LuaEdit, I'd offer ZeroBrane Studio Lua IDE as an alternative, It's based on the same wxLua framework, but provides a bit more functionality and doesn't have this particular issue you're facing. It also supports remote debugging, so you should be able to debug your Lua scripts directly from your application.

delphi 2009 compile packages

i truly don't get it.
trying to recompile the qr5 packages, and is impossible with this Delphi.
build the QR5Run_Rad6.bpl, everything is fine.
when i install QR5Design_RAD6.bpl an error message appears
"its not possible to run the program since qr5run_rad.bpl is missing in your computer. try again installing your program to solve this problem."
just did!
clean build compile doesn't work in any order. closed the ide and reopened , still doesn't work.
what else is left?
clean all related dcp and bpl
QR5Design_RAD6.bpl <> qr5run_rad.bpl
And more importantly, the qr5run_rad.bpl needs to be found on the systempath in order for the IDE to find it so it can be used by the design time package.
In other words: you need to build the qr5run_rad.bpl as well as the QR5Design_RAD6.bpl. And you need to make sure that the qr5run_rad.bpl ends up in a folder that is on your system path, not just any old folder where you have the sources and/or dcu's.
In addition to what Marjan wrote:
Windows uses these places when looking for a DLL (or BPL, which is a DLL):
The directory from which the application loaded.
The system directory. Use the GetSystemDirectory function to get the path of this directory.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The current directory.
The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
Delphi puts BPL files in a directory like C:\Documents and Settings\All Users\Documents\RAD Studio\8.0\Bpl which it adds to your PATH when Delphi is installed. For Delphi 2009, that Path would probably be C:\Documents and Settings\All Users\Documents\RAD Studio\6.0\Bpl on a Windows XP machine.
--jeroen

Resources