How do install OmniPascal into vscode - delphi

From the OmniPascal page on Visual Studio Marketplace:
How to install
Install Visual Studio Code and open it.
Open View -> Command Palette... and type ext install OmniPascal
Restart Visual Studio Code and open File -> Preferences -> User Settings
Add the key "objectpascal.delphiInstallationPath" to the right editor and set its value to the Delphi installation path. Don't forget to escape the backslashes! Example:
"objectpascal.delphiInstallationPath" = "C:\\Program Files (x86)\\Embarcadero\\Studio\\16.0",
Except that seems to be wrong; it complains that it shouldn't be an = (equals), but a : (colon):
I assume that's a typo, and it should be a colon:
But what should the path be?
The page gives the example path as:
C:\\Program Files (x86)\\Embarcadero\\Studio\\16.0
But the animated installation pastes in a path leading to the subfolder source:
Which is it? I only ask because neither path seems to enable suggestions:

Except that seems to be wrong; it complains that it shouldn't be an = (equals), but a : (colon)
Oh, obviously there's an error in the documentation. This will be fixed with the next release. Thanks.
Of course it should be a colon since it is an entry in a JSON file.
But what should the path be?
The entry objectpascal.delphiInstallationPath should point to the path where Delphi is installed. It doesn't matter whether you define the source subdirectory or not. The path is internally used to find Delphi units recursively. As all .pas files are located in the source folder the lookup is slightly faster when the entry looks like this:
"objectpascal.delphiInstallationPath": "C:\\Program Files (x86)\\Embarcadero\\Studio\\16.0\\Source"
Free Pascal users should point to the FPC directory
Sample:
"objectpascal.delphiInstallationPath": "C:\\lazarus\\fpc"
I only ask because neither path seems to enable suggestions
The syntax highlighting in your screenshot seems to come from another Pascal plugin for Visual Studio Code. When the OmniPascal plugin is active in a .pas file then the current file type is "ObjectPascal". You see it in the bottom right corner next to the smiling feedback button:
When the current file type is "Pascal" or anything else then the wrong plugin is active. Click on the file type and change it to "ObjectPascal". Now you should get code completion, quick infos and more.

Related

Loading F# modules not in the current directory

I'm writing a simple F# console app with Visual Studio 2017 targeting .NET Core 2.0. I'm wondering if it's possible to open a module not present in the current directory.
For example :
/root/foo.fs
/root/SubDirectory/bar.fs
How can bar.fs open the Foo module or vice versa?
I already tried :
open Foo
open "../Foo"
open "C:/AbsolutePath/Foo"
With the last two ones, VS complained with :
FS0010 : Unexpected string literal in open declaration. Expected identifier, 'global' or other token.
There seems to be no documentation about this.
Any help would be appreciated.
Actually you can only add or reorder files in VS2017 in the preview version I believe (so not yet on 15.5.6). But TheQuickBrownFox is correct, the file that has your module has to be in the fsproj file, and the order is important.
For VSCode, you can use the Command (or Project Explorer) in Ionide: Ctrl+Shift+P: F#: Add Current File to Project and also F#: Move File Up/Down (there's a right click meny on the F# Project Explorer as well.
In Visual Studio 2017 you can right-click the Project and choose Edit .fsproj. VS will reload the file automatically on save, so no need to unload a project like in VS2015. It will look something like this:
You can see that MyModule.fs is in the root of the project and the line with MyModule.fs needs to be above any other files that reference it. You can use Alt+Up/Down Arrow to move lines around.
Then you can just open this module and use it. For example Add is defined in this module.
I also added the #load directive, this is only if you want to test it in FSI, and the compiler will ignore it.

How does Delphi 7 find all the dcu files during compilation?

I am helping a coworker set up his computer so that his Delphi 7 environment works like mine. He has Delphi 7 installed plus the third party tools we use. We have a Delphi app with source. It compiles fine on my computer but when he compiles it on his computer, it keeps coming up with 'file not found' errors for many dcu files. These are dcu files of third party components, either which come with Delphi IDE or have been installed manually.
I renamed his C:\Program Files (x86)\Borland folder and copied my whole Borland folder structure to his so that he has what I have. So now his Delphi IDE and the app structure resembles mine, yet he still gets missing dcu's. Every time he gets a missing dcu, he adds its path to Delphi's 'Search path' list. For some dcu's, they exist in different folders which means we have to troubleshoot further to make sure we picked the correct version. My 'Search Path' is empty as shown below which tells me my Delphi doesn't use this entry to search for dcu's. Our computer's PATH environment variable entry has the same values for anything related to Delphi.
My question is why my delphi app compiles fine as it finds all the dcu's it needs which reside in different folders yet his Delphi is not finding them when we have the same folder structure and PATH?
How does the Delphi IDE finds all the dcu's it needs during compilation? What is left now to look at is the registry. Are the search patterns in the registry? Where? (We also have Delphi XE installed if this means anything)
You don't want to add these directories to your project's search path. That will make it so that only this project is able to use these components. Instead, you need to do this in the global library path, which applies for all projects. Check the library path of your existing installation, surely you'll find a large list of directories here.
Main Menu -> Tools -> Environment options dialog -> Library page -> Library Path edit box
They are the output paths, try looking in the following location
Tools > Options > Environment Options > delphi Options > Paths and Directories
This tells the IDE what source files to include. The only other difference can be if you system variables are different if you have any.
http://docwiki.embarcadero.com/RADStudio/XE8/en/Library

