Recent

Author Topic: Suggestions for Example projects  (Read 716 times)

sierdolg

  • New Member
  • *
  • Posts: 18
Suggestions for Example projects
« on: April 10, 2019, 11:32:40 am »
Just a short question: If you find (and can fix) some quirk in the examples, where/how do you report it to be corrected at source?
For example, in the "Mushroom Example" you could replace
"lib\$(TargetCPU)-$(TargetOS)"
by
"lib$(DirectorySeparator)$(TargetCPU)-$(TargetOS)"
(in Project Options → Compiler Options → Paths →Unit Output directory)
then the example will build without complaint on systems other than Windows, too.

Of course, "problems" of this kind are easy to solve by experienced users - but examples are intended for beginners ,-)



Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5567
    • wiki
Re: Suggestions for Example projects
« Reply #1 on: April 10, 2019, 01:08:09 pm »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3616
  • I like bugs.
Re: Suggestions for Example projects
« Reply #2 on: April 10, 2019, 01:15:49 pm »
...
then the example will build without complaint on systems other than Windows, too.
Of course, "problems" of this kind are easy to solve by experienced users - but examples are intended for beginners ,-)
Yes bugs can be reported in bug tracker but this one is not a bug.
Both directory separators work just fine on any system. The IDE is clever enough to change them if needed.
Did you test on other systems than Windows?

sierdolg

  • New Member
  • *
  • Posts: 18
Re: Suggestions for Example projects
« Reply #3 on: April 12, 2019, 12:02:46 pm »
We did not test under Windows at all, but under Linux. And it doesn't work here. The IDE refuses to compile with: "Unable to write state file for project Project
Error: Unable to create file ".../lazarus/304-trunk/lazarus/examples/database/sqlite_encryption_pragma/lib\x86_64-linux/project1.compiled"
Or how do you think we even came across the problem? ,-)

We believe that even if the IDE has built in so much special intelligence to be able to handle this automatically, it wouldn't hurt to have "$(DirectorySeparator)" in the examples anyway. Just to be sure. And it's instructive too.

The details: KDE Neon current (Ubuntu 18.04 based), which should be quite irrelevant, Lazarus 2.1.0 (SVN rev. 60786M) setup with fpcupdeluxe-x86_64-linux, FPC 3.0.4

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3616
  • I like bugs.
Re: Suggestions for Example projects
« Reply #4 on: May 06, 2019, 10:50:49 am »
Sorry for the late reply.
Indeed '\' is not supported. However '/' is supported also on Windows and the IDE automatically converts '\' into '/' when saving settings.
I have no idea how the '\' separator got saved into the .lpi files.
I will investigate and fix them. Wait...

Thaddy

  • Hero Member
  • *****
  • Posts: 8671
Re: Suggestions for Example projects
« Reply #5 on: May 06, 2019, 11:03:00 am »
Sorry for the late reply.
Indeed '\' is not supported. However '/' is supported also on Windows and the IDE automatically converts '\' into '/' when saving settings.
I have no idea how the '\' separator got saved into the .lpi files.
I will investigate and fix them. Wait...
DirectorySeparator is supported.....By FPC. Also works for Lazarus.... It is platform independent.  It may be that some parts of Lazarus do not adhere to it. That would be a bug...

https://www.freepascal.org/docs-html/rtl/system/directoryseparator.html

It is also defined for DOS/Windows.
« Last Edit: May 06, 2019, 11:07:23 am by Thaddy »
Most people that want to use threading should learn to patch their jeans first: use a needle.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3616
  • I like bugs.
Re: Suggestions for Example projects
« Reply #6 on: May 06, 2019, 01:36:57 pm »
Project options -> Miscellaneous has a setting:
 "Store path delimiters \ and / as"
which is a can of worms.
I remember the IDE understood also '\' on Linux earlier but it doesn't any more. I will look at it more.

Anyway, r61164 changed the path delimiter to '/' in many example projects. It works also on Windows. Please test.
'\' is better than $(DirectorySeparator) because the IDE can save it directly after user has selected a path. The $(DirectorySeparator) macro must be explicitly typed.
« Last Edit: May 06, 2019, 01:42:55 pm by JuhaManninen »

Thaddy

  • Hero Member
  • *****
  • Posts: 8671
Re: Suggestions for Example projects
« Reply #7 on: May 06, 2019, 03:46:34 pm »
Anyway, r61164 changed the path delimiter to '/' in many example projects. It works also on Windows. Please test.
'\' is better than $(DirectorySeparator) because the IDE can save it directly after user has selected a path. The $(DirectorySeparator) macro must be explicitly typed.
Do what I said... Mixing up is a can of worms....< :-X >:D>
FPC handles it correctly because of it...
Test it....
(And no, I am not prepared to contribute patches for Lazarus. Just FPC... Same reason. Somebody screwed up here)

With due respect, I know you do a good job,

Thaddy
« Last Edit: May 06, 2019, 03:50:38 pm by Thaddy »
Most people that want to use threading should learn to patch their jeans first: use a needle.