xsharp.eu • SET LIBRARY TO 'xxxxxxprogram.prg' ADDITIVE & DO 'xxxxxxprogram.prg'
Page 1 of 1

SET LIBRARY TO 'xxxxxxprogram.prg' ADDITIVE & DO 'xxxxxxprogram.prg'

Posted: Thu Jul 28, 2022 9:11 am
by Paul.Newman
Hello Forum,

Could anyone help with the following.

SET LIBRARY TO 'xxxxxxprogram.prg' ADDITIVE

DO 'xxxxxxprogram.prg' WITH (variable)

How would I integrate this VFP code in XSHARP VFP console app?

Many thanks

SET LIBRARY TO 'xxxxxxprogram.prg' ADDITIVE & DO 'xxxxxxprogram.prg'

Posted: Thu Jul 28, 2022 11:38 am
by robert
Paul,

FoxPro works with PRG files at runtime.
X# (and most other languages) work a bit different:
the sources are included in a project at compile time and are bundled into an output assembly (DLL or EXE) as binary code.
This binary code is run at runtime.
That is why the "SET LIBRARY " command does not really make sense in X#.
If you have common code that you want to use from multiple locations then you would create a library in VS as well. Use the "Class Library" template for that.
Then in your main app (the console app) you add a reference to the Class Library project.
This will create 2 assemblies.
- One for the class library (DLL)
- One for the main app (EXE)

You distribute these 2 assemblies and the X# runtime DLLs.

Of course you can also include the code from the library program in the main app. In that case you only get one assembly (the EXE).
Please note: if you "Add" an existing item to a VS project then VS creates a copy of that file in the project.
If you want to share a file between projects you should add what is called a "Linked Item".
On the "Add Existing Item" dialog there is a down arrow next to the [Add] button. Choose [Add As Link] to add the existing file as link. This will NOT copy the file to your project. That way you can share the same file between projects.
We do that all the time for common files, like the files that contain our version information. This is shared between all projects in the same solution, so they all have the same version number.

Robert