scripts don't recognize FSharp.Data

Somewhat of a F# beginner. I'm trying to test out some of my XmlTypeProvider code in the interactive window by first entering it in a script (fsx) file. The script file won't recognize the following
open FSharp.Data // gives "The namespace or module 'FSharp' is not defined"
Everything has been added to reference, and .fs files seem to not have any problems finding the XmlTypeProvider reference but for some reason, a script in the same project does not. I even got the code to work in a .fs file.
I added FSharp.Data with nuget and everything seem to add correctly. What am I missing here?
Add a reference in the script to the nuget packages folder that contains FSharp.Data.dll. That folder also contains the designer dll (FSharp.Data.DesignTime.dll)
#r #"<your nuget packages folder>\FSharp.Data.2.1.0\lib\net40\FSharp.Data.dll"
Incidentally, I was just debugging this error last week. There are essentially three possible reasons:
The file could not be found. The most obvious one is that F# actually cannot find the dll file. Make sure the reference is correct (check References in the project properties) or make sure your #r points to the right file (when using an F# script file)
Type provider is not trusted. The type provider is blocked by Visual Studio. This can happen if you click on "Disable" when you load the provider for the first time. To fix this, go to "Tools" - "Options" - "F# Tools" - "Type Providers" and enable the type provider (check "Trusted").
The DLL is blocked by OS. Finally, if the dll comes from an untrusted source, Windows might block it (this happens especially if you download a zip file and extract the file using Windows). To unblock the file, go to file properties and click "Unblock". There is a good description here..

Where do I find the bpl file after I compile a package?

I want to create *.bpl file but I am failing to do so.
Specifically, I am trying to make JEDI plugins, but I have tried an empty pure Delphi package, too.
If I create a new package in Delphi XE3, I get an empty unit - if I "make" this project called "Package1.bpl", I get a .dcu file in "debug/win32/", but no .bpl file.
No error is reported by the compiler.
An empty JEDI plugin (bpl-style) only gives a .dcu, too, while an empty dll-style JEDI plugin gives a .cdu and a .dll file in "debug/win32/".
This is the first time I am trying to make a new package, so I am completely lost.
What am I missing?
Go to the Tools menu and navigate to Environment Options -> Delphi Options -> Library.
There you find the Package Output Directory and the DCP Output Directory. These directories are the default output directories for BPLs and DCPs, so the bpl will be created if your packages is compiled, but in a different directory from what you expect.
The JEDI plugins probably have their output directory configured otherwise in Project -> Options.
For those that don't want to travel into Delphi IDE/options etc, lately in Delphi XE it's something like this:
"C:\Users\Public\Documents\Embarcadero\Studio\17.0\Bpl;"
Your exact folder might be different based on 17.0
These folders also end up in the path environment variable of your system, bit dangerous and can lead to some mighty magic loading confusion ?!
"How's that BPL still loading after it was deleted from my local project folder ?" :)
Another solution is to add "." to your project settings without the "". Prevents you from having to modify your delphi environment options/settings, something you probably never want to do since JEDI and other projects may rely on these default settings to function properly. Only change it if you know what you are doing and how to correctly make JEDI and others work if it was changed, this may get tricky/hairy, probably requires search paths to be added.

Compiler Directive error in Delphi 2005

Iam using Delphi 2005 and i have included a unit to the main unit using compiler directive i.e.{$I sample.pas} whenever I try to build the main pas file I get the below error . F 1026 File not found and it shows the path where the sample.pas file is available. I tried different options like tried adding the path of the pas file in the project options- search path and also in the tools-options -library path and it doesnt work. I googled it and found a solution which says to do the following:
In the IDE from the main menu, navigate to
“Tools|Options|Environment Options|Compiling and Running”
switch “Show Commandline” ON
AND set sure you have “Verbosity” set to “Diagnostic”.
The problem is Iam using Delphi 2005 and unable to find the “Verbosity” option in Delphi 2005. It would be great if some one can help me
In Delphi 2009 it is right under the Show Commandline setting:
However, unfortunately for you the verbosity option isn't present in D2006, so I guess it was introduced in either 2007 or 2009.
Oh, and as far as the include directive goes: if your sample pas isn't in the same folder as the unit in which it is included, you could try adding the path to the $I directive:
{$I ..\..\General\sample.pas}
Put the file in the same folder as your project units, and change its extension to ".inc" ( not mandatory but I think that by convention directives files are named like this).
A possible solution could be to get the code working in a package and then have the package keep that part of things compiled. I have been able to use include files in other paths with packages, but it is quite tempermental. It can start rejecting them even with packages for reasons I don't know. This is indeed a VERY annoying problem.
You might also look into doing your builds via your own batch files where you can take full control of the command-line settings that are being used.

Resources